Hello. I'm trying to adapt the package ?hexbin? to suit my needs. This is the first time I do this. I've read a bit through Hadley's ?R packages?, but now I'm pretty lost (from a workflow point of view). I am using RStudio and Hadley's devtools. So I forked the repo I want to adapt: https://github.com/grssnbchr/hexbin and cloned it using RStudio (I created a new project). What I basically want to do is adapt the package slightly and use the adapted source on my use case (an Rmd file in another location) - ideally, I would call the respective function (hexbin::grid.hexagons) in the Rmd and the source code of ?hexbin? would be called and debugged (just for understanding what the package ?hexbin? actually does in that case, I do not have to build it yet, or even publish it). What is the workflow for this? Also, I tried running devtools::check() and it already fails there: R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes" Platform: x86_64-pc-linux-gnu (64-bit)> devtools::check()Updating hexbin documentation Loading hexbin Creating a generic function for ?plot? from package ?graphics? in package ?hexbin? Creating a generic function for ?summary? from package ?base? in package ?hexbin? Setting env vars ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CFLAGS : -Wall -pedantic CXXFLAGS: -Wall -pedantic Building hexbin ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD build '/home/tgrossen/R/hexbin' --no-resave-data --no-manual * checking for file ?/home/tgrossen/R/hexbin/DESCRIPTION? ... OK * preparing ?hexbin?: * checking DESCRIPTION meta-information ... OK * cleaning src * installing the package to build vignettes * creating vignettes ... ERROR Error: processing vignette 'hexagon_binning.Rnw' failed with diagnostics: chunk 1 (label = comphexsq) Error in eval(expr, envir, enclos) : could not find function ?hexbin? Execution halted Error: Command failed (1) As you can see, I am very much lost. I googled for "adapt R package and debug" and so forth but couldn't find any tutorial or anything. Thanks, Timo
On 12/07/2016 7:28 AM, timo at timogrossenbacher.ch wrote:> Hello. > > I'm trying to adapt the package ?hexbin? to suit my needs. This is the first > time I do this. I've read a bit through Hadley's ?R packages?, but now I'm > pretty lost (from a workflow point of view). I am using RStudio and Hadley's > devtools. > > So I forked the repo I want to adapt: https://github.com/grssnbchr/hexbin and > cloned it using RStudio (I created a new project). What I basically want to do > is adapt the package slightly and use the adapted source on my use case (an Rmd > file in another location) - ideally, I would call the respective function > (hexbin::grid.hexagons) in the Rmd and the source code of ?hexbin? would be > called and debugged (just for understanding what the package ?hexbin? actually > does in that case, I do not have to build it yet, or even publish it). What is > the workflow for this?This is more of an R-devel question, so I've posted my followup there (as well as a private copy to you). The fact that you've forked the package shouldn't matter. You are working in RStudio, so the way to work with a package is: 1. Open the project consisting of your local package. 2. In the Build pane, click on "Build and Reload". What "Build and reload" does is to install the package from the source in the project, then restart R and load the installed package. Test your code in this new R session. If you're working on a vignette, you can open the vignette, and execute the code chunks one by one. If they all succeed in that context, they still might not when you run checks: it *won't* have your package loaded when it compiles a vignette. You need to put an explicit library(hexbin) in one of the code chunks. Duncan Murdoch> > Also, I tried running devtools::check() and it already fails there: > R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes" > > Platform: x86_64-pc-linux-gnu (64-bit) > >> devtools::check() > Updating hexbin documentation > Loading hexbin > Creating a generic function for ?plot? from package ?graphics? in package > ?hexbin? > Creating a generic function for ?summary? from package ?base? in package > ?hexbin? > Setting env vars > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > CFLAGS : -Wall -pedantic > CXXFLAGS: -Wall -pedantic > Building hexbin > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet > CMD build '/home/tgrossen/R/hexbin' --no-resave-data --no-manual > > * checking for file ?/home/tgrossen/R/hexbin/DESCRIPTION? ... OK > * preparing ?hexbin?: > * checking DESCRIPTION meta-information ... OK > * cleaning src > * installing the package to build vignettes > * creating vignettes ... ERROR > > Error: processing vignette 'hexagon_binning.Rnw' failed with diagnostics: > chunk 1 (label = comphexsq) > Error in eval(expr, envir, enclos) : could not find function ?hexbin? > Execution halted > Error: Command failed (1) > > As you can see, I am very much lost. I googled for "adapt R package and debug" > and so forth but couldn't find any tutorial or anything. > > Thanks, > > Timo > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Timo, A couple of thoughts ... First, could you achieve what you want by simply modifying (your own copies of) a function or two from the hexbin package, without having to modify the entire package? This might give you fewer tripping points. Second, right after you forked the package (so that you have a copy on your own space on GitHub) and before you modified anything ... were you able to install and use the package from there successfully? library("devtools") devtools::install_github("grssnbchr/hexbin") library(hexbin) Jean On Tue, Jul 12, 2016 at 6:28 AM, <timo at timogrossenbacher.ch> wrote:> Hello. > > I'm trying to adapt the package ?hexbin? to suit my needs. This is the > first > time I do this. I've read a bit through Hadley's ?R packages?, but now I'm > pretty lost (from a workflow point of view). I am using RStudio and > Hadley's > devtools. > > So I forked the repo I want to adapt: https://github.com/grssnbchr/hexbin > and > cloned it using RStudio (I created a new project). What I basically want > to do > is adapt the package slightly and use the adapted source on my use case > (an Rmd > file in another location) - ideally, I would call the respective function > (hexbin::grid.hexagons) in the Rmd and the source code of ?hexbin? would be > called and debugged (just for understanding what the package ?hexbin? > actually > does in that case, I do not have to build it yet, or even publish it). > What is > the workflow for this? > > Also, I tried running devtools::check() and it already fails there: > R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes" > > Platform: x86_64-pc-linux-gnu (64-bit) > > > devtools::check() > Updating hexbin documentation > Loading hexbin > Creating a generic function for ?plot? from package ?graphics? in package > ?hexbin? > Creating a generic function for ?summary? from package ?base? in package > ?hexbin? > Setting env vars > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > CFLAGS : -Wall -pedantic > CXXFLAGS: -Wall -pedantic > Building hexbin > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore > --quiet > CMD build '/home/tgrossen/R/hexbin' --no-resave-data --no-manual > > * checking for file ?/home/tgrossen/R/hexbin/DESCRIPTION? ... OK > * preparing ?hexbin?: > * checking DESCRIPTION meta-information ... OK > * cleaning src > * installing the package to build vignettes > * creating vignettes ... ERROR > > Error: processing vignette 'hexagon_binning.Rnw' failed with diagnostics: > chunk 1 (label = comphexsq) > Error in eval(expr, envir, enclos) : could not find function ?hexbin? > Execution halted > Error: Command failed (1) > > As you can see, I am very much lost. I googled for "adapt R package and > debug" > and so forth but couldn't find any tutorial or anything. > > Thanks, > > Timo > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
On Jul 13, 2016 15:02, Adams, Jean wrote:> > Timo, > > A couple of thoughts ... > > First, could you achieve what you want by simply modifying (your own copies > of) a function or two from the hexbin package, without having to modify the > entire package? This might give you fewer tripping points. >Good point, how would I do this? Just copy-paste the original source and redeclare/overwrite the functions within my use case script?> Second, right after you forked the package (so that you have a copy on your > own space on GitHub) and before you modified anything ... were you able to > install and use the package from there successfully? >> >> library("devtools") >> devtools::install_github("grssnbchr/hexbin") >> library(hexbin) >I basically forked and cloned it, and then ran devtools::check() without modifying anything, and it threw an error when compiling the vignette. Also building fails this way. It seems to work fine when installed with devtools::install_github(). Weird, I know. Anyhow, the question with (modifying and) debugging a (forked) package in order to understand how it works still stands, maybe there's something in Hadley's book that I oversaw. Timo> > Jean > > On Tue, Jul 12, 2016 at 6:28 AM, <timo at timogrossenbacher.ch> wrote: >> >> Hello. >> >> I'm trying to adapt the package ?hexbin? to suit my needs. This is the first >> time I do this. I've read a bit through Hadley's ?R packages?, but now I'm >> pretty lost (from a workflow point of view). I am using RStudio and Hadley's >> devtools. >> >> So I forked the repo I want to adapt: https://github.com/grssnbchr/hexbin >> and >> cloned it using RStudio (I created a new project). What I basically want to >> do >> is adapt the package slightly and use the adapted source on my use case (an >> Rmd >> file in another location) - ideally, I would call the respective function >> (hexbin::grid.hexagons) in the Rmd and the source code of ?hexbin? would be >> called and debugged (just for understanding what the package ?hexbin? >> actually >> does in that case, I do not have to build it yet, or even publish it). What >> is >> the workflow for this? >> >> Also, I tried running devtools::check() and it already fails there: >> R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes" >> >> Platform: x86_64-pc-linux-gnu (64-bit) >> >> > devtools::check() >> Updating hexbin documentation >> Loading hexbin >> Creating a generic function for ?plot? from package ?graphics? in package >> ?hexbin? >> Creating a generic function for ?summary? from package ?base? in package >> ?hexbin? >> Setting env vars >> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> CFLAGS : -Wall -pedantic >> CXXFLAGS: -Wall -pedantic >> Building hexbin >> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >> '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet >> CMD build '/home/tgrossen/R/hexbin' --no-resave-data --no-manual >> >> * checking for file ?/home/tgrossen/R/hexbin/DESCRIPTION? ... OK >> * preparing ?hexbin?: >> * checking DESCRIPTION meta-information ... OK >> * cleaning src >> * installing the package to build vignettes >> * creating vignettes ... ERROR >> >> Error: processing vignette 'hexagon_binning.Rnw' failed with diagnostics: >> chunk 1 (label = comphexsq) >> Error in eval(expr, envir, enclos) : could not find function ?hexbin? >> Execution halted >> Error: Command failed (1) >> >> As you can see, I am very much lost. I googled for "adapt R package and >> debug" >> and so forth but couldn't find any tutorial or anything. >> >> Thanks, >> >> Timo >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > >