cohen [mailto:ehudco.l...@gmail.com]
Sent: Friday, December 18, 2009 1:05 PM
To: Daniel Nordlund
Cc: r-help@r-project.org
Subject: Re: [R] how to combine multiple indicator variables in a single
factor
you can try:
df$f<-names(df)[apply(df,1,function(x) which(x==1))]
Ehud
On Fri, Dec 18, 2009 at 10:48 PM
> Cc: r-help@r-project.org
> Subject: Re: [R] how to combine multiple indicator variables in a single
> factor
>
> you can try:
>
> df$f<-names(df)[apply(df,1,function(x) which(x==1))]
>
> Ehud
>
> On Fri, Dec 18, 2009 at 10:48 PM, Daniel Nordlund
> wrot
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Daniel Nordlund
> Sent: Friday, December 18, 2009 12:49 PM
> To: r-help@r-project.org
> Subject: [R] how to combine multiple indicator variables in a
> single factor
>
> Say I h
you can try:
df$f<-names(df)[apply(df,1,function(x) which(x==1))]
Ehud
On Fri, Dec 18, 2009 at 10:48 PM, Daniel Nordlund
wrote:
> Say I have a dataframe like this:
>
> df <- data.frame(cbind(c(1,0,0,1),c(0,1,0,0),c(0,0,1,0)))
>
> names(df) <- c('a','b','c')
>
> I would like to create a factor i
4 matches
Mail list logo