-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
  • 451,927
  • 24
  • 239
  • 318
shja
  • 3
  • 1
  • 7

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,043
  • 1
  • 15
  • 32