I wanted to get the median of a row, although I worked I also want the name to come with it.
dataset_verkopen %>%
summarise(medianPayed = median(madeMoney))
I wanted to get the median of a row, although I worked I also want the name to come with it.
dataset_verkopen %>%
summarise(medianPayed = median(madeMoney))
Welcome to the community. Please try to post reproducible example (FAQ: What's a reproducible example (`reprex`) and how do I create one?) when you ask something. Otherwise, sometime it is difficult to find what you exactly try to solve. I assume you try to find median rowwise (for every row). Please take a look at following code (I generate df and find median rowwise)
library(tidyverse)
df<-tribble(~x, ~y,~z,2,3,1,3,9, 7)
df
#> # A tibble: 2 x 3
#> x y z
#> <dbl> <dbl> <dbl>
#> 1 2 3 1
#> 2 3 9 7
df %>%
rowwise()%>%
mutate(med = median(c(x,y,z))) %>%
ungroup()
#> # A tibble: 2 x 4
#> x y z med
#> <dbl> <dbl> <dbl> <dbl>
#> 1 2 3 1 2
#> 2 3 9 7 7
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.