How to read source code of a R package that is not on CRAN and edit the source and upgrade the package to R version 4

Hi,
I have a package that was developed by one of my colleague and she left the organization. The package was developed on R version 3.3.0 and it works fine with R 3.x.x. However when I try to install it in R 4.1.0, I get below error.
Error: package or namespace load failed for "xxxx":
package "xxxx" was installed before R 4.0.0: please reinstall it

I tried multiple ways that was suggested by few forums, but I couldn't install.
My Needs:

  1. I have the zip file (the file used for installing the package) for the package and I need to view the entire script for the package. How do I do that?

  2. What edits should I do to enable this package to work on R 4.1.0?

Any help would be appreciated. Thank you in advance

At least this part doesn't seem to be related to the package code, this is only asking you to update the rest of your packages. After a mayor R update you have to update all your packages

update.packages(checkBuilt =TRUE)

Thanks for your suggestion. Do you mean that I have to update all the packages that are installed in my system?

I actually tried installing all the dependent packages and then installing this "xxxx" package. But still that didnt work.

Also, do you have any idea of how to get the source code for a package?

Yes, you always have to do this after a major R update.

You have to update using checkBuilt = TRUE since they might be in the latest version but compiled under an older R version so you have to force reinstallation.

Hi andresrcs, I tried that as well, but didnt work. I was able to get the source file from the one who created the package. Can you please tell me how can I build a new version of that package in new version of R?

You can learn from this book how to work with developing packages in general.
R Packages (r-pkgs.org)

Hi Nirgrahamuk,

I went through this book. It explains about how to create a package. I did try to create a package. But it was not mentioned anything about how to rebuild and reload.

Chapter 5 Fundamental development workflows | R Packages (r-pkgs.org)
?

5.4 Test drive with load_all()

The load_all() function is arguably the most important part of the devtools workflow.

# with devtools attached and
# working directory set to top-level of your source package ...

load_all()

# ... now experiment with the functions in your package

load_all() is the key step in this “lather, rinse, repeat” cycle of package development:

  1. Tweak a function definition.
  2. load_all()
  3. Try out the change by running a small example or some tests.

When you’re new to package development or to devtools, it’s easy to overlook the importance of load_all() and fall into some awkward habits from a data analysis workflow.

Thank you nirgramuk. Maybe my question is dumb. The link you shared explains load_all when the r package is opened.
I have the source file (R folder, description, namespace and others) in a folder in my desktop. My question is, how do I open this folder as a package in R so that I can make edits in functions/package version if required, then run check() and load_all() and then create the zip file.

@nirgrahamuk , I just figured out that i just give "Create_package("give teh path of teh folder that has package") and when I open it asks me if it needs to overwrite "description", "namesspace" ect.. I chose not to change. Then I was able to access the package folder. after making changes, i gave load_all, check() and will convert to binary file to share with others. This worked. Is there any other method?

Just to have a clearer picture of your problem, can you please be more specific about this? What specific error message are you getting now?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.