ggplot2 - R: A facet_wrap() without a factor -


i need create matrix of histograms ggplot , facet_wrap(). more or less code have following:

df_3<-data.frame(rnorm(1000),...,rnorm(1000)) #the data frame has 1000 observations , 16 variables.  colnames(df_3) <- letters[1:16]  library(ggplot2) gr12 <- ggplot(df_3, aes(x=observations)) + geom_histogram() 

my question is: how can plot matrix of histograms facet_wrap() , without factor variable?

melt dataframe long format (see reshape2), data frame goes being

      b   c ...    p 1 0.1 0.2 0.3 ... 0.16 2 0.1 0.1 0.2 ... 0.00 

(my internal randomizer bad.) to

variable  value          0.1       b    0.2       c    0.3     ...    ...       p   0.16          0.1       b    0.1       c    0.2     ...    ...       p   0.00 

then variable factor wish facet by. if long formatted data frame df_4, imagine do

ggplot(df_4, aes(x=value)) + stat_histogram() + facet_wrap(variable) 

Comments