I have entered the following code in R and trying to caluclate mean of all the columns starting from column 2 but getting an error stating:
Error in colMeans(calculate[2:9]) : 'x' must be numeric.
Data:
calculate<-read.csv("Populationdata.csv",header=TRUE)
head(calculate)
ï..State Yr_2000 Yr_2001 Yr_2002 Yr_2003 Yr_2004 Yr_2005 Yr_2006 Yr_2009 Yr_2010
1 Alabama 7,465 14,899 19,683 23,521 26,338 30,894 33,096 35,625 38,965
2 Alaska 13,007 20,887 25,798 29,642 33,568 38,138 42,603 46,778 55,940
3 Arizona 8,854 16,262 20,634 24,988 26,838 31,936 32,935 35,979 39,060
4 Arkansas 7,113 13,779 18,546 21,995 24,289 28,473 31,946 34,723 39,107
5 California 11,021 20,656 24,496 32,149 33,749 39,626 42,325 44,980 52,651
6 Colorado 10,143 18,818 24,865 32,434 34,283 39,491 41,344 45,135 50,410
class(calculate)
#[1] "data.frame"
colMeans(calculate[2:9])
Error in colMeans(calculate[2:9]) : 'x' must be numeric
Please help me out where i am going worng on this. Actual Data in Csv file is :
