Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Addi Wei

The data set for "combined" is pretty huge, but a few columns looks like
this, so just picture it with 187 columns: 

dw_area vdw_vol   vsa_acc  vsa_acid vsa_base   vsa_donvsa_hyd
1   0.8322680  0.93714800 -0.478551 -0.2791860 -0.724420  1.4647400
2   1.8746300  1.2639  0.231489 -0.2791860 -0.724420  2.4437300
3   1.2635300  1.27511000 -0.478551 -0.2791860 -0.724420  1.8885000
4  -0.2091150  0.00245105 -0.478551 -0.2791860  0.643888 -0.1103640
5  -0.6426310 -0.77541200 -0.478551 -0.2791860 -0.724420 -0.1678760
6   0.5617160  0.75142800 -0.478551 -0.2791860  2.012200  0.4365550
7   0.3181530  0.56153700 -0.478551 -0.2791860  0.728689  0.4913130
8  -0.9256880 -0.95886100 -0.478551 -0.2791860 -0.724420 -0.4941470
9  -0.4869660 -0.32273400 -0.478551 -0.2791860  2.012200 -0.7498750
10 -0.1318450  0.41073000 -0.478551 -0.2791860 -0.724420 -0.1566290
11 -0.3376330 -0.70423700 -0.478551 -0.2791860 -0.724420  0.1211300
12  1.8514500  1.77306000  0.231489 -0.2791860 -0.724420  2.1934600
13 -1.1121400 -1.24015000 -0.478551 -0.2791860 -0.724420 -0.8079080
14 -1.0180100 -0.91463100  1.163990 -0.2791860  0.152065 -1.5639500
15  0.9840690  0.54838200  1.163990 -0.2791860 -0.724420  0.9464930
16  0.9221160  0.89172700 -0.478551 -0.2791860 -0.724420  1.0412800
17 -0.6572660 -0.91214600 -0.478551 -0.2791860 -0.724420 -0.3433890
18 -1.1652000 -1.11063000 -0.478551 -0.2791860 -0.724420 -0.7814010
19 -0.9517200 -1.11619000 -0.478551 -0.2791860 -0.724420 -0.5873950
20  1.8636100  1.50704000 -0.478551 -0.2791860 -0.724420  1.5324200
21  1.3454900  1.04233000 -0.478551 -0.2791860 -0.286177  0.7846970
22 -1.3750400 -1.39968000 -0.478551 -0.2791860 -0.724420 -0.9562210
23  0.4430730  0.63993400 -0.478551 -0.2791860  2.012200  0.2604830
24  1.7497800  1.68613000  0.231489 -0.2791860 -0.724420  1.7329500
25 -0.0373934 -0.55246500 -0.478551 -0.2791860 -0.724420  0.5856500
26 -0.2394720 -0.12850800 -0.347514 -0.2791860  0.643888 -0.1623170
27 -0.8967770 -1.06392000 -0.478551 -0.2791860 -0.724420 -0.5233780
28 -0.4451600 -0.26183600 -0.478551 -0.2791860 -0.724420 -1.0779000
29 -0.5424250 -0.49660500  2.062620  2.2030200 -0.724420 -0.8550770
30 -0.5771440 -0.85601000 -0.478551 -0.2791860 -0.724420 -0.0588589
31 -0.6260030 -0.53066600 -0.478551 -0.2791860 -0.724420 -0.1375320
32  1.0570400  1.30541000  0.941530 -0.2791860  0.643888  0.7244410
33  0.2571910  0.75395500  0.941530 -0.2791860  0.643888 -0.2198800
34  0.9883210  0.94507000  2.189390  2.6537100  0.643888  0.0258676
35  1.7612300  1.95718000 -0.478551 -0.2791860 -0.724420  2.3069400
36 -0.2426960 -0.25155900 -0.478551 -0.2791860  2.012200 -0.4236040
37 -0.0908961 -0.13352200 -0.347514 -0.2791860  0.643888 -0.4903390
38 -1.1075600 -0.92771700 -0.216477 -0.2791860 -0.724420 -0.8159470
39  2.4950200  2.38145000  3.900680  1.7057800 -0.101657  1.0432800
40 -0.0593010 -0.10824900  0.941530  1.7057800  0.643888 -0.4941250
41 -1.3516500 -1.39192000 -0.478551 -0.2791860 -0.724420 -1.2724300
42  1.2363300  1.38493000  0.231489 -0.2791860  0.643888  1.0500900
43 -0.3339520 -0.67890300  3.792660  5.6910400  2.012200 -2.2014700
44 -1.3119500 -1.02913000 -0.347514 -0.2791860 -0.724420 -1.0122300
45 -0.1282990  0.15140400 -0.478551 -0.2791860 -0.724420  0.2809100
46 -1.3564000 -1.31133000 -0.478551 -0.2791860 -0.724420 -0.9906220
47 -0.6378720 -0.85601000 -0.478551 -0.2791860 -0.724420 -0.3433890
48 -0.8773830 -1.00778000 -0.478551 -0.2791860 -0.724420 -0.5233780
49  0.8775800  1.15662000  0.941530 -0.2791860  0.152065  0.3502700
50 -0.2114330  0.12992100 -0.478551 -0.2791860  2.012200 -0.4322770
51 -0.4391080 -0.31051500 -0.478551 -0.2791860  0.643888 -0.3195850
52 -0.2952910 -0.23493200 -0.478551 -0.2791860  0.643888 -0.6866230
53 -0.8967770 -1.06392000 -0.478551 -0.2791860 -0.724420 -0.5233780
54 -0.4822070 -0.40333200 -0.478551 -0.2791860  2.012200 -0.7108580
55 -0.4822070 -0.40333200 -0.478551 -0.2791860  2.012200 -0.7108580

miceSample may be just the last 2 columns (or whatever sample R comes up
with) vsa_donvsa_hyd or looking at my code from my original post, it's
"nvars"

It looks like that code did it perfectly. Thanks.  



-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-delete-a-date-frame-from-a-data-frame-tp2290577p2290646.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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 comment

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Erik Iverson
It's high time for a small, reproducible example.  Don't say, "for 
example", *give* us an example in R.


That being said, something like

combined[!names(combined) %in% names(miceSample)]

might be a start...

Addi Wei wrote:

But "miceSample" has multiple columns...  For example if nvars=4, I have 4
columns of data to delete from "combined".

Specifically, I have 187 columns in "combined", and "miceSample" only has 4
columns.   So the new data frame should have 183 columns.


__
R-help@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.


Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Addi Wei

But "miceSample" has multiple columns...  For example if nvars=4, I have 4
columns of data to delete from "combined".

Specifically, I have 187 columns in "combined", and "miceSample" only has 4
columns.   So the new data frame should have 183 columns.  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-delete-a-date-frame-from-a-data-frame-tp2290577p2290605.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 2:37 PM, Addi Wei wrote:

> 
> e.g. I have a big data set called "combined", and then a small sample of
> "combined" called "miceSample".  I wish to delete "miceSample" from
> "combined" to create a new smaller data set and store it into a new object. 
> 
> combined <- rbind(scaleMiceTrain, scaleMiceTest)
> miceSample <- sample(combined[,-c(1,2)],nvars, replace=FALSE)
> 
> How do I do that?  

See ?subset

If you have a column in your data frame, say called 'Group', that contains an 
indicator as to which group each record belongs to:

  subset(combined, Group != "miceSample")

will return a new data frame without the records where the Group column 
contains 'miceSample'.

HTH,

Marc Schwartz

__
R-help@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.