Untitled
unknown
plain_text
2 years ago
803 B
5
Indexable
#computing the arithmetic and geometric mean, median, mode, and sd for feature A.
#Deal with any missing values as well/
arith_meanA<-mean(my_data$Global_active_power, na.rm = TRUE)
#compute geometric mean for feature A.
geo_meanA<-exp(mean(log(my_data$Global_active_power), na.rm = TRUE))
#compute median for feature A.
medianA<-median(my_data$Global_active_power, na.rm = TRUE)
#compute mode for feature A.
mode<-function(x){
unix <-unique(x)
unix[which.max(tabulate(match(x,unix)))]
}
modeA<-mode(my_data$Global_active_power)
#standard deviation computation
sdA<-sd(my_data$Global_active_power, na.rm = TRUE)
print(paste("Computations for feature A: ", "Arithmetic Mean:", arith_meanA,
"Geometric Mean:", geo_meanA, "Median:", medianA, "Mode:", modeA, "Standard Deviation:", sdA))Editor is loading...