any can please tell me how to remove 10%,15%,25% and 50% of the data randomly by using R programme??? can anyone please show me the coding? do i need to install any package? -- View this message in context: http://r.789695.n4.nabble.com/HELP-how-to-remove-10-of-data-randomly-in-R-tp4647879.html Sent from the R help mailing list archive at Nabble.com.
HELP!! how to remove 10% of data randomly in R
3 messages · Eugenie, R. Michael Weylandt, arun
Nope, you can do it easily along the lines of dat[sample(NROW(dat), NROW(dat)*(1 - 0.1)),] But you need to spend the time understanding what all that does. Lots of important and powerful R ideas in that little bit. Michael
On Tue, Oct 30, 2012 at 3:12 PM, Eugenie <leemeanwei at hotmail.com> wrote:
any can please tell me how to remove 10%,15%,25% and 50% of the data randomly by using R programme??? can anyone please show me the coding? do i need to install any package? -- View this message in context: http://r.789695.n4.nabble.com/HELP-how-to-remove-10-of-data-randomly-in-R-tp4647879.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Hi, Try this: dat1<-read.table(text=" ? V1 V2 1 5 10 2 6? 3 3 8? 4 4 9 20 5 15 30 6 25 40 7 2? 4 8 3? 1 9 1? 5 10 8 10 ",header=TRUE) dat1[sample(1:nrow(dat1), 0.50*nrow(dat1)),] #50% of data #?? V1 V2 #4?? 9 20 #6? 25 40 #8?? 3? 1 #10? 8 10 #9?? 1? 5 dat1[-sample(1:nrow(dat1), 0.90*nrow(dat1)),] #remove 90% of data #? V1 V2 #7? 2? 4 ----- Original Message ----- From: Eugenie <leemeanwei at hotmail.com> To: r-help at r-project.org Cc: Sent: Tuesday, October 30, 2012 11:12 AM Subject: [R] HELP!! how to remove 10% of data randomly in R any can please tell me how to remove 10%,15%,25% and 50% of the data randomly by using R programme??? can anyone please show me the coding? do i need to install any package? -- View this message in context: http://r.789695.n4.nabble.com/HELP-how-to-remove-10-of-data-randomly-in-R-tp4647879.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.