Re: [R] naming components of a list

From: N. Lapidus <n.lapidus_at_gmail.com>
Date: Sun, 25 May 2008 23:11:46 +0200

And if you have "thousands of names" like this: names(L) <- paste ("names", 1:length(L), sep="")

Nael

On Sun, May 25, 2008 at 10:38 PM, Erin Hodgess <erinm.hodgess_at_gmail.com> wrote:

> try this:
>
> > names(L) <- c("name1","name2","name3")
> > L
> $name1
> [1] "Fred"
>
> $name2
> [1] "Mary"
>
> $name3
> [1] "SAM"
>
> >
> >
> HTH,
> Sincerely,
> Erin
>
>
> On Sun, May 25, 2008 at 2:42 PM, joseph <jdsandjd_at_yahoo.com> wrote:
> > Hi
> > I have a character vector with thousands of names which looks like this:
> >> V=c("Fred", "Mary", "SAM")
> >> V
> > [1] "Fred" "Mary" "SAM"
> >> class(V)
> > [1] "character"
> >
> > I would like to change it to a list:
> >> L=as.list(V)
> >> L
> > [[1]]
> > [1] "Fred"
> > [[2]]
> > [1] "Mary"
> > [[3]]
> > [1] "SAM"
> >
> > but I need to name the components as name1, name2, name3,
> > so it should look like this:
> > $name1
> > [1] "Fred"
> > $name2
> > [1] "Mary"
> > $name3
> > [1] "SAM"
> >
> > Any help will be much appreciated
> > Joseph
> >
> >
> >
> > [[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.
> >
> >
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess_at_gmail.com
>
> ______________________________________________
> 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.
>

        [[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. Received on Sun 25 May 2008 - 21:35:40 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 26 May 2008 - 01:30:43 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