median of a row dataframe in r
# Create a sample dataframe
set.seed(123)
data <- matrix(rnorm(20), ncol = 4)
df <- as.data.frame(data)
# Calculate the median of each row in the dataframe
row_medians <- apply(df, 1, median)
# Create a sample dataframe
set.seed(123)
data <- matrix(rnorm(20), ncol = 4)
df <- as.data.frame(data)
# Calculate the median of each row in the dataframe
row_medians <- apply(df, 1, median)