I am trying to subtract the mean (using the sweep function) from each column of the inbuilt longley data set in R, except from the ‘Year’ column. I have tried
sweep(apply(longley,2,mean),2,-c["Year"])
but is giving me the error
Error in c["Year"] : object of type 'builtin' is not subsettable
It seems like a simple question but I just can't figure out how to exclude the 'Year' column in this function
Thank you