In R; I would like to do something in R rather than excel because excel can’t handle the calculation. In excel the calculation is: =A2+SUM($B$2:B2)

Look into dplyr https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html

install.packages("dplyr")

library(dplyr)

df <- df %>% mutate(phys_pos=cumsum(length)+position)

I am assuming your data.frame is named df

Or with base R

df$phys_pos <- cumsum(df$length) + df$position

Leave a Comment