Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Average value of vector

Tags:

r

average

I'm playing around with R and trying to get the average of a column. Just mean(V1) doesn't work.

enter image description here

Could anybody give me an advice?
Thank you!

like image 882
Evgenij Reznik Avatar asked Oct 31 '13 02:10

Evgenij Reznik


People also ask

How do you find the average value of a vector in R?

The mean() is a built-in R function that takes an input vector as an argument and returns the mean of the vector elements. The mean is calculated by taking a sum of the values and dividing by the number of values in the data.

How do you find the average of a vector?

Average is the sum divided by n, the number of elements in the vector.

How do you calculate average R value?

You can get an average R-value of a mixed surface by multiplying their respective U-value by the percentage of their area, then sum them. U-value is the inverse of R-value. A material with R-value of 10 has a U-value of 1/10 = 0.1.

What is the average function in R?

Average in R Programming To compute the average of values, R provides a pre-defined function mean(). This function takes a Numerical Vector as an argument and results in the average/mean of that Vector.


1 Answers

A: mean(D$V1) ... column names are not first class objects. They are part of a data.frame with a name that needs to be used.

Q: es, thanks. So $ is like the dot-operator? – user1170330 4 mins ago

A: Perhaps (depending on which language is being compared.) it is possible to construct list objects with cascaded calls to $<- and then obj$V1$subV1 to extract. Review ?Extract very carefully.

like image 53
IRTFM Avatar answered Oct 10 '22 00:10

IRTFM