Within my dataset there are many rows that are code markers and then many columns i believe we're only interested in column 2-96 as column 1 is the code markers names. 2-50 is c3 repititions and 50 - 96 is c4. For each code marker i am meant to produce a mean and sd from their c3 and c4 repetitions so the out put is a mean and sd of c3 and c4 for every code marker (row name). the column names are not just c3 for all the c3 repetitions it goes c3_1, c3_1.1, etc. I would like it to be one function for both sd and mean for both c3 and c4. I was thinking that probably means using the column number would work better (as mention earlier).
I managed to create this code however it does what i need but for columns not rows, is this a simple fix?
df1[,lapply(.SD, function(x) return(c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE)))), .SDcols = colnames(df1)[2:6]]