[R] Accessing members
David Winsemius
dwinsemius at comcast.net
Tue Dec 29 02:55:13 CET 2009
On Dec 28, 2009, at 5:14 PM, Nick Torenvliet wrote:
> Consider the following....
>
>> fileLines
> V1 V2 V3 V4 V5 V6 V7 V8
> 1 AB 20091224 156.0 156.0 154.00 154.00 55 1198
> 2 AB.C 20091224 156.0 156.0 156.00 156.00 0 0
> 3 ABF10 20091224 156.0 156.0 156.00 156.00 55 444
.
.
>
>> attributes (fileLines)
> $names
> [1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"
>
> $class
> [1] "data.frame"
>
> $row.names
> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
> 22 23 24
> 25
> [26] 26 27 28 29
>
>> fileLines[1,2]
> [1] 20091224
> As expected!
>
>> fileLines[1,3]
> [1] 156
> As expected!
>
>> fileLines[1,1]
> [1] AB
> 29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10
> ABN11 ... WW
> Doh!
>
> How do I access the "AB" element directly?
You already did access that element directly. You were given a bit
more information than you expected but the value of fileLines[1,1] is
"AB" and you were also advised that such value was one of 29 possible
values for the particular factor set of which it is a member.
--
David
>
> Nick
>
> [[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