Change month order using R and ggplot2 [duplicate] - r

This question already has answers here:
How do you specifically order ggplot2 x axis instead of alphabetical order? [duplicate]
(2 answers)
Closed 4 months ago.
So I'm having a pretty big problem. I'm trying to plot animal density (using two methods) against months.
When I plot one of the two methods, the months go out of order and I can't seem to get them to work.
In the end I want to have each of the two methods (camera.estimations and scat.estimations) on the same plot, with SD of each included and months in the right order. Any pointers from you lovely R folk would be awesome!
Here's my data:
https://docs.google.com/spreadsheet/ccc?key=0AjSTnjcF57_IdEhUXzFyQmtZaG5NXzdzTXZkbFdweXc&usp=sharing

I have used this post to help structure my ggplots before
How do you specifically order ggplot2 x axis instead of alphabetical order?
Manually setting the order of factors works but can be annoying, but is the best answer I have for you :)
without more information hope it helps!

Related

ggplot2 geom_col() does not show all items [duplicate]

This question already has answers here:
order of stacked bars in ggplot
(1 answer)
Force ggplot legend to show all categories when no values are present [duplicate]
(1 answer)
Can you put labels between horizontal bars?
(2 answers)
Closed last month.
I'm new to R and I'm trying to plot a small survey where I used a likert-scale.
I'm using
ggplot(Likert, aes(x=Anzahl, y=Frage, fill=Zustimmung)) + geom_col()
to display the data. There are probably better ways to do this and I probably should use data frames as I currently don't use them.
Now the actual Problem: The variable "Zustimung" has 5 different specifications but only 4 of them are shown and there are sorted weirdly.
I've found a few different posts online which seem to be regarding this issue but I can't understand them. Could someone please explain why this problem occures and how I can fix this?

What function would I use in R to give more detail to this Chart? [duplicate]

This question already has answers here:
Increase number of axis ticks in ggplot2 for dates
(1 answer)
Adding date ticks to ggplot in R
(4 answers)
Closed 3 months ago.
I am fairly new to all of this, and I'm currently working with some datasets for fun/practice. I took a course on R, and it explained the basics and dove a little deeper into ggplot2, but I am at a point where I'm not quite sure what to do.
The dataset is commodity prices from 1960-2021. I am trying to visualize the cost of crude oil over that time, and currently I have a decent chart, but I am wanting to change the intervals on the tick marks so that it is more readable. I will also take any advice you guys have on how to make it look even better!
I've attached my current chart here. (https://i.stack.imgur.com/o9Z63.png)
This is my current code for the chart:
graph +
geom_point(size=2, alpha=.7) + geom_line() +
ggtitle("Oil Prices from 1960 to 2021") +
xlab("Years") + ylab("Oil Prices") +
theme(axis.title.x=element_text(color="Black", size=20),
axis.title.y=element_text(color="Black", size=20),
plot.title=element_text(color="Black", size=40))
I have tried to google the function, and have been given a bunch of answers, but I'm still not sure which one fits for what I'm trying to do. Ideally I would like the x axis (Years) to at a minimum show every 5-10 years, but the more descriptive the better. Also the Y axis (Prices) is very hard to read and tell what the actual price is.
I appreciate any and all help with this. I'm just working on it for the fun of it and to get some practice in, but figured I would use this resource and try to see what we can come up with.
Thanks!

Set limits in ggplot without loosing data points [duplicate]

This question already has an answer here:
Limit ggplot2 axes without removing data (outside limits): zoom
(1 answer)
Closed 1 year ago.
I want to focus on certain numbers above 0 in the y axis, so I tried to use
ylim(ymin=0,ymax=15)
but by doing this I removed values that are not in the figure
I tried to find another argument that will only "zoom" the figure but do not remove any actual value and the line will remain
Does anyone know any argument that will be valid?
E.g. figures
Try to use this instead of ylim()
coord_cartesian(ylim=c(0, 15))

ggplot2: dates - anyway to plot years on major x axis and months on minor x-axis?

Here's an image I made in paint on what I'm trying to do
Basically I'm trying to plot years on the major x axis and months on the minor x axis. And every three months (March, June,September,December) have a vertical broken line. I have really no clue where to start.
I'm not even sure if it is possible. I'm not sure if Hadley was addressing a similar question here. Some wrote "
Impossible labeling the minor ticks: Is this justified or a conceptual bug. At first sight it seems obvious that you want to do that, for example Mayor=years minor=months" and hadley responded
There is an infinite number of things that seems "obvious" to someone
- I can only implement and support a finite number
...so I'm not sure if what I want to do is possible in ggplot2.

What type of graph is this, and how would I go about programming it in R? [duplicate]

This question already has answers here:
creating "radar chart" (a.k.a. star plot; spider plot) using ggplot2 in R
(5 answers)
Closed 5 years ago.
I'm planning on creating a similar graph for each data point in a set where I have clustered the data into 5 clusters and calculated the distance to each centroid. Each point would represent how far away from the centroid it is relative to the average distance away. I would also like to create one graph per team where the individual player graphs overlay each other. Here is a snippet of the dataset that I'm using.
If this isn't the best way to display this sort of data, could you also explain which ways are better and how to do it?
A very interesting R package for interactive radar (o spider) charts is radarchart.
Here is a very simple code which gives you the opportunity to appreciate the potentiality of this tool. Let's enjoy it !
library(radarchart)
set.seed(12345)
X <- as.data.frame(round(matrix(runif(35),nrow=5),2))
names(X) <- c("Kaydop","Matt","kuxir97","Freakii","Jacob","JKnaps","Mognus")
labs <- paste("DistToC", 1:5)
chartJSRadar(scores=X, labs=labs)

Resources