[R] averaging two tables (rows with columns)

Petr PIKAL petr.pikal at precheza.cz
Thu May 10 18:10:33 CEST 2012


Hi

as already mentioned your data can not be deciphered. Use

dput(table1) for sending usable data.

>From what you describe probably

?aggregate can be used.
But without suitable data you hardly get any advice.

Regards
Petr

> 
> 
> Hi R user,I am struggling to figure out on how I can calculate the 
average
> from the two tables in R. Any one can help me? really your help  would 
be 
> grateful- I am spending so much time to figure it out. It should not be 
so
> hard, I think. 
> I have very big data but I have created a hypothetical data for 
simplification. 
> for example 
> I have : table 1
> 
> 
> 
> 
> table 1: species occurance data
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> speciesX
> 
> 
> speciesY
> 
> 
> speciesZ
> 
> 
> speciesXX
> 
> 
> 
> 
> Plot1
> 
> 
> 1
> 
> 
> 0
> 
> 
> 1
> 
> 
> 0
> 
> 
> 
> 
> Plot2
> 
> 
> 0
> 
> 
> 1
> 
> 
> 1
> 
> 
> 0
> 
> 
> 
> 
> Plot3
> 
> 
> 0
> 
> 
> 0
> 
> 
> 0
> 
> 
> 1
> 
> 
> 
> 
> Plot4
> 
> 
> 1
> 
> 
> 0
> 
> 
> 1
> 
> 
> 0
> 
> 
> 
> 
> Table 2
> 
> 
> 
> table 2. species tolerance data 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> EnviA
> 
> 
> EnviB
> 
> 
> EnviC
> 
> 
> 
> 
> speciesX
> 
> 
> 0.21
> 
> 
> 0.4
> 
> 
> 0.17
> 
> 
> 
> 
> speciesY
> 
> 
> 0.1
> 
> 
> 0.15
> 
> 
> 0.18
> 
> 
> 
> 
> speciesXX
> 
> 
> 0.14
> 
> 
> 0.16
> 
> 
> 0.19
> 
> 
> 
> You may noticed that table 2 does not have species Z which was in table 
1.
> 
> 
> Now I want to get the average value of species tolerance in each plot 
> based on each environmental value (EnviA or EnviB etc)The example of the 

> out come (final table I was looking for it) Results table 1a: average 
> species tolerance in each plot based on EnviA
> 
> 
> 
> 
> Result Table 3. Average species tolerance in each plot based on EnviA
> 
> 
> 
> 
> 
> 
> 
> 
> speciesX
> 
> 
> speciesY
> 
> 
> speciesZ
> 
> 
> speciesXX
> 
> 
> Average
> 
> 
> 
> 
> Plot1
> 
> 
> 0.21
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> 0.14
> 
> 
> 0.175
> 
> 
> 
> 
> Plot2
> 
> 
> NA
> 
> 
> 0.1
> 
> 
> Nodata
> 
> 
> NA
> 
> 
> 0.1
> 
> 
> 
> 
> Plot3
> 
> 
> NA
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> 0.14
> 
> 
> 0.14
> 
> 
> 
> 
> Plot4
> 
> 
> 0.21
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> NA
> 
> 
> 0.21
> 
> 
> 
> 
> Result table 1b: average species tolerance in plot based on EnviB
> 
> 
> 
> Table 4. Average species tolerance in each plot based on EnviB
> 
> 
> 
> 
> 
> 
> 
> 
> speciesX
> 
> 
> speciesY
> 
> 
> speciesZ
> 
> 
> speciesXX
> 
> 
> Average
> 
> 
> 
> 
> Plot1
> 
> 
> 0.4
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> 0.16
> 
> 
> 0.28
> 
> 
> 
> 
> Plot2
> 
> 
> NA
> 
> 
> 0.15
> 
> 
> Nodata
> 
> 
> NA
> 
> 
> 0.15
> 
> 
> 
> 
> Plot3
> 
> 
> NA
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> 0.16
> 
> 
> 0.16
> 
> 
> 
> 
> Plot4
> 
> 
> 0.4
> 
> 
> NA
> 
> 
> Nodata
> 
> 
> NA
> 
> 
> 0.4
> 
> 
> 
> 
> Would any one help me how I can calculate these?Thanks
> Kristi Golver======
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list