Nserk
Nserk

Reputation: 1

How to manipulate data in R of which I have already their frequencies

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

Answers (1)

Yuriy Saraykin
Yuriy Saraykin

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

Related Questions