data(mtcars)
#mtcars
mtcars$Model = rownames(mtcars)
rownames(mtcars) = NULL
mtcars$Brand = sapply(strsplit(mtcars$Model," "), FUN='[',n=1)
hp_brands = aggregate(
mtcars$hp,
by = list(mtcars$Brand),
FUN = mean
)
hp_brands
names(hp_brands) = c('Brands','Mean_hp')
#hp_brands
# to sort the data we use order function
# sorted data in ascending order
#hp_brands[order(hp_brands$Mean_hp),]
# sorted data in descending order
#hp_brands[order(-hp_brands$Mean_hp),]
#mtcars$Model= NULL
#mtcars[order(mtcars$hp),]
To embed this project on your website, copy the following code and paste it into your website's HTML: