Search code examples
rswirl

Does Swirl have a bug, or is my RStudio glitching?


I am currently making my way through Swirl, and I seem to be stuck on this part. As you can see, it doesn't accept (what I think is) the right answer, and when I try to skip it just takes me out of Swirl. Not sure what the problem is here, should I just uninstall and reinstall?

| Use dir.create() to create a directory in the current working directory called
| "testdir".

> "testdir"
[1] "testdir"

| Not quite! Try again. Or, type info() for more options.

| Type dir.create("testdir") to create a directory in the current working
| directory called "testdir".

> dir.create("testdir")
Error in dir.create("testdir") : unused argument ("testdir")
> dir.create(testdir)
Error in dir.create(testdir) : unused argument (testdir)
> dir.create("test.dir")
Error in dir.create("test.dir") : unused argument ("test.dir")
> skip()
Error in dir.create("testdir") : unused argument ("testdir")

| Leaving swirl now. Type swirl() to resume.

Solution

  • The only thing I can imagine is that you accidentally created your own function called dir.create that takes no arguments:

    dir.create <- function() {}
    dir.create("testdir")
    ## Error in dir.create("testdir") : unused argument ("testdir")
    

    Try

    • find("dir.create") (the answer should be "package:base")
    • base::dir.create("testdir") (should work)
    • rm(dir.create) (should remove the bogus function)
    • rm(list=ls()) to remove all objects from your workspace (note that this does not completely reset your R session ...)

    or, restart a clean R session (make sure you don't have a .RData file with the bogus function stored in it). Uninstalling and reinstalling is overkill unless something truly weird is happening.