Skip to content

Aggregate or extract function ?

4 messages · Celine, Jean V Adams

#
Hi R user,

I have two dataframe with different variables and coordinates :
       X         Y sp bio3 bio5 bio6 bio13 bio14
1 -70.91667 -45.08333  0   47  194  -27    47    12
2 -86.58333  66.25000  0   16  119 -345    42     3
3 -62.58333 -17.91667  0   68  334  152   144    28
4 -68.91667 -31.25000  0   54  235  -45    25     7
5  55.58333  48.41667  0   23  319 -172    23    14
6  66.25000  37.75000  0   34  363  -18    49     0

and this one :

 X  Y LU1 LU2 LU3 LU4 LU5 LU6 LU7 LU8 LU9 LU10 LU11 LU12 LU13       LU14
LU15 LU16 LU17 LU18
1 -36.5 84   0   0   0   0   0   0   0   0   0    0    0    0    0  
0.000000    0    0    0    0
2 -36.0 84   0   0   0   0   0   0   0   0   0    0    0    0    0  
0.000000    0    0    0    0
3 -35.5 84   0   0   0   0   0   0   0   0   0    0    0    0    0 
26.085468    0    0    0    0
4 -35.0 84   0   0   0   0   0   0   0   0   0    0    0    0    0  
0.000000    0    0    0    0
5 -34.5 84   0   0   0   0   0   0   0   0   0    0    0    0    0  
5.267761    0    0    0    0
6 -34.0 84   0   0   0   0   0   0   0   0   0    0    0    0    0
105.371069    0    0    0    0

I wouldlike to add to my first dataframe the value of the LU variables at
the coordinates of the first dataframe. Of course, the coordinates are not
at the same resolution and are different, this is the problem.
 I wouldlike to decrease the resolution of the first one because the second
dataframe have a coarser resolution and obtain something like that :

       X         Y sp bio3 bio5 bio6 bio13 bio14 LU1 LU2 LU3 LU4 ...
1 -70.91667 -45.08333  0   47  194  -27    47    12 0 22.08 76.9
2 -86.58333  66.25000  0   16  119 -345    42     3 0 22.08 76.9
3 -62.58333 -17.91667  0   68  334  152   144    28 0 22.08 76.9
4 -68.91667 -31.25000  0   54  235  -45    25     7 0 22.08 76.9
5  55.58333  48.41667  0   23  319 -172    23    14 0 22.08 76.9
6  66.25000  37.75000  0   34  363  -18    49     0 0 22.08 76.9

Do someone know a function or a way to do obtain that ?

Thanks in advance for the help,
C?line


--
View this message in context: http://r.789695.n4.nabble.com/Aggregate-or-extract-function-tp4013673p4013673.html
Sent from the R help mailing list archive at Nabble.com.
#
Thanks for your help, I still have a little problem with this function
because I don't have the same number of line in my two datarame so when I
try to apply the dataframe function, I obtain this response ; that I have a
different number of lines.

Erreur dans data.frame(train, test[rowz, ]) : 
  les arguments impliquent des nombres de lignes diff?rents : 50327, 66592
Do you know how I could solve this problem ?

Thanks,

C?line


--
View this message in context: http://r.789695.n4.nabble.com/Aggregate-or-extract-function-tp4013673p4015263.html
Sent from the R help mailing list archive at Nabble.com.