Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
60 views

what's diffrent of geom_histogram about statistical transformations

i have no idea with the difference between statistical transformations about plot1 and plot2 ? plot1 <- ggplot(mpg, aes(x = hwy)) + geom_histogram(stat = "density") plot2 <-ggplot(...
kschen's user avatar
  • 13
0 votes
1 answer
102 views

How to implement after_stat(ymax) with count expression in r?

I would like to add n numbers to each ggplot box plots with the italic(n) = #. I have tried expression and bquote for label but did not work. Any suggestion? stat_summary(fun = median, fun.max = ...
Fkiran's user avatar
  • 79
0 votes
1 answer
79 views

Overlay bar chart in Age standardised mortality rate graph in ggplot in r

I have age-standardized mortality rates with a 95%CI graph in a ggplot, is there any way I can add a number of deaths by year in this graph? I thought of showing this as a bar chart by adding a second ...
skpak's user avatar
  • 97
1 vote
1 answer
29 views

I want to create a separate bar chart but only one bar appears and it looks like they add together, dodge doesn't work

I don't know why all the time the bar chart is not separated, I want to do a comparation between temperature and male-female floration monthly but dodge doesn't work. enter image description here year ...
bryan simba's user avatar
1 vote
1 answer
1k views

Error with adding p-values using stat_pvalue_manual into a ggplot [duplicate]

I have a problem with stat_pvalue_manual. They showed an error whenever I ran it with stat_pvalue_manual function. I tried to use stat_compare_means, but it is wrong with p.adj value, so I need to ...
Trinh Phan-Canh's user avatar
1 vote
1 answer
459 views

in R, draw LDA and QDA partition lines on the same plot

I have trouble understanding how to 'export' equations of the delimitation lines resulting from a linear (LDA) or quadratic discriminant analysis (QDA) in R. Ideally, I would like to compare both ...
Alex's user avatar
  • 158
0 votes
3 answers
71 views

extracting selected estimate and CI from a linear mixed model

I need help in extracting estimate and CIs only for yr_qun variable from my linear mixed model. when I run the following code I get Error: ! Tibble columns must have compatible sizes. • Size 30: ...
skpak's user avatar
  • 97
0 votes
1 answer
662 views

Draw ellipse in PCA plot with 3 data points in each group

I am using RNA transcriptome data "test.csv" to make PCA plot and draw an ellipse around each group with only three biological replicate data points. test.csv Script data <- read.csv(&...
Govind Sah's user avatar
0 votes
0 answers
83 views

showing estimate value in the forest plot from ZINB model

This question is a follow up question to Overlay of forest plot from ZINB model. I need help in displaying the estimated value in the forest plot from ZINB model indicated in the picture below library(...
skpak's user avatar
  • 97
0 votes
0 answers
142 views

Automatically assigning p-value position in ggplot loop

I am running an mapply loop on a huge set of data to graph 13 parameters for 19 groups. This is working great except the p-value position. Due to the data varying for each plot I cannot assign ...
T_J_Neuro's user avatar
0 votes
2 answers
2k views

Add Mean Trend Line to geom_line plot + R

I need to add an average trend line to a geom_line line plot in R. The result should be a dotted line on the same chart that that is the average of the values that make up the other lines, like so: ...
John Conor's user avatar
0 votes
0 answers
21 views

Moving equation when saved

I have been using the command ggsave to save my plots: ggsave("t1_b_radish.jpg") But when i save it, the equations in plot moves at random spot. I have a lot of plots to save, so saving ...
Disha Dhanda's user avatar
1 vote
1 answer
81 views

Is there a way to fix these blank gaps between areas in ggplot?

I have a problem with drawing coloured areas behind the plot of a Normal Distribution. I desire to achieve something like this: enter image description here but without the blank gaps. My code is ...
Riccardo Fassina's user avatar
0 votes
0 answers
277 views

Adding Custom Brackets labels for Statistical comparisons manually in ggplot2

I have data (data.se) that I want to use to add custom bracket comparison after running a multivariate linear model with adjustment. I need to modify the stat labels and want to show the comparisons ...
James Jean IV's user avatar
0 votes
1 answer
2k views

Add statistical significance to ggplot with geom_bar by bar

I'm representing a barplot with geom_bar in R that displays two discrete x levels and one continuous y level faceted. I want to put stars to show the significance level (p-value) between the groups ...
Elena Priego's user avatar
2 votes
1 answer
610 views

Grouped ggplot for adding p-values

I'm trying to print the bonferroni p values on top of every grouped bar plot. The code that I'm using is: stat1 <- stack[1:170,] %>% rstatix::group_by(modules) %>% rstatix::t_test(values ~ ...
driver's user avatar
  • 266
0 votes
0 answers
46 views

split violin plot for a lung function (continuous) comparing distance with overly plot

I'd like to make a split violin plot for a lung function (continuous) that compares distance (its categorical variable, i.e., two categories) in children and adults, as well as overly crude and ...
skpak's user avatar
  • 97
-2 votes
1 answer
191 views

How do I add the names of the graphs inside the plot in R?

I built the graph but I try to add the names of the graphs and it does not work. It should look like in the picture, I only have the graphs without the names I would happy if anyone knows which ...
Miki Hayat's user avatar
0 votes
0 answers
268 views

Interrupted or no ribbon ggplot geomribbon or stat_summary

I have a df that looks like this: ID Genotype Time10min N mean sd se ci 43 1 k_DMSO 43 10 0.029318750 0.009793853 0.0030970883 0.007006100 44 1 ...
Tahnee's user avatar
  • 77
1 vote
1 answer
647 views

geom_bar with x and fill aesthetics by one factor and dodge by a second

I have this data.frame: df <- data.frame(id = c("A","A","B","B","C","C"), age = rep(c("young", "old")...
dan's user avatar
  • 6,294
0 votes
1 answer
172 views

Something wrong with my segmented bar plot in ggplot2

I want to plot a segmented bar plot in ggplot2. Here is part of my dataframe, I want to plot the proportion of output(0 and 1) for each x1(0 and 1). But when I use the following code, what I plot is ...
Sihang Zeng's user avatar
0 votes
1 answer
138 views

R: ggplot2 stat_bindot alternative for circle / round points - error produced

I'm currently using the below code to display rectangular plots on a heatmap: stat_bin2d(bins = 19, aes(fill = after_stat(density))) + The following error presents itself: could not find function &...
Stacker's user avatar
1 vote
2 answers
1k views

Why does stat_compare_means only show pairwise comparisons in one facet?

I'm trying to do a pairwise comparison of grouped data. I've used stat_compare_means to do this successfully before, but for some reason this time it is only showing the comparison bars in one of the ...
Mike's user avatar
  • 1,141
0 votes
1 answer
134 views

ggplot2 geom_qq change theoretical data

I have a set of pvalues i.e 0<=pval<=1 I want to plot qqplot using ggplot2 As in the documentation the following code will plot a q_q plot, however if my data are pvalues I want the therotical ...
Mariya's user avatar
  • 847
0 votes
1 answer
145 views

ggplot kernal density plot lines overlapping improperly

The colors in my density plot are wrong! I can't figure out why. Here is my data: https://pastebin.com/0jqHgvxx data %>% ggplot(aes(x=amountremain, color=black)) + geom_density() When I ...
myfatson's user avatar
  • 539
0 votes
0 answers
301 views

Extrapolating/predicting non-linear using ggplot

I want to be able use the stat_smooth function in ggplot to extrapolate/predict using a regression model, via a non-linear function. Is there a way to do this? I have been trying this on the Iris ...
awz1's user avatar
  • 449
1 vote
1 answer
635 views

facet_zoom by date range from stat_summary

I am trying to zoom into a specific date range but the code below is not allowing me to do so. Also in this plot are stat_summary by Bleach and an existing facet by Species. I am willing to zoom into ...
user avatar
1 vote
1 answer
44 views

How can I plot x with mutiple y values?

I would like to plot these. subj type stc key value 1 2 1 1 X1 94.30562 2 2 1 7 X1 94.30104 3 2 2 1 X1 95.26288 4 2 2 7 X1 94.66240 5 3 1 1 X1 89....
hannah's user avatar
  • 13
1 vote
1 answer
164 views

Add Percentage Labels to Pie chart in ggplot2?

I've been struggling with trying to put percentage labels on a pie chart in ggplot2. I know this has been posted a lot but I wasn't able to use examples to get my code to work. I'm just looking for a ...
Kyle Schichl's user avatar
0 votes
0 answers
285 views

Polynomial Regression Plot R

Bit of a beginner in R, so I was adding polynomial regression models to a ‘Global Terrorism’ graph for degree 1, 2, 3, and 4 polynomials with different colors. I was working on the 1st degree and when ...
ColdLogic121's user avatar
2 votes
1 answer
639 views

R: Using time series data with 'splinefun' and ggplot2 'stat_function'

I have time series data with one observation at each respective time. I run it through R's splinefun to create a spline function for the observations. I would like to plot this spline function in ...
Eric Krantz's user avatar
  • 2,061
0 votes
0 answers
24 views

how to get the stat details in ggplot2? [duplicate]

Just one question about r. as we know ,in the base R, for example, in hist function, we conduct following calculation: x=rnorm(500,90,3) a<-hist(x) b<-density(x) then we can find details by a$ ...
Guangming Wu's user avatar
1 vote
0 answers
993 views

No fitted curves with warning: "ggplot2: stat_smooth warnings: Computation failed in `stat_smooth()`: object 'weight' not found"

I am trying to fit nonlinear curves to a list of scatterplots. I use 'gnls' to fit the nonlinear model. 'gnls' works well, but when I tried to use it as a smooth method in ggplot2. It gives warnings: ...
kickshark's user avatar
0 votes
0 answers
37 views

Plotting an Exponential Best Fit Curve to ggplot2 using Stat_smooth [duplicate]

Here is my data: df <-read.table(text="x group y 1 A 0.5 2 A 0.25 3 A 0.1 1 B 0.6 2 B 0.7 3 B 0.2", header=TRUE) What I'm trying to do is plot ...
Kardinol's user avatar
  • 301
1 vote
1 answer
756 views

Changing the size of line drawn with stat_function

I'm trying to plot a series of functions with stat_function in ggplot2 on R. The function remains the same throughout, but some of the parameters change according to values in a data frame. I used a ...
Vinay Swamy's user avatar
0 votes
0 answers
120 views

PLease explain stat_summary inheritance?

I'm new to ggplot2 and don't really understand how inheritance works. I'm trying to create a line plot of sums of 4 types of air pollution across time: ## Download dataset to local directory and read ...
Carlton Lee's user avatar
4 votes
1 answer
1k views

issue with using stat_summary to produce error bars for line graphs when faceting

I'm trying to add error bars to line graphs using stat_summary in ggplot2 but it won't work when I facet the graphs My data: date week year location imidacloprid block wickhami virescens sexta 1 ...
hortsystems's user avatar
1 vote
1 answer
2k views

Create group smooth plot in ggplot2

I am currently plotting a graph with 100 individuals over 10 years, where each line in the graph is for one individual. The 100 individuals are also grouped into 4 different stratification groups. I ...
YDao's user avatar
  • 325
1 vote
1 answer
3k views

How to visulaize linear model prediction in ggplot along with confidence interval?

Suppose I'm using my_df to fit a linear model. After getting the estimates I want to see how well model1 can predict n case of another dataset. I'm not sure if the following is the right way to ...
Jack's user avatar
  • 165
1 vote
1 answer
2k views

modify stat_summary to also show count in distribution for box plot

I have the boxplot below and I'd like to have the count as text. group = c( rep(c(1,2,1),100) ) group2 = rep(c("A","B","B"),100) r = rnorm(300,50,63) d = data.frame( group = group, r = r , ...
user3022875's user avatar
  • 8,998
2 votes
1 answer
1k views

conf.int no longer working in 3.3 using ggplot2, stat_summary

I am using conf.int for the creation of boxes around a jitterplot. This had worked until upgrading R to 3.3. Is there a known fix for this? stat_sum_df_all <- function(fun, geom="crossbar", ...) { ...
rrbest's user avatar
  • 1,779
1 vote
3 answers
124 views

Does ggplot use dynamic function for statistic functions?

So I'm running an optimization problem and am trying to add the function at each point in time to a plot. I'm able to plot the function but I have the variables stored and it seems like r doesn't ...
Paul McVay's user avatar
3 votes
1 answer
3k views

ggplot2: add line for average per group (Error: No stat called StatHline.)

I recently updated ggplot2 package and running into major issues drawing horizontal lines for averages per group using facets. I believe this post is no longer valid? I am creating a time series ...
Shery's user avatar
  • 1,872
3 votes
1 answer
396 views

extract equation used to get the best fit using Lattice (panel.smoother) or ggplot

I have 100+ files with similar data following almost the same trend. I have managed to obtained best fits for all of them but now i want to compare that to a theoretical argument. To put in other ...
Ayushi Kachhara's user avatar
9 votes
1 answer
13k views

R : stat_smooth groups (x axis)

I have a Database, and want to show a figure using stat_smooth. I can show the avg_time vs Scored_Probabilities figure, which looks like this: c <- ggplot(dataset1, aes(x=Avg.time, y=Scored....
Jeffery Chen's user avatar
1 vote
3 answers
4k views

Count and Percent Together using Stack Bar in R

I am trying to create stack bar with counts and percent in same graph. I took help from Showing data values on stacked bar chart in ggplot2 and add group total and plotted my as By using code ### ...
user2612244's user avatar
1 vote
1 answer
2k views

Conditional stat_summary for ggplot in R

I'd like to write some conditional stats in my graph if the data is bigger than a certain value. With the kind help of Jack Ryan (Cut data and access groups to draw percentile lines), I could create ...
Powderking's user avatar
67 votes
5 answers
58k views

Method to extract stat_smooth line fit

Is there a way to extract the values of the fitted line returned from stat_smooth? The code I am using looks like this: p <- ggplot(df1, aes(x=Days, y= Qty,group=Category,color=Category)) p <- ...
MikeTP's user avatar
  • 7,976