Skip to content

[Bioc-devel] Experimental data package or ExperimentHub

3 messages · Michael Love, Obenchain, Valerie, Kasper Daniel Hansen

#
dear Valerie,

This is a simple R question, but I can't seem to find the answer. I'm
assuming ExperimentHub wants object created by save() and not
saveRDS().

In make-data.R, I have a loop where I programmatically make a
GAlignmentPairs object for each of 4 samples. I'm then using assign()
to assign the value to an appropriate name, e.g.

assign(sample.name[i], x)

where x is a GAlignmentPairs object I've made.

I'm having trouble though saving this to a file. My first try was:

save(sample.name[i], file=paste0(sample.name[i],".rda"))

But this gives:

Error in save(sample.name[i], file = ...
  object 'sample.name[i]' not found

I also tried get(), but it's also giving the "not found" error.

save(get(sample.name[i]), file=paste0(sample.name[i],".rda"))


thanks
Mike

On Thu, Jun 30, 2016 at 6:41 PM, Obenchain, Valerie
<Valerie.Obenchain at roswellpark.org> wrote:
#
Hi,

There may be more elegant ways but here is one solution.

sample.name <- c("ABC_study_provider", "XYZ_study_provider")
lapply(sample.name,
    function(xx) {
        filename <- paste0(xx, ".rda")
        ## make the GAlignmentPairs
        ## ...
        xx <- GAlignmentPairs()
        save(xx, file=filename)
    })

Val
On 07/14/2016 05:40 AM, Michael Love wrote:
This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.
#
In save() you can use the "list" argument to give object names.  So
  save(list = sample[i], file=paste0(sample.name[i],".rda"))
should work.

Best,
Kasper

On Thu, Jul 14, 2016 at 9:21 AM, Obenchain, Valerie <
Valerie.Obenchain at roswellpark.org> wrote: