Open mtwelker opened 3 years ago
Did you load the import package?_
Hello Michelle @mtwelker,
I was able to replicate your error on my computer.
Try the following steps:
Restart your R session and clear all output.
Update the renv:
renv::restore()
#select y
If you get a pop-up on the top of the screen to install any packages, select install.
Next, highlight the libraries listed and run the code.
These are the libraries:
library( dplyr )
library( here )
library( knitr )
library( pander )
If you get a pop-up to install any packages, click install.
Now run the code.
Let me know if you have any further difficulties!
That did the trick! Thank you!
Prof. Stowers-
I completed the above steps after updating R and RStudio to the most recent versions and am still getting the same error messages mentioned above:
load necessary functions ----
note: all of these are R objects that will be used throughout this .rmd file
import::here("build_year",
- "RELEVANT_FILES",
- "obtain_crosswalk",
- "create_final_metadata_file",
notice the use of here::here() that points to the .R file
where all these R objects are created
- .from = here::here("labs/utilities.R"),
- .character_only = TRUE) Error in loadNamespace(name) : there is no package called ‘C:/Users/danic/OneDrive/Desktop/CPP528/labs/wk03/labs/utilities.R’
for each relevant file, run the build_year() function ----
note: this populates the data/rodeo/ directory with clean files
for (relevant_file in RELEVANT_FILES) {
- print(paste0("Starting on ", relevant_file[["year"]]))
- build_year(fn1 = relevant_file[["fullcount"]],
- fn2 = relevant_file[["sample"]],
- year = relevant_file[["year"]])
- if (relevant_file[["year"]] < 2010) {
- print("Finished! Moving onto the next decade.")
- } else {
- print("Finished! No more data to parse.")
- }
- } Error in RELEVANT_FILES : object 'RELEVANT_FILES' not found
load the crosswalk ----
note: this stores a copy in the data/raw/ directory
cw <- obtain_crosswalk() Error in obtain_crosswalk() : could not find function "obtain_crosswalk"
create the final meta data file ----
note: this stores a copy within the data/rodeo/ directory
create_final_metadata_file(file_names = RELEVANT_FILES,
- crosswalk = cw) Error in create_final_metadata_file(file_names = RELEVANT_FILES, crosswalk = cw) : could not find function "create_final_metadata_file"
end of script
Hello Danica @DMBurwell,
.from = here::here("labs/utilities.R")
should be
.from = here::here("labs/wk03/utilities.R")
The file path needs to match the location of your utilities.R file.
Let me know if you run into any other issues!
I updated this and am still getting the same error messages
@DMBurwell have you installed the import package?
I am having a similar issue. I followed the instructions here but still get errors running the project_data_steps.R code.
I run the utilities.R file successfully with the the here() library outputting:
> library( here )
here() starts at /Users/bbmoreno
The first error I get after running the project_data_utilities.R file:
> import::here("build_year",
+ "RELEVANT_FILES",
+ "obtain_crosswalk",
+ "create_final_metadata_file",
+ # notice the use of here::here() that points to the .R file
+ # where all these R objects are created
+ .from = here::here("cpp528/cpp-528-fall-2021-group-06/labs/wk03/utilities.R"),
+ .character_only = TRUE)
Error: Cannot assign name to different value in the given environment. Name already in use.
Then, when I run the first function:
for (relevant_file in RELEVANT_FILES) {
+ print(paste0("Starting on ", relevant_file[["year"]]))
+ build_year(fn1 = relevant_file[["fullcount"]],
+ fn2 = relevant_file[["sample"]],
+ year = relevant_file[["year"]])
+ if (relevant_file[["year"]] < 2010) {
+ print("Finished! Moving onto the next decade.")
+ } else {
+ print("Finished! No more data to parse.")
+ }
}
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt"):
And showing the traceback:
Error in file(file, "rt") : cannot open the connection
5. file(file, "rt")
4. read.table(file = file, header = header, sep = sep, quote = quote,
dec = dec, fill = fill, comment.char = comment.char, ...)
3. read.csv(here::here(path), colClasses = "character")
2. tidy_up_data(fn1)
1. build_year(fn1 = relevant_file[["fullcount"]], fn2 = relevant_file[["sample"]],
year = relevant_file[["year"]])
Each subsequent function also has issues related to "cannot open the function" and/or "object 'x' not found".
I am assuming this is a file source issue? I have attempted using a different file path but it is also unsuccessful. I assume it requires the full path since my here() begins at bbmoreno/, but shortening the path is also unsuccessful. I have the utilities.R and project_data_steps.R files in labs/wk03 folder. Is there anything I should have in there at this time? I am wondering if I should also have my data in this folder.
Thanks for any and all help!
Hello @bbmoren2,
If you notice, your here() package is starting at the user level of your computer. You must be inside of your repository's project for the code to work.
I would suggest re-opening your .Rproject file to ensure that here() starts in that folder.
I figured it was related to that, thank you for clarifying!
Brittany
Hi again, @castower. 😬
I successfully navigated to the correct path through my .Rproject file but am receiving the same errors when I run the for() function:
for (relevant_file in RELEVANT_FILES) {
+ print(paste0("Starting on ", relevant_file[["year"]]))
+ build_year(fn1 = relevant_file[["fullcount"]],
+ fn2 = relevant_file[["sample"]],
+ year = relevant_file[["year"]])
+ if (relevant_file[["year"]] < 2010) {
+ print("Finished! Moving onto the next decade.")
+ } else {
+ print("Finished! No more data to parse.")
+ }
}
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt"):
And showing the traceback:
Error in file(file, "rt") : cannot open the connection
5. file(file, "rt")
4. read.table(file = file, header = header, sep = sep, quote = quote,
dec = dec, fill = fill, comment.char = comment.char, ...)
3. read.csv(here::here(path), colClasses = "character")
2. tidy_up_data(fn1)
1. build_year(fn1 = relevant_file[["fullcount"]], fn2 = relevant_file[["sample"]],
year = relevant_file[["year"]])
Is there another place I should be adding the correct directory or file path?
Thank you!
Hello @bbmoren2 ,
Do you have the ltdb files stored in your data/raw folder?
Nope 😅 Thank you, @castower!
Prof. Stowers, On the first step of Lab 03, I'm getting errors when I try to run "project_data_steps.R":
I think it can't find the utilities in the utilities.R file, even though they're in the same directory. And I believe I'm in the right directory, because it said:
and that's where the utilities.R file is with those functions that errored out:
Am I missing something? Is there something else I need to run first? Thanks for any help you can offer!