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

215 Views Asked by At

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.
2

There are 2 best solutions below

2
Ben Bolker On BEST ANSWER

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.

0
NinjaS On

To the second part of your question: why skip() skips to the main menu and not just skips the question: Yes there does seem to be a glitch.

I had a similar issue (using Rstudio, and swirl) three are different definitions for skip():

Rstudio cursor highlight on skip(): 'return to main menu' ?skip(): 'Skip the current unit of instruction.' info() menu: 'allows you to skip the current question'.

I am a novice so I don't know if its that the swirl info() menu definition of 'a learning unit' is incorrect or Rstudios is.

Again, just for the skip() question issue: I found a solution here from @Daniel Miller its for the the question in the logic section causing the glitch for me (below) so that I could continue the lesson. But you would need to tailor your own work around by finding and deleting the glitch question for the lesson you are in by editing the lesson .yaml file, which as the answer below shows can be found here (swapping out "Logic" for whichever lesson is causing the problem): file.path(find.package("swirl"),"Courses","R_Programming","Logic","lesson.yaml") .

https://stackoverflow.com/a/76974153/22640198