limits: A numeric vector of length two providing limits of the scale. Use NA to refer to the existing minimum or maximum.
expand: Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. Use the convenience function expand_scale() to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.|
So you might first just remove the limits and expand in scale_x_continuous and see if that delivers the plot you were hoping for. You can also add padding by increasing the values in expand.
For additional help, a reprex is really the way to go.
Since this is off-topic from Read.table with no header - #21, where it was originally posted, I took the liberty of converting your reply-post into a new topic thread, as rensa suggested
I used reprex and got this error:
Error: .onLoad failed in loadNamespace() for 'callr', details: call: loadNamespace(name) error: there is no package called ‘debugme’
I ran the command: #Install reprex package
install.packages("reprex", dependencies = TRUE)
library(reprex)
It loaded okay. I then hit command C to copy. Then I ran reprex() and got this error.
Rendering reprex... Error: .onLoad failed in loadNamespace() for 'callr', details: call: loadNamespace(name) error: there is no package called ‘debugme’
I stopped at this point. Do you have any idea why the reprex() command gives me the error?
install.packages("callr")
install.packages("reprex", dependencies = TRUE)
library(reprex)
2.Copied the code to clip board -ctrl copy
3.used command reprex()
I got this error message:
Rendering reprex... Error: .onLoad failed in loadNamespace() for 'callr', details: call: loadNamespace(name) error: there is no package called ‘debugme’
Did I enter an incorrect command or are my methods faulty? I appreciate your patience.
reprex() is failing because of a second-degree missing dependency: reprex depends on callr, but callr depends on debugme — and you’re missing debugme. Try:
install.packages("callr", dependencies = TRUE)
Hopefully that will clear this up! By the way, if you’re using RStudio I highly recommend trying the Addin that comes along when you install reprex — all you have to do is select the code you want to run through reprex() and choose “Reprex selection” from the Addins menu. Super quick! (If you’ve never heard of Addins before and don’t know where the Addins menu is, see here: https://rstudio.github.io/rstudioaddins/#running-addins)
install.packages("callr", dependencies = TRUE) and it installed with no error.
I then copied code to the clipboard and used the command:
Reprex() and got this error which is different from the other error.
Rendering reprex...
Error in loadNamespace(name) : there is no package called ‘callr’
When I tried to install the addins I got the following error and there was no addin on my tool bar.
ERROR: dependency 'shiny' is not available for package 'addinexamples'
* removing 'C:/Users/Andre Jackson/Documents/R/win-library/3.3/addinexamples'
Error: Command failed (1)
In addition: Warning messages:
1: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\Andre Jackson\Documents\R\win-library\3.3" C:\Users\ANDREJ~1\AppData\Local\Temp\RtmpEdKjse/downloaded_packages/shiny_1.1.0.tar.gz' had status 1
2: In utils::install.packages(pkgs, repos = repos, type = type, dependencies = dependencies, :
installation of package ‘shiny’ had non-zero exit status
It looks like something did go wrong in the callr install, because reprex can't find callr when it goes looking for it. I can't tell what the problem might have been without seeing the console output that was generated when you ran the install command. But it looks like something also went wrong when R was trying to install the shiny package, which is in the dependency chain for these packages.
However, I also notice that you seem to be running a pretty old version of R (3.3 — the current version is 3.5, and R versions are released annually). Running older R will make it increasingly difficult to install packages, since pre-compiled binaries for up-to-date packages won't be available.
Before you chase these package problems any further, I'd consider upgrading R to the current version. Warning: this will require you to reinstall your packages, but the process should (hopefully!) go more smoothly. If you go this route, I'd start by installing tidyverse, which will give you reprex (and everything it needs to run) along with ggplot2, dplyr, and the rest. FYI, within RStudio, there's a nice interface for installing packages — click the Install button on the Packages pane.
The error you're getting above is because the reprex needs to be self-contained that means that you need to have library(ggplot2) inside of the reprex, otherwise you'll get the error you did, since it doesn't have the function loaded (because ggplot2 isn't loaded).
Yeah, reprex doesn't know about anything you run outside of the reprex (that's how it's self-contained, which means others can run your code to reproduce your issue)
No worries! Honestly, getting better at making reproducible examples is a great way to improve your coding in general — I can't tell you how many times I've solved my own problem en route to making a reproducible example.
Thanks for sticking with this! I really do think it's worth it, once you wrap your head around it. I highly recommend watching the recent webinar (where that slide @mara posted came from), which might help to give you a bit of the bigger picture:
I know this can feel like a lot of hoops to jump through when you're just getting started, but learning to reason about whether a chunk of code is self-contained or not is a really important step in leveling up your programming practice. And the reprex package is a fantastic tool for sharing code with other people to get their help. Once you get used to doing things the reprex way, it cuts down enormously on the time you spend going back and forth trying to explain what your problem is, and it makes your questions much more fun and appealing for other people to answer, which over time gets you better answers faster.