I'm struggling a bit with R and plyr, I don't know how to obtain the result I'm interested in. I have a dataframe looking like this:
Region Price
Alentejano 71
Andalucia 30
Bordeaux 135
Bordeaux 500
Bordeaux 185
And so on. I would like to get the mean for each Region, and so far I tried with plyr
and the code:
means <- ddply(data, ~ Region, summarise, mean = mean(Price), sd=sd(Price))
which succesfully gives me the standard deviation in places where I have more than one observance per variable. I do not get any means. How do I make a code that gives me a mean for multiple observances, but leaves the number if there is only one observance?