Hello, I have this file:> a=load("paired_example.Rdata") > a[1] "rawdata" "treatment" "patient" I can extract "rawdata" with: dat<-local(get(load("paired_example.Rdata"))) Can you please advise how would I extract in data frame "treatment" and "patient"? Thanks Ana
What does str(a) give? Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jul 31, 2020 at 7:18 PM Ana Marija <sokovic.anamarija at gmail.com> wrote:> Hello, > > I have this file: > > a=load("paired_example.Rdata") > > a > [1] "rawdata" "treatment" "patient" > > I can extract "rawdata" with: > dat<-local(get(load("paired_example.Rdata"))) > > Can you please advise how would I extract in data frame "treatment" > and "patient"? > > Thanks > Ana > > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]
Hi Ana, You are making this far too complicated. load("paired_example.Rdata") ls() str(rawdata) str(treatment) str(patient) load() puts all of them into your current environment. If you assign the result of load() to something, in your example a, that object contains the names of the objects, but the objects themselves are in your workspace. You should probably try a basic R tutorial; it will help you with this kind of thing. Sarah On Fri, Jul 31, 2020 at 10:18 PM Ana Marija <sokovic.anamarija at gmail.com> wrote:> > Hello, > > I have this file: > > a=load("paired_example.Rdata") > > a > [1] "rawdata" "treatment" "patient" > > I can extract "rawdata" with: > dat<-local(get(load("paired_example.Rdata"))) > > Can you please advise how would I extract in data frame "treatment" > and "patient"? > > Thanks > Ana > > ______________________________________________ > R-help at 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.-- Sarah Goslee (she/her) http://www.numberwright.com
Hi Bert, it gives me this:> a=load("paired_example.Rdata") > str(a)chr [1:3] "rawdata" "treatment" "patient" I don't know how to extract "treatment" for example in a data frame. I tried this but of no help.> b=a[[2]] > b[1] "treatment"> str(treatment)chr [1:10] "treat" "treat" "treat" "treat" "treat" "control" "control" ... but this is not the format I need. On Fri, Jul 31, 2020 at 9:18 PM Ana Marija <sokovic.anamarija at gmail.com> wrote:> > Hello, > > I have this file: > > a=load("paired_example.Rdata") > > a > [1] "rawdata" "treatment" "patient" > > I can extract "rawdata" with: > dat<-local(get(load("paired_example.Rdata"))) > > Can you please advise how would I extract in data frame "treatment" > and "patient"? > > Thanks > Ana
It seems that "treatment" and "patient" are just vectors.> treatment[1] "treat" "treat" "treat" "treat" "treat" "control" "control" [8] "control" "control" "control"> patient[1] "a" "b" "c" "d" "e" "a" "b" "c" "d" "e" On Fri, Jul 31, 2020 at 9:53 PM Ana Marija <sokovic.anamarija at gmail.com> wrote:> > Hi Bert, > > it gives me this: > > > a=load("paired_example.Rdata") > > str(a) > chr [1:3] "rawdata" "treatment" "patient" > > I don't know how to extract "treatment" for example in a data frame. > > I tried this but of no help. > > b=a[[2]] > > b > [1] "treatment" > > > str(treatment) > chr [1:10] "treat" "treat" "treat" "treat" "treat" "control" "control" ... > > but this is not the format I need. > > On Fri, Jul 31, 2020 at 9:18 PM Ana Marija <sokovic.anamarija at gmail.com> wrote: > > > > Hello, > > > > I have this file: > > > a=load("paired_example.Rdata") > > > a > > [1] "rawdata" "treatment" "patient" > > > > I can extract "rawdata" with: > > dat<-local(get(load("paired_example.Rdata"))) > > > > Can you please advise how would I extract in data frame "treatment" > > and "patient"? > > > > Thanks > > Ana
Sarah has explained all. I agree with her about the need for tutorials also. This list cannot substitute for such homework on your own. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jul 31, 2020 at 7:55 PM Ana Marija <sokovic.anamarija at gmail.com> wrote:> Hi Bert, > > it gives me this: > > > a=load("paired_example.Rdata") > > str(a) > chr [1:3] "rawdata" "treatment" "patient" > > I don't know how to extract "treatment" for example in a data frame. > > I tried this but of no help. > > b=a[[2]] > > b > [1] "treatment" > > > str(treatment) > chr [1:10] "treat" "treat" "treat" "treat" "treat" "control" "control" ... > > but this is not the format I need. > > On Fri, Jul 31, 2020 at 9:18 PM Ana Marija <sokovic.anamarija at gmail.com> > wrote: > > > > Hello, > > > > I have this file: > > > a=load("paired_example.Rdata") > > > a > > [1] "rawdata" "treatment" "patient" > > > > I can extract "rawdata" with: > > dat<-local(get(load("paired_example.Rdata"))) > > > > Can you please advise how would I extract in data frame "treatment" > > and "patient"? > > > > Thanks > > Ana > > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]