Hello All,

I have two dataframes and I wish to insert the values of one dataframe into
another (let's call them DF1 and DF2). DF1 looks like this:

col1.....col2
a...........1
b...........2
c...........3
d...........4
e...........5
f............6
g...........7

where col1 (which is just the first column of the dataframe) is a list of
characters and col2 is the numeric value associated with col1

DF2 looks like this:

col1.....col2.....col3.....col4.......col5
a...........b.........NA.......NA
a...........c.........NA.......NA
a...........d.........NA.......NA
b...........c.........NA.......NA
b...........d........NA........NA
b...........e.........NA.......NA
c..........d..........NA......NA
c...........e..........NA......NA
c...........f..........NA........NA

Basically, DF2 is every possible combination of of DF1. col5 is also full of
NA's

I want to create a simple mathematical model utilizing the values in
DF1$col2 to see the outcomes of every possible combination of objects in
DF1$col1
The first step I wanted to do is to transfer values from DF1$col2 to
DF2$col3 (values from DF2$col3 should be associated to values in DF2col1),
but that's where I'm stuck. I currently have:


for(j in 1:length(DF2$col1))
{
# this part is to use the characters in DF2$col1 as an input to yield the
output for DF2$col3
  input=c(DF2$col1)[j]

  # This is supposed to use the values found in DF1$col2 to fill in DF2$col3
  g=DF1[(DF1$col2==input),"pred"]

 # This is so that the values will fill in DF2$col3
  DF2$col3=g
}

When I run this, DF2$col3 will be filled up with the same value for a
specific character from DF1(e.g. DF2$col3 will have all the rows filled with
the value associated with character "a" from DF1)
What exactly am I doing wrong?

Thanks a bunch for your time

-- 
Best,
Dat Mai
PhD Rotation Student
Albert Einstein College of Medicine

	[[alternative HTML version deleted]]

