Watts-College / cpp-527-fall-2021

A course shell for CPP 527 Foundations of Data Science II
https://watts-college.github.io/cpp-527-fall-2021/
2 stars 6 forks source link

Incorrect Output for create_game() #29

Open aawoods97 opened 2 years ago

aawoods97 commented 2 years ago

Hello, I am receiving an error when attempting to run the game. Instead of outputting three doors as expected, it is outputting ten. I did have a function from a previous lab that would output ten doors. Is it possible that this function is being called instead of the one from the package? I attached a copy of the console as well.

Screen Shot 2021-09-10 at 5 57 54 PM
aawoods97 commented 2 years ago

Additionally, when I attempt to load the package, there is nothing on the help page, but my edits are reflected in the description file ![Uploading Screen Shot 2021-09-10 at 5.58.41 PM.png…]()

aawoods97 commented 2 years ago

In regards to the first problem, I uninstalled the package and the function is still running. How can I ensure the function of previous documents isn't being called?

lecy commented 2 years ago

You need to restart R. Just make sure you are not saving your R sessions when you quit. This preserves old objects like datasets, vectors and functions from previous sessions and is rarely helpful.

You can clear all objects by typing:

rm(list = ls())

R Studio has a nice shortcut for opening a clean R environment:

Ctrl+Shift+F10

aawoods97 commented 2 years ago

I did this and the function stopped working entirely. I received an error saying:

'Error in create_game() : could not find function "create_game"'

Where could I find the source of this problem?

lecy commented 2 years ago

That is good, though. You were running an old function, not the one from your package.

There are a couple of problems to fix.

lecy commented 2 years ago

I see you created a folder inside of your montyhall folder called montyhall. This is creating conflict.

You FINAL folder structure should be:

documents     # should be back here 
├─ montyhall  
│  ├─ R
│  ├─ man     # new *.rd files will be here 
lecy commented 2 years ago

Your script / documented functions look fine in the R folder.

The document() step did not work, though, because you don't have a man folder and your help files don't work.

I would save your R script (and your DESCRIPTION file if you updated that), delete the entire montyhall folder, and start over.

Pay attention to the directory structure at each step. I think that's where you are getting tripped up.

aawoods97 commented 2 years ago

Okay, I will begin that now.

lecy commented 2 years ago

I did this and the function stopped working entirely. I received an error saying:

'Error in create_game() : could not find function "create_game"'

Where could I find the source of this problem?

Your package was not installing correctly, which is why it can't find the function. You were calling an old create_game() function that was hanging out in your environment.

Once your folder structure is fixed it should work. Your code looks good, other files ok. Just need to fix the folders.

aawoods97 commented 2 years ago

When creating the package, my output was slightly different than the one listed in the instructions. Will this cause any errors?

Screen Shot 2021-09-10 at 9 02 25 PM
lecy commented 2 years ago

I don't think so. You have these now, right? Then you are good.

├─ montyhall  
│  ├─ R (folder)
│  ├─ DESCRIPTION
│  ├─ NAMESPACE
aawoods97 commented 2 years ago

Yes I do

aawoods97 commented 2 years ago

It worked! Thank you so much for your help!

lecy commented 2 years ago

Excellent!

sandralili commented 2 years ago

Hello Dr. @lecy I followed the tutorial and everything looks ok until the system needs to install some files; I have tried several times and only get to this part. Could you please help me? ( I have read other comments to see if I can find something to help me). Thanks!

image Warning message: In file.copy(savedcopy, lib, recursive = TRUE) : problem copying C:\Users\sandr\OneDrive\Documents\R\win-library\4.0\00LOCK\testthat\libs\x64\testthat.dll to C:\Users\sandr\OneDrive\Documents\R\win-library\4.0\testthat\libs\x64\testthat.dll: Permission denied

library(devtools) has_devel() Your system is ready to build packages!

setwd( "C:/Users/sandr/OneDrive/Documents" ) usethis::create_package( "montyhall" ) √ Creating 'montyhall/' √ Setting active project to 'C:/Users/sandr/OneDrive/Documents/montyhall' √ Creating 'R/' √ Writing 'DESCRIPTION' Package: montyhall Title: What the Package Does (One Line, Title Case) Version: 0.0.0.9000 Authors@R (parsed):

  • First Last first.last@example.com [aut, cre] (YOUR-ORCID-ID) Description: What the package does (one paragraph). License: use_mit_license(), use_gpl3_license() or friends to pick a license Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.1 √ Writing 'NAMESPACE'

This part is missing:

✔ Writing 'montyhall.Rproj'

✔ Adding '.Rproj.user' to '.gitignore'

✔ Adding '^montyhall\.Rproj$', '^\.Rproj\.user$' to '.Rbuildignore'

✔ Opening 'montyhall/' in new RStudio session

✔ Setting active project to ''

(Sorry I didn't know these letters were going to be very large.)

image I don't get the rest of the files. Thanks!

lecy commented 2 years ago

That’s right. The messages might be a little different.

you have what you need there

sandralili commented 2 years ago

Hello again Dr. @lecy , I am in this step now and I keep getting this message: In the beginning, it allowed me to answer when asked which file I wanted to update, I selected 1 a couple of times, now it is now asking me anymore, but still incurring the same problem. I am trying to resolve the problem with the package 'dplyr' , but not sure if I am doing it right.

devtools::install( "C:/Users/sandr/OneDrive/Documents/montyhall" ) These packages have more recent versions available. It is recommended to update all of them. Which would you like to update?

1: All
2: CRAN packages only
3: None
4: vctrs (0.3.6 -> 0.3.8 ) [CRAN] 5: rlang (0.4.10 -> 0.4.11) [CRAN] 6: ellipsis (0.3.1 -> 0.3.2 ) [CRAN] 7: tibble (3.0.6 -> 3.1.4 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates:

√ checking for file 'C:\Users\sandr\OneDrive\Documents\montyhall/DESCRIPTION'

√ checking DESCRIPTION meta-information

Running "C:/PROGRA~1/R/R-40~1.2/bin/x64/Rcmd.exe" INSTALL "C:\Users\sandr\AppData\Local\Temp\RtmpysJ3Jo/montyhall_0.0.0.9000.tar.gz" --install-tests

** using staged installation

** R

** byte-compile and prepare package for lazy loading

Error: package or namespace load failed for 'dplyr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):

namespace 'ellipsis' 0.3.1 is being loaded, but >= 0.3.2 is required

Error: package 'dplyr' could not be loaded

In addition: Warning message:

package 'dplyr' was built under R version 4.0.5

Execution halted

ERROR: lazy loading failed for package 'montyhall'

Error in (function (command = NULL, args = character(), error_on_status = TRUE, : System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed Type .Last.error.trace to see where the error occurred

If I tried to continue with the instructions, this is the message I'm getting:

library( montyhall ) Error in library(montyhall) : there is no package called ‘montyhall’

sandralili commented 2 years ago

I was able to fix the CRAN packages versions vctrs (0.3.6 -> 0.3.8 ) [CRAN] rlang (0.4.10 -> 0.4.11) [CRAN] ellipsis (0.3.1 -> 0.3.2 ) [CRAN] tibble (3.0.6 -> 3.1.4 ) [CRAN]

I went to the RStudy and install them from there. I did try to install also the dplyr. It looks like it needs a 4.05 version. I am trying to figuring it out.

lecy commented 2 years ago

Sandra, can you please read through this thread. Ahmed was having the same problem:

https://github.com/Watts-College/cpp-527-fall-2021/issues/21#issuecomment-916375475