[R] Setting name attributes to a vector - join?
Andy Bunn
abunn at montana.edu
Mon Jul 21 22:19:54 CEST 2003
I have a vector of land cover class data from a GIS:
> landcov[1:10,2] #the first ten examples of a large (100k+) object
1 2 3 4 5 6 7 8 9 10
12 12 01 12 01 15 15 15 15 15
etc.
I also have a lookup table for the class data that gives the cover type
as a string:
> cnd.names #the look up table, i.e., landcov[3,2] == 1 == "Montane
Meadow"
CndVal Cnddbname
1 1 Montane Meadow
2 2 Sierran Mixed Coniferous Forest
3 3 Mixed Montane Chaparral
4 4 Jeffrey Pine-Fir Forest
5 5 Sierran White Fir Forest
etc.
How can I create an object that has the string as its value?
I.e., foo[3] <- "Montane Meadow"
I tried using apply and a custom function but couldn't get it to work.
I feel like this is trivial but am stuck fast.
Thanks, Andy
More information about the R-help
mailing list