[R] averaging two tables (rows with columns)

John Kane jrkrideau at inbox.com
Thu May 10 18:01:11 CEST 2012


Kristi,
Your data has come through in a totally unreadable layout.

Have a look at ?dput as a handy way to present sample data.  Just run dput(mydata), copy the output and paste into the email.  

John Kane
Kingston ON Canada


> -----Original Message-----
> From: kristi.glover at hotmail.com
> Sent: Thu, 10 May 2012 12:50:43 -0300
> To: r-help at r-project.org
> Subject: [R] averaging two tables (rows with columns)
> 
> 
> 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list