I am a newish R user and have a basic question about na.rm
I have a long list of dataframes, from which I am trying to calculate column means. I have the following code to do this -
results <- lapply(list_of_data_frames,
function(x) colMeans(subset(x, select = c(colname1, colname2), na.rm = TRUE)))
This works great but the na.rm piece isn't working, in that I get the result 'NA' for data frames within the list where there is 1 or more NA in the relevant column. Is it positioned correctly in the code?
All help massively appreciated.
Oli