Re: [R] creating character vector

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Mon, 14 Mar 2011 20:41:00 +1100

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



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. Received on Mon 14 Mar 2011 - 09:44:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Mar 2011 - 10:10:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive