We're starting to compile a list of GIS commands in R that have the same functionality as common task in ArcGIS.
Turns out you can debug anonymous functions! Where you want to break the code, simply insert a .doTrace(browser()) function. If you want to debug on the line "x = bar()", below, the syntax would look like this:
lapply( foo, function{ . . . { .doTrace(browser()) x = bar() } . . . } ) To work with git in R studio, first exit out of R Studio (and R for that matter) and then install Git on your computer. Reasonable directions are available in the R Packages ebook section on Git. Once you have Git installed, open R Studio.
IMPORTANT: You may have to enter the location of the Git.exe file (in the \bin folder of the Git installation) in R Studio (Tools->Global Options->Git/SVN) and maybe even restart R Studio before Git will play nicely with R Studio. Be sure to also set up a SSH RSA Key in R Studio and enter the key at GitHub, as described in the R Packages ebook section on Git. R Studio uses this in the place of your password to access GitHub Now you should be able to choose from the Project dropdown in the upper right corner of R Studio "New Project->Version Control->Git and enter the GitHub URL for the Package. Be sure to enter the local directory where you want the source code to go. Packages URLs include: gangsta: https://github.com/FluvialLandscapeLab/gangsta.git datapuppy: https://github.com/FluvialLandscapeLab/datapuppy.git R Studio should pull the package source from GitHub for you. Seems like this should be easier, but if you create a new RStudio project with the "version control" option, the project created is just a project, not a package. Perhaps there is a simple way in RStudio to create a package from a project, but I can't find it.
So, we can create a Package, and then add version control. This assumes you have followed all of the installation instructions in Hadley Wickam's e-book R packages. So, in RStudio, from the project drop down in the upper right corner, choose "new project," "new directory," "R Package," and then enter the relevant information. Be sure to click the "create a git repository" checkbox before finalizing the Package!! If the "create a git repository" checkbox is not present, git it probably not installed on your computer. See Hadley's e-book for that. . IMPORTANT: You may have to enter the location of the Git.exe file (in the \bin folder of the Git installation) in R Studio (Tools->Global Options->Git/SVN) and maybe even restart R Studio before Git will play nicely with R Studio. Once R Studio is running with Git (you can tell this is working if there is a "Git" tab in the upper right pane of R Studio when you have your newly created Package open), choose "Tools->Shell" and be sure the command prompt is displaying your Package root directory. From here, follow these lovely instructions from our friends at GitHub on how to push the new Package up to the remote repository on the GitHub website. Once you have pushed your package to GitHub, close R, back up your package by renaming the package directory to <packagename>.bak (e.g. if your package is called "mypackage", then find the R studio directory called "mypackage" -- which should include subdirectories including .git, .Rproj.user, man, and R -- and rename the directory "mypackage.bak"). Then follow the instructions for "Pulling an R package from GitHub." This will recreate the <packagename> (e.g., "mypackage") directory from the information you pushed to GitHub, which allows you to test that all of the package information was pushed to GitHub correctly. Once you have worked with the new <packagename> directory for a few days are your are sure all is well, you can delete the .bak backup directory. |
AuthorFluvial Landscape Lab members. ArchivesCategories |