[R-pkg-devel] Guidance on importind multiple text files for @example

Duncan Murdoch murdoch.duncan at gmail.com
Thu May 11 19:05:42 CEST 2017

On 11/05/2017 9:56 AM, Zhian Kamvar wrote:
> I sent this earlier, but from a different email and it bounced on the list:
> You might try placing a directory (e.g. foo) of a few small dummy text
> files in inst/ and then in the example use:
> system.file("foo")
> as the input to your example.

That's the right idea, though I would list the package name explicitly 
in the system.file() call, e.g.

datafolder <- system.file("foo", package = "bar")

> That being said, system.file() often confuses users, so some authors
> have taken to wrapping that in a separate function like foo_example().

I'd say it's better to show users how to find the folder, rather than 
hiding that where they can't see it.  Examples should be for learning, 
not just to produce magic output.

Duncan Murdoch

> HTH,
> Zhian
> -----
> Zhian N. Kamvar, Ph. D.
> Postdoctoral Researcher (Everhart Lab)
> Department of Plant Pathology
> University of Nebraska-Lincoln
>> On May 11, 2017, at 08:54 , ujjwal anand <ujjwalsas9 at gmail.com
>> <mailto:ujjwalsas9 at gmail.com>> wrote:
>> Hi,
>> I am creating a function ftsc(x)
>> where x is given by:
>> x<-cname <- file.path("C:/Users/anand/Desktop/Internship", "dataftc")
>> In the dataftc folder I have stored all the text files to be clustered by
>> my function.
>> So, while creating the package I have to include an example and that is my
>> problem.
>> I am not able to define a path for data folder in @example.
>> So, please let me know if you have some ideas about it.
>> Thanks & regards,
>> Ujjwal
>> On Thu, May 11, 2017 at 3:47 PM, Duncan Murdoch
>> <murdoch.duncan at gmail.com <mailto:murdoch.duncan at gmail.com>>
>> wrote:
>>> On 11/05/2017 6:42 AM, ujjwal anand wrote:
>>>> Hello Sir/Ma'am,
>>>> I am trying to build a package on R. But my function, which takes a
>>>> folder
>>>> full of text files as an argument.
>>>> So, could you please share some ideas on how to import a folder (which
>>>> contains multiple text files) for "@example".
>>> Not sure what you mean by "import".  What are you starting with?  What do
>>> you want to end up with?
>>> Duncan Murdoch
>> [[alternative HTML version deleted]]
>> ______________________________________________
>> R-package-devel at r-project.org
>> <mailto:R-package-devel at r-project.org> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel

More information about the R-package-devel mailing list