Member-only story

Basic statistics in R for busy aspiring data scientists

Rabin Poudyal
1 min readDec 11, 2019

( 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.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Rabin Poudyal
Rabin Poudyal

Written by Rabin Poudyal

Software Engineer, Data Science Practitioner. Say "Hi!" via email: rabinpoudyal1995@gmail.com or visit my website https://rabinpoudyal.com.np

No responses yet

Write a response