[R] How to access data structure (List of List)

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Mon, 23 Jun 2008 16:28:09 +0900


Hi,

I have this kind of output.

> str(nw)
List of 3
 $ :List of 2
..$ part1: num 30.9
..$ part2: num [1:78] 60.1 70.0 73.0 75.0 83.9 ...
 $ :List of 2
..$ part1: num [1:2] 30.9 60.1
..$ part2: num [1:77] 70.0 73.0 75.0 83.9 93.1 ...
 $ :List of 2
..$ part1: num [1:3] 30.9 60.1 70
..$ part2: num [1:76] 73.0 75.0 83.9 93.1 97.6 ...

My question are:

  1. What kind of data structure is it? List of List?
  2. How can I access it's element?

I tried the following loop but seem to fail

for (i in 1:length(nw)) {

    print(nw[i]$part1)
}

Please advice.
- Gundala Viswanath
Jakarta - Indonesia



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 Mon 23 Jun 2008 - 07:33:48 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 23 Jun 2008 - 08:31:01 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