-1

R newbie here. I have a csv sheet which i have sorted my data according to gender (Child's sex). I want to add/sum the column up to a certain point only, in this case I want to sum the Child's age column from column 301 to 311 then store the value, and then 312 to 336. how do i do this in r. Thanks

enter image description here

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
shja
  • 3
  • 1
  • 8

1 Answers1

0

You could library(data.table):

data <- as.data.table( read.csv(file.choose(), header = T) )
data[,.(age_sum = sum(age)), by=list(child_sex) ]
Mario
  • 2,393
  • 2
  • 17
  • 37