Hallo I am not familiar with any of packages you use (except of MASS and ggplot2) and the code is too complicated without any hint where the error could come from and what is the message you get. I wonder if anybody would like to go through your whole code.
1. data seems to be read correctly ICUData <- read.csv(file = "ICUData.csv", stringsAsFactors = TRUE) ICUData.neuro <- ICUData[ICUData$surgery == "neuro",] 2. ggplot(ICUData, aes(x=ICUData.neuro$LOS)) + geom_histogram(aes(y=after_stat(density)), binwidth = 5, fill = "darkgrey") gives me error Error in `check_aesthetics()`: ! Aesthetics must be either length 1 or the same as the data (500): x Run `]8;;rstudio:run:rlang::last_error()rlang::last_error()]8;;` to see where the error occurred. which, I believe, resulted from using whole ICUData in ggplot but only ICUData.neuro as aes value. Compare: ggplot(ICUData.neuro, aes(x=ICUData.neuro$LOS)) + geom_histogram(aes(y=after_stat(density)), binwidth = 5, fill = "darkgrey") with ggplot(ICUData, aes(x=ICUData.neuro$LOS)) + geom_histogram(aes(y=after_stat(density)), binwidth = 5, fill = "darkgrey") Cheers Petr And I do not provide private consulting so keep your posts to R help. Others may have much more insightful answers. From: Upananda Pani <upananda.p...@gmail.com> Sent: Wednesday, January 11, 2023 2:43 PM To: PIKAL Petr <petr.pi...@precheza.cz> Subject: Re: [R] Reg: ggplot error Hi Respected Member, Please find attached. Regards, Upananda Pani On Wed, Jan 11, 2023 at 6:07 PM PIKAL Petr <mailto:petr.pi...@precheza.cz> wrote: Hi Attachments are mostly removed from emails so they probably will not reach r-help. You said you get an error, which is the first place you should look at. It can navigate you to the source of the error if you read it carefully. Anyway, if your code is complicated it is difficult to understand and decipher. So think about simplification and maybe you will find the error source yourself during this simplification. Cheers Petr > -----Original Message----- > From: R-help <mailto:r-help-boun...@r-project.org> On Behalf Of Upananda Pani > Sent: Wednesday, January 11, 2023 1:06 PM > To: Eric Berger <mailto:ericjber...@gmail.com> > Cc: r-help <mailto:r-help@r-project.org> > Subject: Re: [R] Reg: ggplot error > > I am sorry. > > On Wed, Jan 11, 2023 at 5:32 PM Eric Berger <mailto:ericjber...@gmail.com> > wrote: > > > No code or data came through. > > Please read the posting guidelines. > > > > > > On Wed, Jan 11, 2023 at 1:38 PM Upananda Pani > > <mailto:upananda.p...@gmail.com> > > wrote: > > > > > > Dear All, > > > > > > I am using roptest function of package "ROptEst" (Kohl and > > > Ruckdeschel > > > (2019)) to find out the ML, CvM-MD, and the RMX estimator and their > > > asymptotic confidence intervals. I am assuming 1-5% of erroneous > > > data for the RMX estimator. > > > > > > Then I am trying to Plot the data in the form of a histogram and add > > > the three Gamma distribution densities with the estimated parameters > > > and validate the three models additionally with pp- and qq-plots. > > > > > > I have tried to code it. I have attached the code and data. I am > > > getting error while fitting ggplot to plot the distribution densities. > > > > > > I am doing some error which I am not able to correct. Please help me > > > to find out my error. > > > > > > With sincere regards, > > > Upananda Pani > > > ______________________________________________ > > > mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.