I am trying to create a Control charts with rolling averages in R that closely matches something like this. I am relatively new to R, and my grasp of all the available pages is not great yet.
controlchart with moving average i'd like to recreate
Can someone help me figure this out? Maybe point me to the right packages I should install and study? Any help is appreciated.
I was looking for the answer to creating this type of chart myself.
One solution is the qicharts package. Instead of calling the changes rolling averages or stages (the term Minitab uses), they call the changes breaks.
Related
We have a lot of types of plots available in R. And every single time I get a dataset, I have to think for a long time that which type of plot I should use to plot my dataset in order to get information I want (I'm a beginner of R). I don't know whether it's related to my math and stats knowledge or just not familiar with R tech skills. Anybody can tell me the reasons and how to improve that? Thanks many in advance.
I am attempting a homework problem where I am tasked to plot the histogram that results from a Galton board experiment, essentially creating normal distribution by adding one value at at a time and updating the histogram after each trial (ball). I would like to find a way to update the histogram after each addition of a new value to the distribution; instead of that my code currently makes a whole ton of plots.
So far I've set up a vector with length=1000 (though theoretically I should be able to apply my final code to a vector of anything length?) and created a loop to add values to it using rbinom() with 200 "pegs" with a probability of 50% (falling left or right).
x<-numeric(1000) #create vector length of 1000 values of 0
for (i in 1:1000) {
x[i]<-sum(rbinom(200,1,0.5))
hist(x,freq=FALSE)
}
I have the hist() call within the for loop (this may be a cardinal sin in R...), which as you can imagine produces 1000 graphs! Definitely not the right way to go about this. Is there any way to just essentially update on top of the previous plot? I'm thinking of things like abline(), lines(), etc, which (as far as I can tell) just add lines on top of an already existing plot in R without creating a new one. This is probably because the data associated with those functions isn't the same as the data in a vector? Anyways, I haven't been able to figure this out wth google. I haven't tried using ggplot2 or the animate packages yet, though I'm only vaguely familiar with the former and I imagine there's a learning curve.
A final note: I'm fairly new to R, so I'd appreciate unrelated advice on the above code, but I also think it's very productive to work things out on your own, so I would prefer hints and/or general advice instead of pasting working code.
Thank you very much in advance for your help!
I am searching for a method to show progress when doing spatial operations in R. I know there are some for working with raster-data. Does anyone know a way to show progress when doing an operation with vactor-data like union{raster}? It would really help to organize our workflow here.
Thanks
It is my first time using R for phylogenetics work and I was wondering if I could do that. It seems a rather trivial job and I think there must be a very small code for this, but I am unable to get it done. Any help appreciated!
First time poster here, so please forgive any faux pas on my part.
I have a set of data which consists of essentially 3 fields:
1)Position 2)Start_of_shift (datetime object) 3)End_of_Shift (datetime object)
From the datetime object I can extract date, day of week, & time. The schedules are 24/7 and do not conform to any standard 3 shift etc. rotation, they are fairly specific to a site. (I am using the lubridate package)
I would like to visualize Time of day vs. Day of Week to show numbers of staff, so that I can see heavy concentrations of staff and where I am light at specific days and times.
I am unsure on how to approach this problem as I am relatively new to R and I have found the various date time packages & base utilities confusing and often conflicting with each other. While I find plenty of examples of time series plotting, I have found next to nothing on how to plot if you have a start and end time in separate fields and want to show areas of overlap
I was thinking of using ggplot2 with geom_tile to plot this out, with a smoother, but wanted to know if there were any good examples out there that do something similar or if anyone has any idea on how I should transform my data to best achieve my end objective. I wanted to keep the time continuous but as a last resort I will discretize it into 15 minute chunks if necessary, but didn't know if there were other options?
Any thoughts?
You might consider using a gannt chart, the gannt.chart function in the plotrix package is one option for creating them.
Maybe the timeline package is what you need. I've found it very good for planning projects. It's on CRAN, but you can see a quick example at it's Github home here.
To work out how many people are present (or should be if it's a future event) you need to think of your staffing as a stock / flow.
First step would be to use the melt function in package reshape2 to get all the dates in one column and the event (starting / finishing) in another.
From this you can create a running total of how many people will be in at any time.