[R] creating character vector

Allan Engelhardt allane at cybaea.com
Mon Mar 14 16:32:04 CET 2011


You could try

scan(what=character(0), sep=",", file=textConnection("first,second,third"))


but better to put the strings in a file (say, strings.txt), one per 
line, and read it using

scan("strings.txt", what=character(0), sep="\n")


Even better is to understand what you are really trying to do and we can 
maybe help with that.

Hope this helps a little


Allan
---
http://www.cybaea.net/Blogs/Data/


On 14/03/11 09:29, 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.
>
> Thanks
>
> Jim
>
>
> ===============================
> Dr. Jim Maas
> University of East Anglia
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list