[R] How to create a data set from object/data frame?

Sarah Goslee @@r@h@go@|ee @end|ng |rom gm@||@com
Fri Jul 19 18:12:33 CEST 2019


Right. If you have some equivalent to the Dilution dataset, then you
need to get it into R in the appropriate way for whatever data you
have.

data() is merely a way to get stored R data into your R session.
There's no reason you need to use data() rather than read.table() or
whatever is appropriate for the data you have available.

Or if you needed that exact dataset, data(Dilution) would get it into
your R session.

Do look at ?data if you haven't already.

Sarah

On Fri, Jul 19, 2019 at 10:46 AM Spencer Brackett
<spbrackett20 using saintjosephhs.com> wrote:
>
> Sarah,
>
>   I am trying to extract phenoData (ie sample information) from the object as part of a procedure to analyze my array for probe sets, which I realize is under the BioConducter package Biobase and not relevant to this mailing list.
>
>   Yes the original procedure uses data from the Dilution dataset hosted in the AffyBatch package affydata. Previous to this part of the procedure, a dataset was create via..
>
>   >fake.data <- matrix(rnorm(8*200), ncol=8)
> ##Then phenotype (sample) data was generated in this example through... ##
>
>   sample.info <- data.frame( + spl=paste('A', 1:8, sep=''), + stat=rep(c('cancer' , 'healthy'), each=4))
>
> ##Then a meta data.frame object was created to give more intelligible labels##
>
> > meta.info <- data.frame (labelDescription = + c('Sample Name' , 'Cancer Status')) Then we put them all together: > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
> ##Which was then aggregated together##
>
> > pheno <- new("AnnotatedDataFrame", + data = sample.info, + varMetadata = meta.info)
>
>   >my.experiments <- new("ExpressionSet", + exprs=fake.data, phenoData=pheno)
>    > my.experiments
> ExpressionSet (storageMode: lockedEnvironment) assayData: 200 features, 8 samples element names: exprs
>
> ##The following deals with further manipulating the phenoData##
> phenoData
>    sampleNames: 1, 2, ..., 8 (8 total) varLabels and varMetadata description: spl: Sample Name stat: Cancer Status
>
> featureData
>  featureNames: 1, 2, ..., 200 (200 total) fvarLabels and fvarMetadata description: none
> experimentData:  use 'experimentData(object)'
> Annotation:
>
> ##At this point is when the dataset 'Dilution was read in through data(Dilution)
>
> which was made an object of the AnnotatedDataFrame via
>
> >phenoData(Dilution)
>
> My apologies in advance as I know the above info. pertains to functions carried out strictly through BioConducor, but is the only context I can provide for what I am trying to do.
>
> Best,
>
> Spencer
>
>
> On Fri, Jul 19, 2019 at 10:23 AM Sarah Goslee <sarah.goslee using gmail.com> wrote:
>>
>> Hi Spencer,
>>
>> Your description doesn't make any sense to me. If anno is already an R
>> object, what are you trying to do with it?
>>
>> data() is for loading datasets that come with packages; if your object
>> is already an R object in your environment, then there's no need for
>> it.
>>
>> It sounds like you are possibly working through an example provided
>> elsewhere, that has sample data loaded with data(). If so, then you do
>> not need that step for your own data. You just need to import it into
>> R in the correct format.
>>
>> If that doesn't help, then I think we need more information on what
>> you're trying to do.
>>
>> Sarah
>>
>> On Fri, Jul 19, 2019 at 10:18 AM Spencer Brackett
>> <spbrackett20 using saintjosephhs.com> wrote:
>> >
>> > Hello,
>> >
>> >   I am trying to create a data set from an object called ‘anno’ in my
>> > environment. I’ve tried arguments like saveRDS(anno, file = “”) and
>> > save(anno, file “.RData”) to save the object as a file to see if that will
>> > work, but it seems for the particular procedure I am trying to carry out, I
>> > need to transpose the object to a data set. Any ideas as to how I might do
>> > this? For reference, my next step in manipulating the data contained in the
>> > object is data(), which evidently does not work for reading in data frame
>> > objects as data(“file/object name).
>> >
>> > Best,
>> >
>> > Spencer
>> >\

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



More information about the R-help mailing list