[R] creating character vector

Allan Engelhardt
Mon, 14 Mar 2011 15:32:04 -0000

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.