Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
686 B
1
Indexable
Never
at <- iris
head(dat)
str(dat)

min(dat$Sepal.Length)
max(dat$Sepal.Length)
rng <- range(dat$Sepal.Length)
rng
rng[1] #min
rng[2] #max

max(dat$Sepal.Length) - min(dat$Sepal.Length)
range2 <- function(x){
  range = max(x) - min(x)
  return(range)
}
range2(dat$Sepal.Length)

mean(dat$Sepal.Length)
median(dat$Sepal.Length)
quantile(dat$Sepal.Length, 0.5)
quantile(dat$Sepal.Length, 0.25)
quantile(dat$Sepal.Length, 0.75)
quantile(dat$Sepal.Length, 0.4)
quantile(dat$Sepal.Length, 0.98)

IQR(dat$Sepal.Length)
quantile(dat$Sepal.Length, 0.75) - quantile(dat$Sepal.Length, 0.25)

sd(dat$Sepal.Length)
var(dat$Sepal.Length)
lapply(dat[, 1:4],sd)

summary(dat)

by(dat, dat$Species, summary)