[R] $name vs. [["name"]]

About this list Date view Thread view Subject view Author view Attachment view

From: Kjetil Kjernsmo (kjetil.kjernsmo@astro.uio.no)
Date: Sat 17 Nov 2001 - 01:18:58 EST


Message-id: <Pine.OSF.4.30.0111161512210.130123-100000@alrami>

Dear all,

I have been away for a month, but some time ago, I noted something that
was very surprising to me. I think this example illustrates it well:
> test <- data.frame(col1 = c(1,2), col2=c(3, 4))
> test
  col1 col2
1 1 3
2 2 4
> apply(test, 1, function(x) browser())
Called from: FUN(newX[, i], ...)
Browse[1]> x$col1
NULL
Browse[1]> x[["col1"]]
[1] 1
Browse[1]> x[["col2"]]
[1] 3
Browse[1]> x$col2
NULL

it seems like the $name notation and the [["name"]] notation are
different, yet, what I understand from the intro, they should be
identical.

What's the deal?

Best,

Kjetil

-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj@astro.uio.no                                - Piet Hein
Homepage <URL:http://folk.uio.no/kjetikj/>
Webmaster@skepsis.no                            OpenPGP KeyID: 6A6A0BBC

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:09 EST