[R] Splitting a data column randomly into 3 groups
Avi Gross
@v|gro@@ @end|ng |rom ver|zon@net
Fri Sep 3 03:42:06 CEST 2021
What is stopping you Abou?
Some of us here start wondering if we have better things to do than homework for others. Help is supposed to be after they try and encounter issues that we may help with.
So think about your problem. You supplied data in a file that is NOT in CSV format but is in Tab separated format.
You need to get it in to your program and store it in something. It looks like you have 204 items so 1/3 of those would be exactly 68.
So if your data is in an object like a vector or data.frame, you want to choose random number between 1 and 204. How do you do that? You need 1/3 of the length of the object items, in your case 68.
Now extract the items with those indices into say A1. Extract all the rest into a temporary item.
Make another 68 random indices, with no overlap, and copy those items into A2 and the ones that do not have those into A3 and you are sort of done, other than some cleanup or whatever.
There are many ways to do the above and I am sure packages too.
But since you have made no visible effort, I personally am not going to pick anything in particular.
Had you shown some text and code along the lines of the above and just wanted to know how to copy just the ones that were not selected, we could easily ...
-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of AbouEl-Makarim Aboueissa
Sent: Thursday, September 2, 2021 9:30 PM
To: R mailing list <r-help using r-project.org>
Subject: [R] Splitting a data column randomly into 3 groups
Dear All:
How to split a column data *randomly* into three groups. Please see the attached data. I need to split column #2 titled "Data"
with many thanks
abou
______________________
*AbouEl-Makarim Aboueissa, PhD*
*Professor, Statistics and Data Science* *Graduate Coordinator*
*Department of Mathematics and Statistics* *University of Southern Maine*
More information about the R-help
mailing list