[R] (no subject)
David Winsemius
dwinsemius at comcast.net
Mon Aug 20 02:59:40 CEST 2012
On Aug 19, 2012, at 5:14 PM, Dikán Szabolcs András wrote:
> Dear R Users! I'm new in R! I've got a data.frame. For
> example:a<-data.frame(cbind( 0:1, 1:10)) X1 X2
> 1 0 1
> 2 1 2
> 3 0 3
> 4 1 4
> 5 0 5
> 6 1 6
> 7 0 7
> 8 1 8
> 9 0 9
> 10 1 10 Firstly i want to create combinations from X2, for
> example:combn(a$X2,2) It's ok,
> but secondly
> I would like to get combinations from those X2 numbers only , where
> X1= 0. Could you help me? Thanks!
> combn( a[a$X1==0, "X2"] ,2)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 1 1 1 3 3 3 5 5 7
[2,] 3 5 7 9 5 7 9 7 9 9
>
> [[alternative HTML version deleted]]
Please learn to post with a meaningful subject line and in plain text.
The most excellent Posting Guide is a font of wisdom in other areas as
well. As is the "Introduction to R" which should be studied in its
entirety but for this case the section: "2.7 Index vectors; selecting
and modifying subsets of a data set".
Afore-mentioned posting guide: http://www.R-project.org/posting-guide.html
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list