Basic statistics in R for busy aspiring data scientists

Source: Deep Learning on Medium

Basic statistics in R for busy aspiring data scientists

( Learning basic statistics does not hurt and will help you to become a better developer in future)

It is very important that we learn statistics before applying any machine learning techniques. Here are some commands to keep in mind while you are trying to get some statistical inference from your data. The data we are going to use comes pre-installed in R. It is called mtcars dataset. To view the structure of the dataset, we can cut the head and see it.

head(mtcars)
  1. Mean:
apply(mtcars, 2, mean)

Note: Here 2 indicates mean along column(same in below examples)

2. Median:

apply(mtcars, 2, median)

3. Standard Deviation

apply(mtcars, 2, sd)

4. Variance

apply(mtcars, 2, variance)

5. Frequency table

table(mtcars$cyl)

6. Relative Frequency table

table(mtcars$cyl)/sum(table(mtcars$cyl))

7. Quartile

quantile(mtcars$mpg, probs = c(0.05, 0.1, 0.5, 0.9, 0.95))

8. Range

range(mtcars$mpg)

9. Getting summary

summary(mtcars)

If you like this post, don’t forget to clap the post and follow me on medium and on twitter.