I am using a package from R and it has a bug, but I don't know how to fix this permanently.
By using trace(), I can fix this every run, but I need to fix this permanently.
p.s. it's just a typo, so I just need to change a letter ("A" to "a") and I know which line I should modify.
Another way that I was trying is to replace the original function file with the updated function file. I do have a fixed function (XXX.r), but I don't have a new package to install. I tried to find where the original function code was, but it seems like it's not visible as far as I understand. ( I might be missing something ).
Any helps would be appreciated.
Related
I'm trying to modify a CRAN package. From what I understand, they use a C interface using .Call().
So I made changes in the C code (can't do it anywhere else since it's in a loop) but I need to ask the user to input an integer.
I read the "Writing R extension" doc and found out that you need to use specific functions as Rprintf() instead of printf().
But I can't seem to find a way to replace scanf() so how can we ask for an input?
And finally is Rprintf() supposed to print in the R console because it is what I'd want but I can't find where it is printed?
Edit:
I'm unable to try it right now but it may seem that using capture_output() may work to get the Rprintf() output. Therefore the only remaining issue would be the scanf() :)
Thanks a lot!
I am having a problem with my read_csv. I have used this function with no problem but the path/directory I am using is a little different than normal and I can't figure it out by myself.
This is the code I have been using:
X2022_03_08_habit_and_OCD_clinical <- read_csv("Box/OCD: Habit or Learning?/experiment/data/raw/survey-data/2022-03-08_habit-and-OCD_clinical.csv")
I have tired tweaking this by not using the first two arguments with no luck. Has anyone used Box in a path before (Box is in my finder, like desktop would be). I also tried updating r for that first error code but maybe it didn't take, I am not sure how to update again.
Here is the error code I have been receiving:Error Message
I would appreciate any help and I apologize if there is a simple answer I have been missing!
I am trying to fix an issue in an R project (that I'm not too familiar with). The test script that is executed when running "Test Package" in R-Studio uses a variable, let's call it x. From the result of the test I can tell that the data assigned to this variable is outdated and I want to update it.
Problem is, I just cannot figure out where this variable is actually defined. I have used grep for the entire source code of the package, and I only find the instance from the test script but no declaration. It is not defined in the script itself nor anywhere else in the source code.
When I just load the package, the variable is not defined. Somehow it is defined however when running the test, because only when I change the name in the test script into some dummy I get the error that it isn't defined.
Is there a specific place where I could look, or may be a simple trick how I could figure out where and how the variable is defined?
Thanks
Edit: the actual variable name is a bit complicated, it is not x
The find in files option in RStudio may help.
You can search through multiple files within a folder.
If you get too many matches to sort through (I'm really hoping your variable is not actually called x!), you can try using a regular expression.
enter image description here
Follow the pictures and you could solve the problem.
I am using the isoriX package in R and would like to update part of the source code. When I try to run it without making any changes yet, R doesn't seem to recognise any function preceded by a dot.
Am I missing any packages that should be installed in order to allow me to use those kind of functions or to update the source code?
The code I am trying to apply is quite long, but the bit R struggle with is the following function:
.complete_args()
Any ideas? Thank you!
The isoriX:::.complete_args() call worked.
You can access unexported function with ::: and in my case isoriX:::.complete_args() worked well.
I am working with the earlywarnings package, and would like to edit one of the functions written in the qda_ews function. I could do fix(...) but the function I would like to edit is for some reason not listed when I use fix.
The function is called generic_RShiny. Here is the link to the github (https://github.com/earlywarningtoolbox/earlywarnings-R/blob/master/earlywarnings/R/qda_ews.R).
How can I access the entire qda_ews.R code to make the changes I need?
once the library is loaded, use
trace(name_of_function, edit = T)
but beware that the function will be modified permanently (until of course you reinstall the package)