visualization - plotting different columns in r -
data = 110 columns( x1: x100) (numeric)
i trying plot columns using following code,
x2=melt(x1) ggplot(x2,aes(x = value)) + facet_wrap(~variable,scales = "free_x") + geom_histogram(aes=(density)) +title(sub = s, line = 5.5) s<-summary(x1)
i'm want append summary data every column in plot analysis . there alternate this?
thanks.
to knowledge, cannot add subtitles subplots of facet_wrap. change title accomodate want though. here example min, max, mean , median :
data = data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100), x4=rnorm(100), x5=rnorm(100), x6=rnorm(100)) library(dplyr) library(tidyr) library(ggplot2) x <- data %>% gather(variable,value) %>% group_by(variable) %>% mutate(mean=mean(value), median=median(value), min=min(value), max=max(value), lab=paste(first(variable),"\nmin:",round(min,2),"mean:",round(mean,2),"median:",round(median,2),"max:",round(max,2))) ggplot(x,aes(x = value)) + facet_wrap(~lab,scales = "free_x") + geom_histogram(aes=(density)) + geom_vline(aes(x=mean))
Comments
Post a Comment