[R] Understand Rcode- subset

John Kane jrkrideau at inbox.com
Mon Aug 24 17:59:56 CEST 2015


Just to second Thierry's point, your HTML post is basically unreadable.

Please repost as plain text.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: butt_its_me at hotmail.com
> Sent: Mon, 24 Aug 2015 16:30:31 +0530
> To: r-help at r-project.org
> Subject: [R] Understand Rcode- subset
> 
> Hi!
> I am facing a problem in understanding the R-Code
> Suppose I have a dataset named- transact with its values like following:
> 
> 
> 
> 
> 
>   customer_ID
>   shopping_pt
>   record_type
> 
> 
>   10000000
>   1
>   0
> 
> 
>   10000000
>   2
>   0
> 
> 
>   10000000
>   3
>   0
> 
> 
>   10000000
>   4
>   0
> 
> 
>   10000000
>   5
>   0
> 
> 
>   10000000
>   6
>   0
> 
> 
>   10000000
>   7
>   0
> 
> 
>   10000000
>   8
>   0
> 
> 
>   10000000
>   9
>   1
> 
> 
>   10000005
>   1
>   0
> 
> 
>   10000005
>   2
>   0
> 
> 
>   10000005
>   3
>   0
> 
> 
>   10000005
>   4
>   0
> 
> 
>   10000005
>   5
>   0
> 
> 
>   10000005
>   6
>   1
> 
> 
>   10000007
>   1
>   0
> 
> 
>   10000007
>   2
>   0
> 
> 
>   10000007
>   3
>   0
> 
> 
>   10000007
>   4
>   0
> 
> How does the following code work and the results of sub and id-
id<-transact$record_type==1sub<-train[c(id[2:length(id)],FALSE),]id<-c(id[3:length(id)],FALSE,FALSE)
> sub2<-train[id,]
> Thanks in advance!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.



More information about the R-help mailing list