Re: [R] Selecting data from list object

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 07 Apr 2011 02:18:38 -0400

Hi Santosh,

One way would be

> sapply(d, "[", 1)

[1] "20110405" "20110405" "20110405" "20110405" "20110405" "20110405"

HTH,
Jorge

On Thu, Apr 7, 2011 at 2:14 AM, santosh <> wrote:

> Hello Group,
>
> Is there a simpler way to get data out of a list object? (like in data
> frame without using the apply functions)
>
> I have the following dataset
>
> > dput(d)
> list(c("20110405", "092102"), c("20110405", "092538"), c("20110405",
> "093458"), c("20110405", "101124"), c("20110405", "102041"),
> c("20110405", "103659"))
>
> I extracted my data like this:
>
> getDate <- function(x)(unlist(x[[1]]))
>
> unlist(lapply(d, getDate))
> [1] "20110405" "20110405" "20110405" "20110405" "20110405" "20110405"
>
> Isn't there an easier way to do this?
>
> Thanks,
> Santosh
>
> ______________________________________________
> 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 Thu 07 Apr 2011 - 06:21:27 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 Thu 07 Apr 2011 - 06:40:28 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