souce code and reusing it

ledzep

Point Mass at Zero
#22
The build is coming nicely. Few questions..

1) After I build and reload the package, R sessions starts and library is loaded. How do I see the list of functions present in the current library.
2) After I build the source package, it generates the .tar.gz files. Where is the.tar.gz file located?
3) The purpose of the package is store my functions so that I can use them anytime I want. If I want to run it off github directly, then what files do I need to transfer to github?
4) Most importantly, how do I transfer the files to github?

Thank you.
 

trinker

ggplot2orBust
#23
1) After I build and reload the package, R sessions starts and library is loaded. How do I see the list of functions present in the current library.
Dason and I are working on a packae called pacman that does exactly this. Here's the snipet of code from it that allows you to do this (I used ggplot2 as an example).

Code:
unclass(lsf.str(envir = asNamespace("ggplot2"), all = T))
2) After I build the source package, it generates the .tar.gz files. Where is the.tar.gz file located?
Should be in the main folder of your repo

3) The purpose of the package is store my functions so that I can use them anytime I want. If I want to run it off github directly, then what files do I need to transfer to github?
4) Most importantly, how do I transfer the files to github?
The whole shebang. Github really is a repo in the clouds. It' basically the same thing as dropbox only cooler. To transfer the files to git hub you need to use the push and pull command in the Git tab. The video I made above shows this for bitbucket but works basically the same way. First you create the repo on github. Next use the url in Rstudio to create the "link" between your machine and the cloud. Then dump all files of the package in that folder that will be created by R studio. Then push it to guthub.

To install something like:

Code:
library(devtools)
install_github("cool_package_by_zep", "ledzeptalkstats")
PS as you get a little more comfortable I'd really recommend learning roxygen2 for documentation (but that's more if you plan on sharing the package, still it's a good habit to document IMO). I learned this the hard way (document as you go tyler :)).
 
Last edited by a moderator:

Dason

Ambassador to the humans
#24
The build is coming nicely. Few questions..

1) After I build and reload the package, R sessions starts and library is loaded. How do I see the list of functions present in the current library.
I take it you're talking about RStudio's "Build & Reload" button? I don't typically use that and opt to use devtools functions instead. If you want to install a package and if your working directory is set to the top level of where that package is stored then you can just use install() from devtools to install the package directly. I don't quite get what your second question is asking.
2) After I build the source package, it generates the .tar.gz files. Where is the.tar.gz file located?
If you're talking about the "Build & Reload" button in RStudio then it doesn't actually keep the .tar.gz file around for you. It would probably more appropriately be labeled "Build, install, reload, clean up" but that's a bit too long. You can use the "Build Source Package" or "Build Binary Package" from the drop down menu if you want to build a package and get a file you can actually use to install the package manually on a different system.
3) The purpose of the package is store my functions so that I can use them anytime I want. If I want to run it off github directly, then what files do I need to transfer to github?
Put the entire package on github. Here is an example of everything you would on there: https://github.com/Dasonk/musicmakeR
You wouldn't need the inst or data folders though so don't worry if you don't have those.
4) Most importantly, how do I transfer the files to github?
Do you have git installed on your computer? I know you have a github account but I don't know if you actually have git installed yet so that's step one.
 

trinker

ggplot2orBust
#25
Funny we answered at almost the same time with a bit of overlap. On a windows machine though RStudio will actually build the .tar.gz if you do build source package (or the zip if you do the build binary package) but build by itesly doesn't put it any where (I think this is what Dason is saying).

Dason said:
Do you have git installed on your computer? I know you have a github account but I don't know if you actually have git installed yet so that's step one.
@zep what OS are you using? If Windows this is the page you want I think: http://git-scm.com/download/win