[R] creating character vector

Jim Lemon
Mon, 14 Mar 2011 09:41:00 -0000

On 03/14/2011 08:29 PM, Maas James Dr (MED) wrote:
> Is there a way to convince R to create a character vector without using the
quotes?
>
> This works
>
> ex1<-  c("first","second")
>
> but when I try this it doesn't
>
> ext<- as.character(c(first,second))
>
> it complains. I have many variables to put into character vectors so
dispensing with the quotes would be useful.
>
Hi Jim,
If you are reading values in from a file, you can get character vectors
like this:

<contents of file "charvec.txt">
Monday Tuesday Wednesday Thursday Friday Saturday

charvec<-unlist(read.table("charvec.txt",stringsAsFactors=FALSE))
is.character(charvec)

Jim