Reputation: 1
I hope this is not a dumb question, but I'd like to know if there are builtin function in R to manipulate data of which I have already the frequencies. I mean, let's say that I have some values and their frequencies, and I will arrange them in a 2-dimesnional array, are there function or libraries to calculate their statistics (like mean, std. deviation and so) or do I have to make my functions? I tried to search on Google but I found only the functions to get the frequencies from the unitary data. I hope I was clear enough...
Upvotes: 0
Views: 66
Reputation: 8880
try using library(expss)
там вы можете вычислить различную взвешенную статистику w_...
for your example
myMatrix <- matrix(c(1,2,3,4,3,1,2,1), nrow=4, ncol=2)
colnames(myMatrix) <- c("values","frequencies")
myMatrix <- as.data.frame(myMatrix)
with(myMatrix, expss::w_mean(x = values, weight = frequencies))
[1] 2.142857
> 15/7
[1] 2.142857
Upvotes: 1