Re: [R-pkg-devel] How do I enable to show data in inst/extdata in data() || lazy load

2022-12-19 Thread Sanjeev Sariya
Hi,
thank you for the reply.

Do you need this to be a file? Could it be a pre-parsed R object
instead?


I need to provide an external data/file in the R package. This has come as
a request from F1000 journal editors.

One way to solve this could be to write a script that imports the file
from inst/extdata using the facilities provided by your package and put
it in a file under data/, then document the resulting object.


What do you call this step? How do I do this?
I thought to loading the file as lazyload, .onload package something?

Best,
--
Sanjeev M




On Tue, Dec 20, 2022 at 1:55 AM Ivan Krylov  wrote:

> On Mon, 19 Dec 2022 20:59:27 +0530
> Sanjeev Sariya  wrote:
>
> > ... I have created a .Rd file.
> > I'm interested in listing this file in data() ...
>
> My understanding is that data() is for R-level objects, and so is
> help(), most likely.
>
> One way to solve this could be to write a script that imports the file
> from inst/extdata using the facilities provided by your package and put
> it in a file under data/, then document the resulting object. I think
> that if you build your package with --no-resave-data, it will remain an
> R script that will be run during the data() call. (By default, your R
> script will be run during R CMD build and its output will be packaged
> into a gzip-compressed RData file.)
>
> This might go against the guidance at
> ,
> which says:
>
> >> R code should be if possible “self-sufficient” and not make use of
> >> extra functionality provided by the package, so that the data file
> >> can also be used without having to load the package or its namespace
>
> Do you need this to be a file? Could it be a pre-parsed R object
> instead?
>
> --
> Best regards,
> Ivan
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] How do I enable to show data in inst/extdata in data() || lazy load

2022-12-19 Thread Ivan Krylov
On Mon, 19 Dec 2022 20:59:27 +0530
Sanjeev Sariya  wrote:

> ... I have created a .Rd file.
> I'm interested in listing this file in data() ...

My understanding is that data() is for R-level objects, and so is
help(), most likely.

One way to solve this could be to write a script that imports the file
from inst/extdata using the facilities provided by your package and put
it in a file under data/, then document the resulting object. I think
that if you build your package with --no-resave-data, it will remain an
R script that will be run during the data() call. (By default, your R
script will be run during R CMD build and its output will be packaged
into a gzip-compressed RData file.)

This might go against the guidance at
,
which says:

>> R code should be if possible “self-sufficient” and not make use of
>> extra functionality provided by the package, so that the data file
>> can also be used without having to load the package or its namespace

Do you need this to be a file? Could it be a pre-parsed R object
instead?

-- 
Best regards,
Ivan

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] NOTE about use of `:::`

2022-12-19 Thread David Kepplinger
I think I will go with the suggestion of creating a new empty environment,
adding only the argument parsing function. Moreover I will use the same
name as the user-facing function that's being invoked,  i.e.,

foo <- function(...) {
   call <- match.call(expand.dots = TRUE)
   call[[1]] <- quote(parse_args)
   envir <- new.env(parent = parent.frame())
   envir$foo <- parse_args

   eval(call, envir)
}

This way a trace-back shows the function the user expects, without having
to export the parsing function or duplicate the code in the user-facing
functions.

Thanks again everyone for the suggestions.

All the best,
David


On Thu, Dec 15, 2022 at 4:39 AM Duncan Murdoch 
wrote:

> If you want the name of the function to appear, then you can put the
> function in an environment whose parent is where most of the evaluation
> should take place.  For example,
>
> f <- function(...) {
>call <- match.call(expand.dots = TRUE)
>call[[1]] <- quote(parse_args)
>envir <- new.env(parent = parent.frame())
>envir$parse_args <- parse_args
>
>eval(call, envir)
> }
>
> parse_args <- function(...) {
>cat("args were ", names(list(...)), "\n")
>stop("Error in parse_args")
> }
>
> f(a = 1, b = 2)
> #> args were  a b
> #> Error in parse_args(a = 1, b = 2): Error in parse_args
>
> Duncan Murdoch
>
>
> On 14/12/2022 8:35 p.m., David Kepplinger wrote:
> > Thank you both for the suggestions. I would prefer a clean stack trace in
> > case of errors as input errors are caught by this function and hence
> users
> > might very well see errors emitted from it. It seems more informative to
> me
> > if the error message would say "Error in .parse_args…" than "Error in
> > new.env(…". But since this solution was suggested by both of you it is
> > likely that CRAN too would demand this or a similar approach instead of
> > using `:::`. I know `:::` is expansive, but the computations that follow
> > are typically at least a few minutes so anything that takes less than a
> few
> > seconds won't be noticeable.
> >
> > I also thought about using `...` before, but then the signature of the
> > user-facing functions would be incomplete and IDEs won't be able to
> provide
> > suggestions.
> >
> > Thanks for the help!
> >
> > -- David
> >
> > On Wed, Dec 14, 2022 at 7:11 PM Simon Urbanek <
> simon.urba...@r-project.org>
> > wrote:
> >
> >> David,
> >>
> >> why not
> >>
> >> call[[1]] <- parse_args
> >>
> >> The assignment is evaluated in your namespace so that makes sure the
> call
> >> is that of your function. The only downside I see is that in a stack
> trace
> >> you'll see the definition instead of the name.
> >> Or possibly
> >>
> >> do.call(parse_args, as.list(call[-1]))
> >>
> >> Cheers,
> >> Simon
> >>
> >> PS: Note that ::: is expensive - it probably doesn't matter here, but
> >> would in repeatedly called functions.
> >>
> >>
> >>> On 15/12/2022, at 12:19 PM, David Kepplinger <
> david.kepplin...@gmail.com>
> >> wrote:
> >>>
> >>> Dear List,
> >>>
> >>> I am working on updating the pense package and refactored some of the
> >>> methods. I have several functions which take the same arguments, hence
> >> I'm
> >>> sending all these arguments to an internal function, called
> >> `parse_args()`.
> >>> Since I want to evaluate the arguments in the caller's environment, I'm
> >>> using the following code
> >>>
> >>>   call <- match.call(expand.dots = TRUE)
> >>>   call[[1]] <- quote(pense:::parse_args)
> >>>   args <- eval.parent(call)
> >>>
> >>> Of course, R CMD CHECK complains about the use of `:::`, as it's almost
> >>> never needed. I think the above usage would fall into that area of
> >>> "almost", but I'm not sure if (a) there's a better approach and (b) the
> >>> CRAN team would agree with me. I would have to test (b) by submitting
> and
> >>> working with the CRAN team, but I wanted to ask the list first to see
> if
> >>> I'm missing something obvious. I don't want to export the function
> >>> parse_args() as it's not useful for a user, and the use is truly
> >> internal.
> >>>
> >>> Thanks and all the best,
> >>> David
> >>>
> >>>[[alternative HTML version deleted]]
> >>>
> >>> __
> >>> R-package-devel@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>>
> >>
> >>
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] How do I enable to show data in inst/extdata in data() || lazy load

2022-12-19 Thread Sanjeev Sariya
Hi there,

I've added data in the inst/extdata folder, for which I have created a .Rd
file.
I'm interested in listing this file in data() as other data/objects are
being shown.
Link for package github:
https://github.com/sariya/GARCOM/tree/new_test_hello

best
--
Sanjeev M

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] how to add .Rd in man folder for inst/ext file?

2022-12-19 Thread Sanjeev Sariya
Thank you
--
Sanjeev M




On Mon, Dec 19, 2022 at 7:53 PM Sarah Goslee  wrote:

> Hi,
>
> Well, at the most basic, you create an appropriately-named and
> formatted text file in the man directory. The Writing R Extensions
> manual is full of information:
> https://cran.r-project.org/doc/manuals/R-exts.html
>
> Roxygen is an alternative approach to creating the Rd files yourself.
> https://cran.r-project.org/web/packages/roxygen2/vignettes/roxygen2.html
>
> The package.skeleton() function is a helper for the do it yourself
> approach.
>
> Sarah
>
> On Mon, Dec 19, 2022 at 9:17 AM Sanjeev Sariya 
> wrote:
> >
> > Hi devel team,
> >
> > I have recently added one file in the inst/extdata folder.
> >
> > I'd like to add details about it in the man folder by creating a .Rd file
> > for the respective file.
> >
> > I created .Rd files for other datasets long time back, however, I do not
> > remember the steps now. Their skeleton looks like the attached file.
> >
> > I am using conda environment (not R studios)
> > Kindly guide me further.
> >  best
> >
> > --
> > Sanjeev M
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.sarahgoslee.com
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] how to add .Rd in man folder for inst/ext file?

2022-12-19 Thread Sarah Goslee
Hi,

Well, at the most basic, you create an appropriately-named and
formatted text file in the man directory. The Writing R Extensions
manual is full of information:
https://cran.r-project.org/doc/manuals/R-exts.html

Roxygen is an alternative approach to creating the Rd files yourself.
https://cran.r-project.org/web/packages/roxygen2/vignettes/roxygen2.html

The package.skeleton() function is a helper for the do it yourself approach.

Sarah

On Mon, Dec 19, 2022 at 9:17 AM Sanjeev Sariya  wrote:
>
> Hi devel team,
>
> I have recently added one file in the inst/extdata folder.
>
> I'd like to add details about it in the man folder by creating a .Rd file
> for the respective file.
>
> I created .Rd files for other datasets long time back, however, I do not
> remember the steps now. Their skeleton looks like the attached file.
>
> I am using conda environment (not R studios)
> Kindly guide me further.
>  best
>
> --
> Sanjeev M
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



-- 
Sarah Goslee (she/her)
http://www.sarahgoslee.com

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Question on Description/Citing Feedback

2022-12-19 Thread Uwe Ligges
Well, the CRAN question is more a suggestion that refernces for a 
package can be specified in the Descrioption field of the DESCRIPTION 
file so that poeple directly see the references even befiore downloading 
the package. This is a (strong) suggestion, not compulsory.


Best,
Uwe Ligges



On 16.12.2022 19:06, Michael Topper wrote:

Hello all,

I just received feedback from my first CRAN submission. Currently, I am a
little confused as to one point of the feedback which reads:









*If there are references describing the methods in your package, pleaseadd
these in the description field of your DESCRIPTION file in the formauthors
(year) authors (year) authors (year, ISBN:...)or if
those are not available: with no space after 'doi:', 'arXiv:',
'https:' and angle brackets forauto-linking. (If you want to add a title as
well please put it inquotes: "Title")*

For some background:

- My package is named panelsummary. The link to the github can be found
here: https://github.com/michaeltopper1/panelsummary
- My package inherits some documentation of some of the parameters from
the package modelsummary
. In particular, two
of my functions (panelsummary::panelsummary and
panelsummary::panelsummary_raw) share a couple of the same arguments as
modelsummary::modelsummary. I used roxygen2 (@inherits) to generate
documentation for the shared arguments.
- Because of this inherited documentation, I have also included the
author/creator of modelsummary as a copyright holder in the DESCRIPTION
file with a comment.


My confusion:

- I understand the Description portion of the DESCRIPTION file needs to
be edited, but I'm a little confused as to what I am supposed to add and
how. Do I need to include a citation to the published paper of
modelsummary and describe where I use the documentation? Modelsummary was
published in the journal of statistical software and the following was
included on the modelsummary release information:
   - Arel-Bundock, Vincent (2022). “modelsummary: Data and Model
   Summaries in R.” Journal of Statistical Software, 103(1), 1-23.
   doi:10.18637/jss.v103.i01 https://doi.org/10.18637/jss.v103.i01.’

What would be most helpful:

- If there is any other Description file from another package that
contains an example of what to do in such a situation, this would be
greatly appreciated!

Please let me know if any additional details are needed, and thank you so
much for your help/time!

Michael

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel