Re: [R] mean calculation

2015-01-26 Thread arun
Hi Juvin, The error "dim(X) must have a positive length" usually shows when you are passing a vector to "apply", ie. apply(1:5,2,mean) #Error in apply(1:5, 2, mean) : dim(X) must have a positive length Also, if your dataset originally has "1206" columns, it is not clear why you n

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

Re: [R] Mean calculation of groups

2012-09-25 Thread Rui Barradas
Hello, Or ?tapply. ave will return a vector with the length of the input, tapply just one value per group. ave(test$Score, test$Name, FUN = mean) # 24 values tapply(test$Score, test$Name, FUN = mean) # 3 values Hope this helps, Rui Barradas Em 25-09-2012 15:54, Bert Gunter escreveu: Nic

Re: [R] Mean calculation of groups

2012-09-25 Thread Bert Gunter
Nico: 1. Thanks for the example. 2. Please read -- or at least peruse -- the tutorial, An Introduction to R (or other tutorial that you might find on the Web, there are many) to familiarize yourself with R's features. 3. This is an example of what the apply() family of functions can do, so you m

Re: [R] mean calculation within dataframe corrupted

2010-06-01 Thread Joshua Wiley
Hello, I was hunting for something else and came across your old message, and I noticed that it had never received an answer (at least on the list). I really tried to figure out what might be going on just by looking at your code, but I could not get enough information from your email and your co

[R] mean calculation within dataframe corrupted

2010-02-10 Thread Chaehan So
Dear R-helpers, my little function below calculates the group score (tmpGroupMean) of an item, appends a "_mean" on its name and stores its value on this name. However, it does not calculate the mean of these scores (LVMean) in the same row correctly, as you can see in the below output which stran