[R] Column name assignment problem
Steve Murray
smurray444 at hotmail.com
Mon Mar 30 12:19:49 CEST 2009
Jim and all,
Thanks - I managed to get it working based on your helpful advice.
I'm now trying to do something very similar which simply involves changing the names of the variables in column 1 to make them more succinct. I'm trying to do this via the 'levels' command as I figured that I might be able to apply the character strings in a similar way to how you recommended when dealing with 'colnames'.
# Refine names of rivers to make more succinct
riv_names <- get(paste("arunoff_",table_year, sep=''))[,1]
levels(riv_names) <- c("AMAZON", "AMUR", "CONGO", "LENA", "MISSISSIPPI", "NIGER", "NILE", "OB", "PARANA", "YANGTZE", "YENISEI", "ZAMBEZI")
assign(get(paste("arunoff_",table_year, sep='')[,1], levels(riv_names)))
Error in paste("arunoff_", table_year, sep = "")[, 1] :
incorrect number of dimensions
My thinking was to assign the levels of riv_names to column 1 of the table...
Many thanks again for any advice offered,
Steve
More information about the R-help
mailing list