Wednesday, 26 August 2020

Calculate Mean,Median,Mode and standard deviation(SD) in R

 MIN(): returns minimum value 

MAX(): returns maximum value 

MEAN():It is calculated by taking the sum of the values and dividing with the number of values in a data series. 

MODE():R does not have a standard in-built function to calculate mode. So we create a user function to calculate mode of a data set in R. This function takes the vector as input and gives the mode value as output.

 MEDIAN()Arrange your numbers in numerical order. Count how many numbers you have. If you have an odd number, divide by 2 and round up to get the position of the median number. If you have an even number, divide by 2. Go to the number in that position and average it with the number in the next higher position to get the median. 

SD(): sd stands for standard deviation.The standard deviation of an observation variable is the square root of its variance.. SD is calculated as the square root of the variance (the average squared deviation from the mean). ... If a variable y is a linear (y = a + bx) transformation of x then the variance of y is b² times the variance of x and the standard deviation of y is b times the variance of x. 

RANGE():min and max value range returns a vector containing the minimum and maximum of all the given arguments. 

Example: lp.csv 

Name  Age  Marks 

surya  29     98 

sivi   10      23 

somu  24    99

bapu  26    80

jack  47     89 

jone  34     79

solution: 

data1<-read.csv("lp.csv)

min(data1$Marks)

max(data1$Marks)

mean(data1$Marks)

median(data1$Marks)

var(data1$Marks)

sd(data1$Marks)

range(data1$Marks)

1 comment:

  1. You don't realize how quickly technology is changing. Data science is highly technical and is therefore in high demand. A career in data science will open up many lucrative job opportunities. So, if you have been wanting to start your career in Data Science, now is the best time to enroll in a data science program with one of the best data science training institute in noida.

    ReplyDelete

Global Infrastructure and its components in AWS

You may operate your workloads wherever and however you choose with the AWS Global Infrastructure, and you'll use the same network, cont...