Trying to install ggplot 2 and I keep getting this error "Error: unexpected symbol in "setwd('C:/Users/JOSH'S""

Hey hey everyone,

I am super new to ggplot and I am in a new class where we are using it to visualize data for grad school. I am been trying to install ggplot for the last 4 hours and I seem to keep coming up with the same error (below). I think Rstudio and ggplot don't like that my folder has a space in the name. How do I get around this? Any help you can provide is greatly appreciated!

Thanks,

Josh

install.packages("ggplot2")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

'RTools: Toolchains for building R and R packages from source on Windows
Installing package into ‘C:/Users/Josh's laptop/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependency ‘withr’

Many lines of txt
Error:
Error: unexpected symbol in "setwd('C:/Users/JOSH'S"
Execution halted
ERROR: lazy loading failed for package 'withr'

Yes, R isn't keen on spaces in the library path. You can run

.libPaths()

to see where the system library is installed and direct the installation there. There is a lib argument in install.packages() that allows you to control the library and I expect the RStudio installation tool can also be pointed at that.
You could go as far as making a new user, which is not difficult, and just use that for R and RStudio.
There is also the option of changing your user name. I do not know all the consequences of that but Windows does allow it, judging from a quick web search.

I created a second user account to just use ggplot. It now works!

Thanks!

Josh

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.