How could I find the median value of a column in R. Each of my column has almost three to five values in it. The result should only be one value for each column.
            Asked
            
        
        
            Active
            
        
            Viewed 39 times
        
    0
            
            
        - 
                    2Refer to [this question](https://stackoverflow.com/questions/21644848/summarizing-multiple-columns-with-dplyr), and use the `median` function – IceCreamToucan Oct 23 '20 at 15:16
3 Answers
0
            
            
        foo <- c(1,2,3)
median(foo)
And in a data frame:
df <- data.frame(
    a = c(1,2,3)
  )
median(df[,"a"])
 
    
    
        MKR
        
- 1,620
- 7
- 20
0
            
            
        With dplyr and using iris dataframe for example:
library(dplyr)
#Data
data("iris")
#Code
iris %>% select(-Species) %>% summarise_all(median,na.rm=T)
Output:
  Sepal.Length Sepal.Width Petal.Length Petal.Width
1          5.8           3         4.35         1.3
 
    
    
        Duck
        
- 39,058
- 13
- 42
- 84
 
     
    