I know this has probably been answered a million times, but nothing I seem to do works.
I am running a function that I created, the function is stored in a R script, and I am sourcing and running the function in Rmarkdown.
example <- function(){
EP <- read_excel("filepath")
EP <- Project_EP_Rename(EP)
}
Error in MyPackage::Project_EP_Rename(EP) : object 'EP' not found.
I have tested by putting print(exists(EP)) right in between these lines and that printed TRUE. I am calling library(MyPackage) in the RMarkdown, and this script is located in a subdirectory of the Project file, so I thought that maybe the package wasn't being called. I check using print("MyPackage" %in% .packages()), reran and that came but true. I even tried changing the code to
EP <- MyPackage::Project_EP_Rename(EP)
That still didn't work. I ended up importing the file in the rmarkdown, and then running it through the function example(EP), and changed the code to this, and that worked.
example <- function(datafile){
EP <- datafile
EP <- Project_EP_Rename(EP)
}
Why exactly is this happening? I am very confused.