6
I have a database and my goal is to perform some behavior analysis of classes per line.
Example:
print(DADOS)
Linha A B C D E
L1 4 3 2 2 4
L2 1 11 1 1 1
L3 0 1 2 3 4
L4 2 0 0 8 0
Using the example above, to analyze the classes A, B, C, D and E, at first I used the Sum and Mean of each line.
Being the best way or not, to calculate the Sum and the Average I used the function mutate as follows:
DADOS = DADOS %>%
select(Linha:E) %>%
mutate(Soma = (A+B+C+D+E)) %>%
mutate(Média = Soma/5)
And my database went like this:
print(DADOS)
Linha A B C D E Soma Média
L1 4 3 2 2 4 15 3
L2 1 11 1 1 1 15 3
L3 0 1 2 3 4 10 2
L4 2 0 0 8 0 10 2
In the example above we can verify that although the lines have different data, the lines L1 and L2 possess the Soma and the Média the same applies to the Soma and the Média of the lines L3 and L4.
As the Soma and the Média were not so effective, we can include another calculation for the analysis: the Median.
How the Median Works?
In practice, Mediana sorts a data set and identifies its central element.
Example:
L4 = {2, 0, 0, 8, 0}
Ordering L4 = {0,0,0,2,8}
Median L4 = 0
Mediana divides a data set into equal parts in order to find a more assertive distribution trend. The use of Mediana is ideal to identify values in your set of data that escape the standard, the famous "non-standard".
Knowing this, the question is: How can I calculate the median of a line in a date frame.?
See the function
median().?median– Tomás Barcellos
I know the function
median, but I don’t know how to use the function to calculate the values in the line.– Izak Mandrak