[R] RE : creating character vector

Wolfgang RAFFELSBERGER wraff at igbmc.fr
Mon Mar 14 10:43:38 CET 2011


Jim,

I don't know if this is the most elegant solution :

Copy the following to your clipboard (some editors will require also to take last paragraph mark)
first
second
third

> ## now go to R and use
> dat <- read.table("clipboard")  # will give data.frame
> dat
      V1
1  first
2 second
3  third
> ## or if you want a character-vector
> dat <- as.character(as.matrix(read.table("clipboard")))
> dat
[1] "first"  "second" "third" 



. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
IGBMC,
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300         Fax (+33) 388 65 3276
wolfgang.raffelsberger at igbmc.fr

________________________________________
De : r-help-bounces at r-project.org [r-help-bounces at r-project.org] de la part de Maas James Dr (MED) [J.Maas at uea.ac.uk]
Date d'envoi : lundi 14 mars 2011 10:29
À : r-help at r-project.org
Objet : [R] creating character vector

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