filmov
tv
How to calculate Descriptive statistics using R / R Studio
![preview_player](https://i.ytimg.com/vi/RBiV5jKS-BA/maxresdefault.jpg)
Показать описание
Find the link in description to get the R script used in this video.
At first, the packages that are necessary are psych and Desctools.
Using the Following commands will install the packages only if they are not already installed.
Type.
This will load the package.
To Load inbuilt data, type.
data("trees") .
This will loads data that is inbuilt in dataset package of R which includes Girth, Height and Volume for Black Cherry Trees.
To know the structure of the data frame, use
str(trees)
this will now show the number of observations and variables in the dataset.
Next, use
summary(trees)
this give summary of each variables in the dataset.
To know the mean of single variable in dataset use the following command format.
mean(trees$Height)
now you can see the Average height of trees. Which the mean for variable height in trees dataset.
To calculate the median, use.
median(trees$Height).
to know the mode, use.
Mode(trees$Height).
To calculate the standard deviation of a variable in the dataset , type.
sd(trees$Height).
You can calculate Standard error of the mean using.
sd(trees$Height) / sqrt(length(trees$Height)).
to know the Five-number summary, quartiles, percentiles.
summary(trees$Height).
To calculate skewness and kurtosis use.
describe(trees$Height,type=3) .
there are 3 options available for calculating skewness and kurtosis, you can see in package documentation for details.
At first, the packages that are necessary are psych and Desctools.
Using the Following commands will install the packages only if they are not already installed.
Type.
This will load the package.
To Load inbuilt data, type.
data("trees") .
This will loads data that is inbuilt in dataset package of R which includes Girth, Height and Volume for Black Cherry Trees.
To know the structure of the data frame, use
str(trees)
this will now show the number of observations and variables in the dataset.
Next, use
summary(trees)
this give summary of each variables in the dataset.
To know the mean of single variable in dataset use the following command format.
mean(trees$Height)
now you can see the Average height of trees. Which the mean for variable height in trees dataset.
To calculate the median, use.
median(trees$Height).
to know the mode, use.
Mode(trees$Height).
To calculate the standard deviation of a variable in the dataset , type.
sd(trees$Height).
You can calculate Standard error of the mean using.
sd(trees$Height) / sqrt(length(trees$Height)).
to know the Five-number summary, quartiles, percentiles.
summary(trees$Height).
To calculate skewness and kurtosis use.
describe(trees$Height,type=3) .
there are 3 options available for calculating skewness and kurtosis, you can see in package documentation for details.