[R] Changing names of a string variable

2010-12-07 Thread Jahan
Hello, Here is the data set I am working with: dat=read.csv('http://dl.dropbox.com/u/1852742/relexpressions.csv') names(dat) #Under the 'target' column, I want to change all of the values into all capital letters (e.g. fgf2 becomes FGF2). I have taken a loop approach but I think my Python

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Hello, To do what you want, see ?toupper : levels(dat$target) - toupper(levels(dat$target)) However, for clarity, dat$target is not a string variable, it is a factor, which you can verify with str(dat) Factors are enumerated types, and have a discrete set of 'levels' associated with them,

Re: [R] Changing names of a string variable

2010-12-07 Thread Phil Spector
Jahan - Try dat$target = toupper(dat$target) I would not recommend a loop for something like this. (You might also want to brush up on your python, because what you're trying doesn't work in python either.) - Phil Spector

Re: [R] Changing names of a string variable

2010-12-07 Thread Erik Iverson
Phil Spector wrote: Jahan - Try dat$target = toupper(dat$target) Note that in this case, the above *will* coerce dat$target to a character vector, which may or may not be what is intended. __ R-help@r-project.org mailing list

Re: [R] Changing names of a string variable

2010-12-07 Thread David Winsemius
On Dec 7, 2010, at 2:31 PM, Erik Iverson wrote: Hello, To do what you want, see ?toupper : levels(dat$target) - toupper(levels(dat$target)) However, for clarity, dat$target is not a string variable, it is a factor, which you can verify with str(dat) And to further clarify, it is a