Re: [R] Mean calculation by two variables

2013-01-17 Thread arun
igues To: Rui Barradas Cc: r-help@r-project.org Sent: Wednesday, January 16, 2013 11:23 PM Subject: Re: [R] Mean calculation by two variables Hello Rui! Thanks a lot for your help! Sorry for make mistake with the factor's name, was inattention during data preparation for the asking

Re: [R] Mean calculation by two variables

2013-01-16 Thread Raoni Rodrigues
Hello Rui! Thanks a lot for your help! Sorry for make mistake with the factor's name, was inattention during data preparation for the asking mail. Unfortunately, it not simple mean calculation, because same individual could have more than one row, if it eat more than a food item. In example data

Re: [R] Mean calculation by two variables

2013-01-16 Thread Rui Barradas
Hello, If you want to calculate the mean weight by Specie and Food.item, you can use ?aggregate. In what follows, I've named your EXAMPLE ex and your SOLUTION sol. Note that the result is different from sol. (No exemplo não há Peixe, é Fish, e os números são outros.) aggregate(Weight ~ Specie +

[R] Mean calculation by two variables

2013-01-16 Thread Raoni Rodrigues
Hello All, I have a data frame (dput information below) with food item weight for fish species. I need to calculate the Mean proportion by weight of each food item for each specie, as show in solution data frame (dput information below). I use the ddply function (plyr package) in two steps. Firs