Thursday 31 March 2016

r - How do I change the scale on the x-axis using ggplot2?

The goal of our project was to assess 2 behavioral responses (crossing success and crossing decision) by deer when interacting with fences. We used a modified BACI design for our study where we monitored fence sections during a pre-modification period and then implemented certain modification during what we termed a post-modification period.



We used logistic regression to evaluate the crossing success and crossing decision of mule deer and white-tailed deer at these fence sections. We modeled the effects of certain demographic factors and fence characteristics on our 2 response variables using generalized linear models with a logit link (i.e., logistic regression).




Now that we have identified the top model for both analysis, we are trying to create a caterpillar plot to graphically show the change of crossing success between the pre-modification period and the post-modification period for a specific variable we titled "Type_Period".



However, we have not been able to figure out how to change the scale of our plot (which I have attached). We used GGally, broom and ggplot2 to create the Caterpillar plot.



enter image description here



We have looked on multiple GGally, and ggplot2 help pages and I haven't been able to find any mention of how to manipulate the scale. We have tried "zooming" in on the graph but ggplot2 couldn't read the command. We tried changing the xlim but got an error message that said "ignoring unknown parameter xlim."



Here is the script that we used for the caterpillar plot only. I will provide the full script and sample database if necessary.




library(GGally)
library(broom)
library(ggplot2)
log.reg <- glm(Decision~ Type_Period, data=analysis, weights = analysis$Freq, x=TRUE,family=binomial(link="logit"))
ggcoef(log.reg, xlim=c(-1, 2))

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...