[19119] in s-news-athena
[S] Subscripting problem?
daemon@ATHENA.MIT.EDU (Molinari, Luciano)
Mon Sep 6 11:33:27 1999
Message-Id: <136E7D899707D311A8290008C7BF17A40A6D81@obelix>
From: "Molinari, Luciano" <Luciano.Molinari@kispi.unizh.ch>
To: S-news@wubios.wustl.edu
Date: Mon, 6 Sep 1999 17:25:11 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
I have a data frame zz1, created as a result of a function. Can somebody
give me a hint about what is going on below?
------------------------
S+>is.data.frame(zz1)
[1] T
S+>names(zz1)
[1] "Y" "Sex" "ST"
S+>str(zz1$Y)
Array[1:154, 1:7] 3.73 3.50 6.74 3.49 9.18 ...
- attr(*, "dimnames")=List of 2
.. $ : chr [1..154] '128' '282' '266' '315' '154' '341' '151' '329' ...
.. $ : chr [1..7] 'X7' 'X8' 'X9' 'X10' 'X11' 'X12' 'X13'
- attr(*, "class")= chr [1..2] 'AsIs' 'matrix'
S+>zz1$Y[1:5,1:2]
X7 X8
128 3.731426 3.707044
282 3.499947 4.334718
266 6.737345 7.933120
315 3.486426 3.890204
154 9.176022 11.529168
################################################### What is wrong here?
S+>zz1$Y[1:5,1]
Error in 1:d[1]: No data to interpret as numerical value
Dumped
----------------
Does this possibly have anything to do with the class attribute of zz1$Y?
In fact it does!
----------
S+>class(zz1$Y)
[1] "AsIs" "matrix"
S+>class(zz1$Y) _ NULL
S+>zz1$Y[1:5,1]
128 282 266 315 154
3.731426 3.499947 6.737345 3.486426 9.176022
S+>class(zz1$Y) _ "matrix"
S+>zz1$Y[1:5,1]
128 282 266 315 154
3.731426 3.499947 6.737345 3.486426 9.176022
S+>class(zz1$Y) _ "AsIs"
S+>zz1$Y[1:5,1]
128 282 266 315 154
3.731426 3.499947 6.737345 3.486426 9.176022
attr(, "class"):
character(0)
S+>class(zz1$Y)_c("AsIs","matrix")
S+>zz1$Y[1:5,1]
Error in 1:d[1]: No data to interpret as numerical value
Dumped
-------------
But why?
More generally: how can one, in these cases, obtain a deeper insight into
the structure of an object?
Thanks for paying attention to this.
Luciano Molinari
Abt. EEG und AWE
Kinderspital Zürich
Steinwiesstr.75
CH-8032 Zürich
molinari@kispi.unizh.ch
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news