[R] Level name as object name

jim holtman jholtman at gmail.com
Fri Oct 2 02:34:44 CEST 2009


assign(levels(data$Species)[1], 1:10)

or you might want to consider the use of a list depending on what you
are trying to do.

On Thu, Oct 1, 2009 at 7:26 PM, jimdare <jamesdare26 at gmail.com> wrote:
>
> Hi,
>
> If I have a dataset called "data" with a factor called "Species" that has
> three levels "Sp1", "Sp2", and "Sp3".  Is there a way to name an object
> after a specific level?  I have tried the code below and get the error
> "error in paste(levels(data$Species)[1]) <- 1:10   could not find function
> "paste<-"
>
> Code:
> paste(levels(data$Species)[1])<-1:10
>
> Thanks for your help.
>
> James
> --
> View this message in context: http://www.nabble.com/Level-name-as-object-name-tp25708252p25708252.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list