• #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
• pro@slogix.in
• +91- 81240 01111

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

#### Measures of central tendency

• Mean
• Median
• Mode
• 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
###### Sapmle Code

#Measure of Central tendency

print(getwd())
setwd(“/home/soft13”)
print(getwd())
print(data)
print(is.data.frame(data))

#Mean

mean(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)