Before doing any computation, first of all, we need to prepare our data, save our data in an external .txt or .csv files and it’s a best practice to save the file in the current directory. After that import, your data into R as follow:
Get the csv file here.
Product Age Gender Education MaritalStatus Usage Fitness Income Miles 1 TM195 18 Male 14 Single 3 4 29562 112 2 TM195 19 Male 15 Single 2 3 31836 75 3 TM195 19 Female 14 Partnered 4 3 30699 66 4 TM195 19 Male 12 Single 3 3 32973 85 5 TM195 20 Male 13 Partnered 4 2 35247 47 6 TM195 20 Female 14 Partnered 3 3 32973 66
Functions for computing mean, median and mode:
It is the sum of observation divided by the total number of observations. It is also defined as average which is the sum divided by count.
where, n = number of terms
It is the middle value of the data set. It splits the data into two halves. If the number of elements in the data set is odd then the center element is median and if it is even then the median would be the average of two central elements.
where, n = number of terms
It is the value that has the highest frequency in the given data set. The data set may have no mode if the frequency of all data points is the same. Also, we can have more than one mode if we encounter two or more data points having the same frequency.
- Coercing an Object of mode "list" to mode "call" in R Programming - as.call() Function
- Calculate Median of elements of a Vector in R Programming - median() Function
- Calculate Arithmetic mean in R Programming - mean() Function
- Calculate the Weighted Mean in R Programming - weighted.mean() Function
- What is the difference between MEAN.js and MEAN.io?
- Create an Object of mode call in R Programming - call() Function
- Get or Set the Type of an Object in R Programming - mode() Function
- Calculate the Median Absolute Deviation in R Programming - mad() Function
- Calculate the Mean of each Column of a Matrix or Array in R Programming - colMeans() Function
- Calculate the Mean of each Row of an Object in R Programming – rowMeans() Function
- Root-Mean-Square Error in R Programming
- CSS | writing-mode Property
- CSS | background-blend-mode Property
- CSS mix-blend-mode Property
- What is SMPS(Switch Mode Power Supply)?
- What does the “+” (plus sign) CSS selector mean?
- What does '<?=' short open tag mean in PHP ?
- What does it mean to start a PHP function with an ampersand?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.