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

    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

    #Measure of Central tendency

    #Read File
    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][/vc_row_inner]
    Leave Comment

    Your email address will not be published. Required fields are marked *

    clear formSubmit