0

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.
sanminchui
  • 59
  • 1
  • 9

1 Answers1

0

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.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Well, `base::dir.create("testdir")` didn't work, but when I tried `dir.create("testdir") Warning message: In dir.create("testdir") : 'testdir' already exists | Nice work!` That did work! So, I think you were right, I probably made my own function somehow, and now that I've started a clean R session (I think? Does closing out of RStudio and then reopening it count?) it worked. Thanks! – sanminchui Jul 31 '20 at 22:31
  • closing and reopening RStudio *usually* works to reset, unless you have saved a workspace as `.RData` (which can happen without your really meaning to) – Ben Bolker Jul 31 '20 at 22:51