[R] Concatenate a Variable

John Kane jrkrideau at yahoo.ca
Fri Feb 1 18:47:09 CET 2008


R is treating tablea[,1] as a factor.  Try converting
it to character.

--- Carla Rebelo <crebelo at liaad.up.pt> wrote:

> Good morning!
> 
> I do not speak English very well and so I will try
> to explain the best I 
> can. I have this:
> 
>  > tabela[,1]
> [1] a a b b a c b a c c c c c
> Levels: a b c
> 
>  >unique(tabela[,1])
> [1] a b c
> Levels: a b c
> 
>  >var<-unique(tabela[,1])[1]
> 
>  > var
> [1] a
> Levels: a b c
> 
> But if I concatenate like this
>  > cat("VAR: ", var, "\n")
> 
> I obtain
>  >VAR:  1
> 
> and I want to obtain
>  >VAR: a
> 
> How can I do this? Thanks!
> 
> ______________________________________________
> 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.
> 



      Looking for the perfect gift? Give the gift of Flickr!



More information about the R-help mailing list