How to measure the central tendency of the given data using R?

Description

To measure the central tendency of the given data in R programming.

• Mean
• Median
• Mode

1) 1) Mean:

• Mean is the average of the data set.
• It is applicable only to numerical values.
• R Function : mean():

2) Median:

• Median the center value of the data set.
• It is applicable only to numerical value.
• R Function : median()

3) Mode:

• Mode is the highest occurrences value.
• It is applicable to both numerical and character type
• No inbuilt function to find mode value in R

Sample Code

#Measure of Central tendency

print(getwd())
setwd(“/home/soft13″)
print(getwd())
data <- read.csv('input.csv') print(data) print(is.data.frame(data))#Meanmean(data\$salary)#Median median(data\$salary)#Mode mode <- function(f){ uniq <- unique(f) uniq[which.max(tabulate(match(f,uniq)))] } mode(data\$salary) mode(data\$dept)#Summary summary(data)[/vc_column_text][/vc_tta_section][vc_tta_section title="Screenshots" tab_id="Screenshots"][vc_single_image image="76653" img_size="full"][vc_single_image image="76652" img_size="full"][vc_empty_space height="15px"][/vc_tta_section][/vc_tta_tabs][/vc_column][/vc_row][vc_row][vc_column][vc_empty_space][vc_row_inner][vc_column_inner width="1/3"][vc_column_text]

Previous Sample
[/vc_column_inner]
Next Sample
[/vc_row_inner]
List of Final Year Hadoop Projects
Leave Comment