[R] Question about list function

jim holtman jholtman at gmail.com
Tue Nov 23 18:25:44 CET 2010


Try this:

> input <- textConnection("var1 a
+ var2 b
+ var3 c
+ var4 d
+ var5 e")
> x <- read.table(input, as.is = TRUE)
> close(input)
> # create a list
> xList <- as.list(x$V2)
> names(xList) <- x$V1
> xList
$var1
[1] "a"

$var2
[1] "b"

$var3
[1] "c"

$var4
[1] "d"

$var5
[1] "e"

>


On Tue, Nov 23, 2010 at 12:05 PM, Guido Leoni <guido.leoni at gmail.com> wrote:
> Dear List I'm a newbie R user.
> I'm utilizing the list function in order to make a var like this:
> clusters<-list(a=var1,b=var2....) My problem is that the total numer of
> variables that I need to include in my list is up to 200. I've the text
> string with the complete list of my variables but is too long to cut and
> paste in my bash shell.
> So is there a way too import the list from a text file?
> Thank you very much for any kind of help
> Guido
>
>
> --
> Guido Leoni
> National Research Institute on Food and Nutrition
> (I.N.R.A.N.)
> via Ardeatina 546
> 00178 Rome
> Italy
>
> tel     + 39 06 51 49 41 (operator)
>        + 39 06 51 49 498 (direct)
>
>        [[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list