[R] Behavior of [[ in S vs. R
Thomas Lumley
tlumley at u.washington.edu
Fri Oct 17 23:03:03 CEST 2003
On Fri, 17 Oct 2003, Backlund, Jan Erik (JE) wrote:
> I am confused by the following difference in the behavior of R and S. Any
> clarification would be greatly appreciated.
sw[[2,1]] in R is short for sw[[2]][[1]], which in the case of a data
frame is sw[1,2], as your example shows.
-thomas
> Jan Erik Backlund
> Dow AgroSciences, LLC.
> jebacklund at dow.com
>
>
> R : Copyright 2003, The R Development Core Team
> Version 1.8.0 (2003-10-08)
> > sw
> Fertility Agriculture Examination Education Catholic
> Courtelary 80.2 17.0 15 12 9.96
> Delemont 83.1 45.1 6 9 84.84
> Franches-Mnt 92.5 39.7 5 5 93.40
> Moutier 85.8 36.5 12 7 33.77
> Neuveville 76.9 43.5 17 15 5.16
> > sw[2,1]
> [1] 83.1
> > sw[[2,1]]
> [1] 17
> >
>
> and the corresponding behaviour in S
> S-PLUS : Copyright (c) 1988, 2001 Insightful Corp.
> S : Copyright Lucent Technologies, Inc.
> Professional Edition Version 6.0.3 Release 2 for Microsoft Windows : 2001
> > sw
> Fertility Agriculture Examination Education Catholic
> Courtelary 80.2 17.0 15 12 9.96
> Delemont 83.1 45.1 6 9 84.84
> Franches-Mnt 92.5 39.7 5 5 93.40
> Moutier 85.8 36.5 12 7 33.77
> Neuveville 76.9 43.5 17 15 5.16
> > sw[2,1]
> [1] 83.1
> > sw[[2,1]]
> [1] 83.1
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list