[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 19:32:31 CEST 2019
You don't need fake.data or rnorm(), which was used to generate the fake data.
You need to use your real data for the analysis, not anything randomly
generated for example purposes, or anything included with a package
for example purposes.
In both cases, those are just worked examples.You need to analyze your
own comparable data.
Sarah
On Fri, Jul 19, 2019 at 12:17 PM Spencer Brackett
<spbrackett20 using saintjosephhs.com> wrote:
>
> Sarah,
>
> Thank you for the reference to ?data. Upon further research into the matter, I think I can provide a simpler explanation than the one previously provided. I am trying to reproduce the following code with an object -- 'anno' -- in my data frame/environment.
>
> >fake.data <- matrix(rnorm(8*200), ncol=8)
>
> I found the number of columns with >ncol(anno) , which is 3
>
> How do I find rnorm when I don't have the data table (saved as the 'anno' object) mean or standard dev. ?
>
> I will try reading in the data object through read.table() now, though won't that just print the data or a subset thereof into my R console?
>
>
>
> 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
>>> >
>>> > [[alternative HTML version deleted]]
>>> >
>>> > ______________________________________________
>>> > R-help using 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.
>>>
>>>
More information about the R-help
mailing list