Description
For analyzing continuous data there are two aspects. First is The central tendency, which will give a general idea about a dataset, rather than individual values. And the second is spread or dispersion of data. There are various statistical indicators or techniques, which can help to understand both aspects.
The mean and median both are the Central Tendency
. As the name suggests, measure of central tendency are used to find values in the middle of the data. And one of the most common measures of central tendency is the mean, also known as arithmetic mean
or average
. Median is another very useful major of central tendency. The median represents the value at central position.
Description
The mean and median are the function in the R programming language. The following is the syntax for the mean function.
[c]mean(x, trim = 0, na.rm = FALSE, ...)[/c]
In the above syntax, x
is the vector(input), Atomic vectors are homogeneous data structures. Means in atomic vector, each element should be an object of same class only. So, a character vector, will have all elements of character type, while a numeric vector will have all elements of numeric type.
Similarly, an integer vector will contain only objects of integer atomic class. The trim
is used to sort the vector values and to drop the observations. The na
is used to return the missing values. The following is an example.
[c]# Create a vector.
x <- c(13,6,7,6.2,16,8,54,-21,8,-5)
# Find Mean.
result.mean <- mean(x)
print(result.mean)[/c]
Output: Now compile the code result will be as follows.
[c]> print(result.mean)
[1] 9.22[/c]
Now apply the trim on the same example.
[c]# Create a vector.
x <- c(13,6,7,6.2,16,8,54,-21,8,-5)
# Find Mean.
result.mean <- mean(x,trim = 0.5)
print(result.mean)[/c]
Output: Now compile the code result will be as follows.
[c]> print(result.mean)
[1] 7.5[/c]
Description
The middle most value can be called as median, the following is the syntax for the median.
[c]median(x, na.rm = FALSE)[/c]
The following is an example.
[c]# Create the vector.
x <- c(13,6,7,6.2,16,8,54,-21,8,-5)
# Find the median.
median.result <- median(x)
print(median.result)[/c]
Output: Now compile the code result will be as follows.
[c]> print(median.result)
[1] 7.5[/c]