Watts-College / paf-514-template

https://watts-college.github.io/paf-514-template/
1 stars 0 forks source link

R Package Assignment - Cannot Change Working Directory #69

Open lindaalvarez opened 3 weeks ago

lindaalvarez commented 3 weeks ago

Hello, I am unfortunately getting stuck when trying to set my working directory for the monty-hall-pkg. I've tried a couple different ways such as creating a folder as well as having the pkg in my downloads but I keep getting an error that I cannot change my wd. @castower

Screen Shot 2024-09-04 at 9 48 26 AM
lecy commented 3 weeks ago

Note /Users/... vs /users/...

You might try it without the C: as well?

lindaalvarez commented 3 weeks ago

I went ahead and tried both and no luck.

Screen Shot 2024-09-04 at 9 57 03 AM
lindaalvarez commented 3 weeks ago

so i tried to double check that my pathway exists and I keep getting false. @castower

Screen Shot 2024-09-04 at 10 12 34 AM Screen Shot 2024-09-04 at 10 13 03 AM
lecy commented 3 weeks ago

Here is some code to help you identify your current location (default working directory), navigate to other directories, create folders, and check which files and folders exist within each folder.

######################################
######################################     CURRENT FOLDER
######################################

getwd()
[1] "C:/Users/lecy/Documents"

dir()   # LIST FILES IN DIRECTORY

# [1] "AWS"                                                       
# [2] "AWS-NCCS-EFILE.csv"  
# [3] "bmf"
# [4] "2023-05-POL-ORGS-SCHED-A.csv"                              
# [5] "2023-05-POL-ORGS-SCHED-B.csv"                              
# [6] "2023-05-POL-ORGS-SCHED-D.csv"

######################################
######################################     BASIC NAVIGATION
######################################

# NOTE DIFFERENCE BETWEEEN FOLDERS AND FILES

setwd( "AWS-NCCS-EFILE.csv" )     # FILES HAVE EXTENSIONS

# > Error in setwd( "AWS-NCCS-EFILE.csv" ) : cannot change working directory

setwd( "AWS" )      # FOLDERS DO NOT

getwd()
# [1] "C:/Users/lecy/Documents/AWS"

setwd( ".." )     # RETURN TO PARENT FOLDER
getwd()
# [1] "C:/Users/lecy/Documents"

setwd( "bmf" )

getwd()
# [1] "C:/Users/lecy/Documents/bmf"

dir()
# [1] "BMF-2022-01-501CX-NONPROFIT-PX.csv" "BMF-2022-08-501CX-NONPROFIT-PX.csv"
# [3] "BMF-LABELED-TEMP.rds"               "BMF_TAX_EXEMPT_PURP.csv"           
# [5] "BMF_UNIFIED_V1.1.csv"               "BMF_UNIFIED_V1.2.csv"              

######################################
######################################     CREATE NEW FOLDERS
######################################

dir()
# [1] "BMF-2022-01-501CX-NONPROFIT-PX.csv" "BMF-2022-08-501CX-NONPROFIT-PX.csv"
# [3] "BMF-LABELED-TEMP.rds"               "BMF_TAX_EXEMPT_PURP.csv"           
# [5] "BMF_UNIFIED_V1.1.csv"               "BMF_UNIFIED_V1.2.csv"              

setwd( "TEST" )
# > Error in setwd( "TEST" ) : cannot change working directory

dir.create( "TEST" ) 
dir()

# [1] "BMF-2022-01-501CX-NONPROFIT-PX.csv" "BMF-2022-08-501CX-NONPROFIT-PX.csv"
# [3] "BMF-LABELED-TEMP.rds"               "BMF_TAX_EXEMPT_PURP.csv"           
# [5] "BMF_UNIFIED_V1.1.csv"               "BMF_UNIFIED_V1.2.csv"                           
# [7] "TEST"

setwd( "TEST" )

getwd()
# [1] "C:/Users/lecy/Documents/bmf/TEST"

dir()  # EMPTY FOLDER
# character(0)

######################################
######################################     RELATIVE NAVIGATION 
######################################

getwd()
# [1] "C:/Users/lecy/Documents/bmf/TEST"

setwd( "../.." )  # GO UP TWO LEVELS 
getwd()
# [1] "C:/Users/lecy/Documents"

setwd( "bmf/TEST" )  # GO DOWN TWO LEVELS (FOLDER IN A FOLDER)
getwd()
# [1] "C:/Users/lecy/Documents/bmf/TEST"
lindaalvarez commented 3 weeks ago

@castower I was able to move forward and now am in the part where I am trying to finish the R file with documenting the instructions. When I use the devtools::document() command I get a series of errors.

devtools::document() ℹ Updating montyhall documentation ℹ Loading montyhall Writing 'create_game.Rd' Warning message: ── Conflicts ─────────────────────────────────────────────────────────────────── montyhall conflicts ── ✖ change_door masks montyhall::change_door(). ✖ create_game masks montyhall::create_game(). ✖ open_goat_door masks montyhall::open_goat_door(). ✖ select_door masks montyhall::select_door(). ℹ Did you accidentally source a file rather than using load_all()? Run rm(list = c("change_door", "create_game", "open_goat_door", "select_door")) to remove the conflicts. Not quite sure how to move forward from this, I'm afraid that if I remove these words it will mess up the code of the game.

castower commented 3 weeks ago

Hello @lindaalvarez ,

A couple of things to check:

  1. Is your .R file stored in your montyhall/R folder?
  2. Is the formatting of the file the same as the template?
  3. Is your working directory set to montyhall?
lindaalvarez commented 3 weeks ago

I believe I have the file in the correct folder, I followed the instructions. I retraced my steps and started over but I did notice that whenever I run the devtools::document() command a new folder gets created with all of the error terms created. I don't know what to do there. @castower

Everything was working up until I started editing the r script to fill the instructions, after I filled them in is when I got those errors and that random folder.

Screen Shot 2024-09-04 at 6 09 02 PM Screen Shot 2024-09-04 at 6 10 19 PM
castower commented 3 weeks ago

@lindaalvarez

The output of getwd() before you run devtools::document() indicates that you're inside of the R subfolder of montyhall.

You'll need to change the directory to go up one folder level to the montyhall folder and then run the devtools::document() code.

castower commented 3 weeks ago

@lindaalvarez

You may have lingering files from the previous attempt at running document().

I would suggest deleting those files and then trying again.

lindaalvarez commented 3 weeks ago

Thank you so much for your help!

castower commented 3 weeks ago

You're welcome @lindaalvarez! Were you able to resolve your installation errors?

castower commented 3 weeks ago

@lindaalvarez ,

Your repo name is MontyHall3Doors vs MontyHall so you'll need to update the package name to install.

lindaalvarez commented 3 weeks ago

@castower As soon as I sent the message I saw the error, my apologies! I am currently waiting for the downloading the finish and hopefully finally be done!

castower commented 3 weeks ago

Great @lindaalvarez !

lindaalvarez commented 3 weeks ago

@castower I think I made an error when waiting for it to upload, not sure how to go from here

Screen Shot 2024-09-04 at 9 19 07 PM
lindaalvarez commented 3 weeks ago

I actually fixed the code and it is now running again @castower I've just been waiting for about 10 minutes for it to finish loading, I hope that is to be expected