Re: [R] Creating new variables in R

2015-10-26 Thread Duncan Murdoch
ginal Message- >>> From: R-help [mailto:r-help-boun...@r-project.org <mailto:r-help-boun...@r-project.org>] On Behalf Of Duncan >>> Murdoch >>> Sent: Monday, October 26, 2015 11:58 AM >>> To: Lorenz, Jennifer; r-help@r-project.org <mailto:r-help@r-project.org

Re: [R] Creating new variables in R

2015-10-26 Thread peter dalgaard
g>] On Behalf Of Duncan >>> Murdoch >>> Sent: Monday, October 26, 2015 11:58 AM >>> To: Lorenz, Jennifer; r-help@r-project.org <mailto:r-help@r-project.org> >>> Subject: Re: [R] Creating new variables in R >>> >>> On 26/10/2015 6:24 A

Re: [R] Creating new variables in R

2015-10-26 Thread Erich Neuwirth
gt; To: Lorenz, Jennifer; r-help@r-project.org <mailto:r-help@r-project.org> >> Subject: Re: [R] Creating new variables in R >> >> On 26/10/2015 6:24 AM, Lorenz, Jennifer wrote: >>> Hi, >>> >>> I have a question regarding the creation of ne

Re: [R] Creating new variables in R

2015-10-26 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan > Murdoch > Sent: Monday, October 26, 2015 11:58 AM > To: Lorenz, Jennifer; r-help@r-project.org > Subject: Re: [R] Creating new variables in R > > On 26/10/2015 6

Re: [R] Creating new variables in R

2015-10-26 Thread Duncan Murdoch
On 26/10/2015 6:24 AM, Lorenz, Jennifer wrote: > Hi, > > I have a question regarding the creation of new variables on the basis of > existing ones in R. > > I have two variables containing information on parents' educational degree > (e.g. 1 'high school degree', 2 'college degree', etc.). I w

[R] Creating new variables in R

2015-10-26 Thread Lorenz, Jennifer
Hi, I have a question regarding the creation of new variables on the basis of existing ones in R. I have two variables containing information on parents' educational degree (e.g. 1 'high school degree', 2 'college degree', etc.). I would like to create a new variable for 'parents' highest edu

Re: [R] Creating new variables. How do you get them into a data frame?

2011-02-28 Thread Nick Riches
Many thanks for the info Nick Riches On 28 February 2011 12:05, Sarah Goslee wrote: > 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 > wrote

Re: [R] Creating new variables. How do you get them into a data frame?

2011-02-28 Thread Sarah Goslee
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 wrote: > Hi > > I'm an R newbie. I can't seem to add new variables to data frames. Here are > the stages > > (1)

[R] Creating new variables. How do you get them into a data frame?

2011-02-28 Thread Nick Riches
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, w

Re: [R] Creating new variables

2009-10-10 Thread David Winsemius
On Oct 10, 2009, at 7:49 PM, Ashta wrote: Thanks. This helps. How do I generate P? Will this work? p1<-pnorm(mean=0, std=1) p2<-pnorm(mean=0, std=1) Seems unlikely. You are not supplying sufficient arguments for the pnorm function for one thing. For another I suspect you really want the r

Re: [R] Creating new variables

2009-10-10 Thread Jim Holtman
you will have to specify what 'x' is. I am not sure what you are trying to do with the variables you have not defined. Sent from my iPhone On Oct 10, 2009, at 19:49, Ashta wrote: > Thanks. This helps. How do I generate P? > Will this work? > > p1<-pnorm(mean=0, std=1) > p2<-pnorm(mean=0, std

Re: [R] Creating new variables

2009-10-10 Thread Ashta
Thanks. This helps. How do I generate P? Will this work? p1<-pnorm(mean=0, std=1) p2<-pnorm(mean=0, std=1) x <- cbind(x, v1=ifelse(x[,'p'] > 0.4, 1, 0), v2=ifelse(x[,'2'] > 0.6, 0, 1)) If the 'data set' is a dataframe, the following will work: x$v1 <- ifelse(x$p > 0.4, 1, 0) x$v2 <- ifelse

Re: [R] Creating new variables

2009-10-10 Thread jim holtman
If the 'data set' is a dataframe, the following will work: x$v1 <- ifelse(x$p > 0.4, 1, 0) x$v2 <- ifelse(x$p > 0.6, 1, 0) If it is matrix, try x <- cbind(x, v1=ifelse(x[,'p'] > 0.4, 1, 0), v2=ifelse(x[,'p'] > 0.6, 1, 2)) If helps a lot if you follow the posting rules and provide commented, mi

[R] Creating new variables

2009-10-10 Thread Ashta
Hi all, I have a data set called x with200 rows and 12 columns. I want create two more columns based on probability. ie if p >0 .4 then v1 =1 else v1=0; if p >0 .6 then v2 =1 else v2=0; Finally x will have 14 variables. Can any one show me how to do that? Thanks Ashta .