aggregate data.frame

2 messages Options
Embed this post
Permalink
Alfredo Alessandrini

aggregate data.frame

Reply Threaded More More options
Print post
Permalink
Hi,

I've two data.frame: ind_comp and dati_area



> ind_comp
   INDEX    indice
1      1 0.3081856
2      2 0.1368007
3      3 0.1290952
4      4 0.2905484
5      5 0.2686706
6      6 0.1122784
7      7 0.4493264
8      8 0.1932665
9      9 0.1982783
10    11 0.3724666

> dati_area
       X_COORD     Y_COORD  DBH AREA ID ind_comp
1    0.0000000   0.0000000 70.0    1  1        0
2    4.4352788  14.5071431 70.0    1  2        0
3   10.6893894  10.3226234 68.0    1  3        0
4    5.8856279   0.4115632 75.5    1  4        0
5    5.7429111  -8.5142159 78.5    1  5        0
6   -6.4300000  11.1370867 60.0    1  6        0
7    0.6358819 -12.1333488 82.4    1  7        0
8   -7.9629934 -15.6282544 60.0    1  8        0
9   -7.9962383  -7.1998453 62.0    1  9        0
10 -17.3282497   5.6302896 67.0    1 10        0
11  -3.2569414   5.0152500 77.5    1 12        0


I need to populate the column "ind_comp" of the data.frame
"dati_area", with the data "indice" of the data.frame "ind_comp".

The data "INDEX" of the data.frame "ind_comp"  must correspond to
index of the rows "dati_area".

       X_COORD     Y_COORD  DBH AREA ID  ind_comp
1    0.0000000   0.0000000 70.0    1  1 0.3081856
2    4.4352788  14.5071431 70.0    1  2 0.1368007
3   10.6893894  10.3226234 68.0    1  3 0.1290952
4    5.8856279   0.4115632 75.5    1  4 0.2905484
5    5.7429111  -8.5142159 78.5    1  5 0.2686706
6   -6.4300000  11.1370867 60.0    1  6 0.1122784
7    0.6358819 -12.1333488 82.4    1  7 0.4493264
8   -7.9629934 -15.6282544 60.0    1  8 0.1932665
9   -7.9962383  -7.1998453 62.0    1  9 0.1982783
10 -17.3282497   5.6302896 67.0    1 10 NA
11  -3.2569414   5.0152500 77.5    1 12 0.3724666


Thanks,

Alfredo

______________________________________________
[hidden email] 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.
Peter Alspach-2

Re: aggregate data.frame

Reply Threaded More More options
Print post
Permalink
Tena koe Alfredo

?merge

HTH ...

Peter Alspach

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Alfredo
> Alessandrini
> Sent: Tuesday, 10 November 2009 1:16 p.m.
> To: [hidden email]
> Subject: [R] aggregate data.frame
>
> Hi,
>
> I've two data.frame: ind_comp and dati_area
>
>
>
> > ind_comp
>    INDEX    indice
> 1      1 0.3081856
> 2      2 0.1368007
> 3      3 0.1290952
> 4      4 0.2905484
> 5      5 0.2686706
> 6      6 0.1122784
> 7      7 0.4493264
> 8      8 0.1932665
> 9      9 0.1982783
> 10    11 0.3724666
>
> > dati_area
>        X_COORD     Y_COORD  DBH AREA ID ind_comp
> 1    0.0000000   0.0000000 70.0    1  1        0
> 2    4.4352788  14.5071431 70.0    1  2        0
> 3   10.6893894  10.3226234 68.0    1  3        0
> 4    5.8856279   0.4115632 75.5    1  4        0
> 5    5.7429111  -8.5142159 78.5    1  5        0
> 6   -6.4300000  11.1370867 60.0    1  6        0
> 7    0.6358819 -12.1333488 82.4    1  7        0
> 8   -7.9629934 -15.6282544 60.0    1  8        0
> 9   -7.9962383  -7.1998453 62.0    1  9        0
> 10 -17.3282497   5.6302896 67.0    1 10        0
> 11  -3.2569414   5.0152500 77.5    1 12        0
>
>
> I need to populate the column "ind_comp" of the data.frame
> "dati_area", with the data "indice" of the data.frame "ind_comp".
>
> The data "INDEX" of the data.frame "ind_comp"  must
> correspond to index of the rows "dati_area".
>
>        X_COORD     Y_COORD  DBH AREA ID  ind_comp
> 1    0.0000000   0.0000000 70.0    1  1 0.3081856
> 2    4.4352788  14.5071431 70.0    1  2 0.1368007
> 3   10.6893894  10.3226234 68.0    1  3 0.1290952
> 4    5.8856279   0.4115632 75.5    1  4 0.2905484
> 5    5.7429111  -8.5142159 78.5    1  5 0.2686706
> 6   -6.4300000  11.1370867 60.0    1  6 0.1122784
> 7    0.6358819 -12.1333488 82.4    1  7 0.4493264
> 8   -7.9629934 -15.6282544 60.0    1  8 0.1932665
> 9   -7.9962383  -7.1998453 62.0    1  9 0.1982783
> 10 -17.3282497   5.6302896 67.0    1 10 NA
> 11  -3.2569414   5.0152500 77.5    1 12 0.3724666
>
>
> Thanks,
>
> Alfredo
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.