boxplot

R: Plot multiple box plots using columns from data frame

守給你的承諾、 提交于 2019-11-27 06:03:17
问题 I would like to plot an INDIVIDUAL box plot for each unrelated column in a data frame. I thought I was on the right track with boxplot.matrix from the sfsmsic package, but it seems to do the same as boxplot(as.matrix(plotdata) which is to plot everything in a shared boxplot with a shared scale on the axis. I want (say) 5 individual plots. I could do this by hand like: par(mfrow=c(2,2)) boxplot(data$var1 boxplot(data$var2) boxplot(data$var3) boxplot(data$var4) But there must be a way to use

Remove Unused categorical values boxplot - R [duplicate]

大憨熊 提交于 2019-11-27 04:49:17
问题 This question already has an answer here: Drop factor levels in a subsetted data frame 14 answers I have the following code: x = rnorm(30, 1, 1) c = c(rep("x1",10), rep("x2",10), rep("x3",10)) df = dataframe(x,c) boxplot(x ~ c, data=df) It works great. But if I decide I am no longer interested in seeing x3, remove it, and replot: dfMod = subset(df, c %in% c("x1", "x2")) boxplot(x ~ c,data=dfMod) The boxplot still shows a column for x3. Ive tried giving boxplot a hint using boxplot(x~c,data

Hierarchically grouped boxplot

丶灬走出姿态 提交于 2019-11-27 04:44:15
问题 I would like to draw a boxplot with two sets of data to compare. I am willing to use Hierarchically grouped boxplot. I could just plot one set of my data using this function. I was wondering how I can use this function to plot two sets of data together. I drew the second set of data in red one by hand to show what I am trying to plot! My problem is that I can't put two sets of data on one graph with hold on . 回答1: Well, this is not precisely what you asked for, and does not use the function

Removing one tableGrob when applied to a box plot with a facet_wrap

谁都会走 提交于 2019-11-27 04:01:11
问题 I'm using the code below to enrich a box plot with a summary table for categorical variable created on the x-axis. # Libs require(ggplot2); require(gridExtra); require(grid); require(ggthemes) # Data data(mtcars) # Function to summarise the data fun_dta_sum <- function(var_sum, group, data) { sum_dta <- data.frame( aggregate(var_sum ~ group, FUN = min, data = data), aggregate(var_sum ~ group, FUN = max, data = data), aggregate(var_sum ~ group, FUN = mean, data = data)) sum_dta <- sum_dta[,c(1

Connect ggplot boxplots using lines and multiple factor

耗尽温柔 提交于 2019-11-27 03:49:30
问题 I'm trying to connect ggplot2 boxplots with geom_lines for multiple factors. I'd been able to accomplish so far to connect all the boxplot with lines, see attach picture. But I wish to connect the only boxplots by their corresponding factor. For example for my variable FL, I want to connect only those two boxplot, without connecting them with the remaining variables. Similarly for the variable RW, connecting those two sex boxplot without the remaining others. library("MASS") data(crabs) melt

Boxplot of table using ggplot2

牧云@^-^@ 提交于 2019-11-27 03:29:18
问题 I'm trying to plot a boxplot graph with my data, using 'ggplot' in R, but I just can't do it. Can anyone help me out? The data is like the table below: Paratio ShapeIdx FracD NNDis Core -3.00 1.22 0.14 2.71 7.49 -1.80 0.96 0.16 0.00 7.04 -3.00 1.10 0.13 2.71 6.85 -1.80 0.83 0.16 0.00 6.74 -0.18 0.41 0.27 0.00 6.24 -1.66 0.12 0.11 2.37 6.19 -1.07 0.06 0.14 0.00 6.11 -0.32 0.18 0.23 0.00 5.93 -1.16 0.32 0.15 0.00 5.59 -0.94 0.14 0.15 1.96 5.44 -1.13 0.31 0.16 0.00 5.42 -1.35 0.40 0.15 0.00 5.38

geom_boxplot() from ggplot2 : forcing an empty level to appear

≯℡__Kan透↙ 提交于 2019-11-27 03:24:10
问题 I can't find a way to ask ggplot2 to show an empty level in a boxplot without imputing my dataframe with actual missing values. Here is reproducible code : # fake data dftest <- expand.grid(time=1:10,measure=1:50) dftest$value <- rnorm(dim(dftest)[1],3+0.1*dftest$time,1) # and let's suppose we didn't observe anything at time 2 # doesn't work even when forcing with factor(..., levels=...) p <- ggplot(data=dftest[dftest$time!=2,],aes(x=factor(time,levels=1:10),y=value)) p + geom_boxplot() #

Overlaying the numeric value of median/variance in boxplots

半世苍凉 提交于 2019-11-27 02:21:19
问题 When using box plots in Python, is there any way to automatically/easily overlay the value of the median & variance on top of each box (or at least the numerical value of the median)? E.g. in the boxplot below, I would like to overlay the text (median, +- std) on each box plot. 回答1: Assuming you are using the boxplot function to draw the boxplots, it returns a dictionary that holds the components of the graph. Note that the box represent the inner quartile range (25 to 75th percentile) and

R - ordering in boxplot

孤人 提交于 2019-11-27 01:42:05
I am trying to produce a series of box plots in R that is grouped by 2 factors. I've managed to make the plot, but I cannot get the boxes to order in the correct direction. My data farm I am using looks like this: Nitrogen Species Treatment 2 G L 3 R M 4 G H 4 B L 2 B M 1 G H I tried: boxplot(mydata$Nitrogen~mydata$Species*mydata$Treatment) this ordered the boxes alphabetically (first three were the "High" treatments, then within those three they were ordered by species name alphabetically). I want the box plot ordered Low>Medium>High then within each of those groups G>R>B for the species. So

Include space for missing factor level used in fill aesthetics in geom_boxplot

穿精又带淫゛_ 提交于 2019-11-27 01:36:20
I am trying to draw a box and whisker plot in R. My code is below. At the moment, because I only have data for two months in one of the two sites, the bars are wider for that site (because the third level of month is dropped). Instead, I would like the same pattern of boxes for site A as there is for site B (i.e. with space for an empty box on the right-hand side). I can easily do this with drop=TRUE when I only have one factor but do not seem to be able to do it with the "filling" factor. Month=rep(c(rep(c("Jan","Feb"),2),"Mar"),10) Site=rep(c(rep(c("A","B"),each=2),"B"),10) factor(Month)