mean(x, ...) ## Default S3 method: mean(x, na.rm = FALSE) ## S3 method for class 'Date': mean(x, ...) ## S3 method for class 'POSIXct': mean(x, ...) ## S3 method for class 'POSIXlt': mean(x, ...) ## S3 method for class 'difftime': mean(x, ..., na.rm = FALSE) ## S3 method for class 'data.frame': mean(x, na.rm = FALSE)
x | a numeric object. Missing values (NA) are allowed. |
... | additional arguments passed to mean, such as trim and na.rm. |
mean | returns the (trimmed) mean of x. |
mean.Date | returns a Date object representing the mean of x. |
mean.POSIXlt | returns a POSIXlt object representing the mean of x. |
mean.POSIXct | returns a POSIXct object representing the mean of x. |
mean.difftime | returns a difftime object representing the mean of x. |
mean.data.frame | returns a numeric NA, with a warning that you should use sapply(x,mean) or colMeans(x) |
testscores <- data.frame(oct=sample(30:100, 25), nov=sample(30:100, 25), dec=sample(30:100,25)) algebra <- testscores[,3] # vector of 25 algebra testscores mean(algebra) # Computes the average mean(algebra, trim=0.1) # Computes the 10% trimmed mean of scores# vector of the means of the columns of scores apply(testscores, 2, mean)
## date-time objects mean(Sys.Date() + 1:5) mean(Sys.time() + 1:5) mean(as.POSIXlt(Sys.time() + 1:5)) mean(Sys.time() - as.POSIXct(Sys.Date()) + 1:5)