osefind.blogg.se

Upload r package to github
Upload r package to github








upload r package to github

Usethis should automatically open the R project for the package you just made! If you haven’t installed usethis before, you can use the following code: install.packages("usethis")Ĭreating a package template: usethis::create_package(path = "packagename") Usethis package to set up a minimal package.

upload r package to github

Situating your script in an R package means that you’ll have access to a lot of helpful tools to tell GitHub Actions, the server you’ll eventually run the script on, how to set up an R session like yours. If you haven’t worked with the internals of an R package before, this step might feel intimidating, but the R community has put together a few tools to make your experience as pleasant as possible! While you’re putting together your script, keep an eye on what R packages you’re making use of! Make sure you’re calling library(packagename) for each package that gets used in your script. You’ll only need to save your results to file if you’d eventually like to commit them to the GitHub repository you’re working inside of. I decided to make a folder called data-raw to save my results into.

upload r package to github

Your file path should be relative to your current working directory. Save(x, file = paste0("data-raw/data_", make.names(Sys.time()), ".Rda"))Īs I write this, the output of that file argument looks like: "data-raw/data_X2020.12.27.08.26.06.Rda" Then, I save x with a filename that gives the time that I generated the numbers. First, I draw ten numbers from the standard normal, assigning them to an object x. I’ll be using a relatively simple script in this example. I imagine most uses for this type of setup will include querying some sort of livestreamed data. Please feel free to file PRs or share other approaches. No worries if not.ĭisclaimer: I don’t know what I’m doing! There are likely better ways of the doing the thing I’m about to show you. Host your package in a GitHub repositoryįor an example of what the final product could look like, I’ve made a publicly-availableĮxample repository with everything you’ll need to get going! If you’re familiar with Git, forking this repository rather than setting yours up from scratch might save you some time.I made many mistakes on the way to combining the solutions to these problems effectively, and thought it would be worth a short write-up of the approach I landed on! The solution looks something like this: saving things: File paths on drives that aren’t, like, mine? Yikes.setting up R: It’s goofy enough to tackle on your own computer! Doing it remotely can get tricky.running computations regularly: CRON, task schedulers, servers… out of my element.This problem gets at the intersection of a few things that are often hard (for me) to get right: I have an R script that queries data from a server that only supplies live data, and I want to run it on a regular basis, saving the results with each run.










Upload r package to github