Skip to content
Prev 302933 / 398503 Next

indexing in data frames

Other way:

b<-c(1988,1989,1990,1991,1992)
c=list(c(1985,1982,1984),c(1988,1980),c(1983,1984),c(1988,1998,1993),c(1993,1994,1998))
?a<-data.frame(b,c1=cbind(c))
a
???? b??????????????? c
1 1988 1985, 1982, 1984
2 1989?????? 1988, 1980
3 1990?????? 1983, 1984
4 1991 1988, 1998, 1993
5 1992 1993, 1994, 1998
A.K.
On Aug 9, 2012, at 2:43 PM, David L Carlson wrote:

            
Not true:
structure(list(b = c(1988, 1989),
? ? ? ? ? ? ?  c = list(c(1985, 1982, 1984),
? ? ? ? ? ? ? ? ? ? ? ? c(1988, 1980))), .Names = c("b", "c"))
?  a.b
1 1988
2 1989
?  a.b? ? ? ? ? ? ?  cb
1 1988 1985, 1982, 1984
2 1989? ? ?  1988, 1980
'data.frame':??? 2 obs. of? 2 variables:
$ a.b: num? 1988 1989
$ cb :List of 2
? ..$ : num? 1985 1982 1984
? ..$ : num? 1988 1980

But it seems unlikely that the OP's "a" object is a dataframe since the console eval-print loop would not display a dataframe in that manner.

At any rate with the ab dataframe:
[1] 3 6 4
[1] 1 9

The OP should note the need to use '[[' on a list-object to get commensurate classes to pass to the '-' operator.

--david.
David Winsemius, MD
Alameda, CA, USA

______________________________________________
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.