This might be easy but I'm very new to R and this question doesn't seem to
have any nice keywords that bring up relevant search results when I search
the CRAN search engine.  Therefore, I'll plead (as I have in the recent
past) Newbie status.

 

I have a data frame with two factors (Factor 1 and 2) which together specify
another unique level.  I want to create a third factor in the data frame
that captures this uniqueness.

For example, say I had dataframe, Df, with Factors, 1 and 2.  I want to
create Factor 3 and add it to my Df dataframe.

i.e.

Df dataframe:                          WANT TO 

Row#     Factor1          Factor2     CREATE THIS: Factor 3        Data

1            1               1                    1                 23

2            1               2                    2                 43

3            1               2                    2                 19

4            1               2                    2                 11

5            1               4                    3                 3

6            1               4                    3                 13

7            3               1                    4                 52

8            3               1                    4                 12

9            3               1                    4                 9

10           3               3                    5                 21

11           3               3                    5                 43


12           4               1                    6                 32

13           4               1                    6                 18

14           4               2                    7                 52

15           4               2                    7                 21


 

and of course, I'm trying to create Factor 3 without loops..

 

My end goal here (which I add because maybe I don't need to create Factor 3
(although I'm still curious)), is to bootstrap "sample" Factor 3. I want to
repeatedly grab, say, 3 levels of Factor 3, and take the mean of those
levels (e.g. say in my first bootstrap sample, I grab levels 2,4, and 7 from
Factor 3, then I want to take the mean of rows, 2,3,4,7,8,9,14,15).  Of
course, each sample from Factor 3 for my bootstrap will most likely have a
differing number of rows since my experiment is not balanced.  I'm not sure
if this is an issue yet when I try to implement the "boot" function in R (I
haven't gotten to that point yet).  

 

Any help is appreciated!

 

Thanks!

-Scott

 

Scott Norton, Ph.D.

Engineering Manager

Nanoplex Technologies, Inc.

2375 Garcia Ave.

Mountain View, CA 94043

www.nanoplextech.com <http://www.nanoplextech.com/> 

nortonsm@verizon.net

 


	[[alternative HTML version deleted]]


