Nick Riches
2011-Feb-28 11:55 UTC
[R] Creating new variables. How do you get them into a data frame?
Hi I'm an R newbie. I can't seem to add new variables to data frames. Here are the stages (1) I import the data using read.csv. (2) I fix it using fix(data) (3) I create a new variable using spos<-tagPOS(stim,language="en",model=NULL,tagdict=NULL). (tagPOS is a function in the OpenNLP toolkit, which tags a string for part of speech. "stim" is a variable in the current data frame) What happens is that the new variable, "spos" is saved as an object, but not added to the data frame. Could anyone help me with this? Thanks Nick Riches -- Lecturer in Speech and Language Pathology Room 1.9 King George VI Building Queen Victoria Road University of Newcastle-upon Tyne NE1 7RU 0191 222 8720 [[alternative HTML version deleted]]
Sarah Goslee
2011-Feb-28 12:05 UTC
[R] Creating new variables. How do you get them into a data frame?
Hi Nick, You want: cbind(mydataframe, newvar) and possibly also a quick read of one of the intro to R documents available online. Sarah On Mon, Feb 28, 2011 at 6:55 AM, Nick Riches <nick.riches at gmail.com> wrote:> Hi > > I'm an R newbie. I can't seem to add new variables to data frames. Here are > the stages > > (1) I import the data using read.csv. > (2) I fix it using fix(data) > (3) I create a new variable using > spos<-tagPOS(stim,language="en",model=NULL,tagdict=NULL). > > (tagPOS is a function in the OpenNLP toolkit, which tags a string for part > of speech. "stim" is a variable in the current data frame) > > What happens is that the new variable, "spos" is saved as an object, but not > added to the data frame. > > Could anyone help me with this? > > Thanks > > Nick Riches >-- Sarah Goslee http://www.functionaldiversity.org