[R] Svar: Re: help with simple R-question
John Kane
jrkrideau at yahoo.ca
Wed Jun 6 13:46:56 CEST 2007
I think that you have the same situation as before
though I have never used ranef(). The boar ids are
acting as the row names and are not really part of the
data.frame. It just looks like that when R prints the
data.frame.
Try
boars <- rownames(far1)
far1 <- cbind( boars, far1)
The results may look a bit funny with two printed
columns looking the same but one will be a column in
the data.frame and the other will be the row names
column. I hope :)
--- Rina Miehs <rmi at danishmeat.dk> wrote:
>
> The left column is boar id number, and the right is
> the random effect
> estimate. I need the numbers in the left column when
> i merge far1
> together with other data.frames based on the id
> numbers. When i use
> ranef the output is the class list and R only sees
> the intercepts, but i
> need a data.frame with 'boar id' and 'niveau', two
> columns not just
> one...
>
> fx
> > far1 <- ranef(resultat1)[1]
> > far1
> $farid
> (Intercept)
> 1437987 -3.775851e-03
> 10000100 -3.220044e-03
> 10007995 1.848914e-02
> 10008295 -4.583903e-03
> 10008792 -9.518371e-03
> 10033401 -7.538132e-03
> 10048900 1.540309e-02
> > far1 <- as.data.frame(far1)
> > far1
> X.Intercept.
> 1437987 -3.775851e-03
> 10000100 -3.220044e-03
> 10007995 1.848914e-02
> 10008295 -4.583903e-03
> 10008792 -9.518371e-03
> 10033401 -7.538132e-03
> 10048900 1.540309e-02
> Thanks again
>
> Rina
>
>
> >>> John Kane <jrkrideau at yahoo.ca> 06/06/07 11:38
> >>>
>
> --- Rina Miehs <rmi at danishmeat.dk> wrote:
>
> > thanks, that works great!!
> >
> > just have another thing...i the same area
> > What if the class is list instead of array, how
> can
> > you name the first unrecognized column?
>
> I am not sure that I understand the question. You
> don't really have an unrecognised column in the
> dataframe but an array of rownames ( I don't know
> how
> they are stored).
>
> I think you can do the same thing as you did for the
> data.frame but as I say, I am not sure I understand
> the question. Would you post a little example?
>
>
> >
> > Rina
> >
> > >>> John Kane <jrkrideau at yahoo.ca> 06/05/07 3:17
> >>>
> >
> > --- Rina Miehs <rmi at danishmeat.dk> wrote:
> >
> > > hello
> > >
> > > what do i write for R to recognize both columns?
> > >
> > > In the R-script downunder you can see that i use
> > > tapply to get my
> > > information out of my data, and then i need to
> use
> > > it as a dataframe
> > > with both columns! It is like R is using the
> first
> > > column as an
> > > observationnumber or something, how can i change
> > > that??
> >
> > It is using the names of the variables as
> rownames.
> >
> > try
> > n.ant <- names(antall)
> > antal1 <- data.frame(n.antal1, antal1)
> >
> >
> > >
> > > > antal1 <-tapply(l1$omlob1,l1$farid,length)
> > > > antal1
> > > 1437987 10000100 10007995 10008295 10008792
> > > 10010203 10018703
> > > 10033401
> > > 2 3 3 2
> 3
> >
> > > 1 1
> > > 2
> > > 10048900 10050492 10055897 10076495
> 10081892
> > > 10094801 10100692
> > > 10101395
> > > 3 1 3 3
> 6
> >
> > > 2 5
> > > 20
> > > 10101495 10101595 10104692 10113592
> 10113697
> > > 10114297 10120797
> > > 10120897
> > > 1 5 4 2
> 6
> >
> > > 11 1
> > > 4
> > > 10121697 10121897 10121997 10133592
> 10142892
> > > 10142995 10146495
> > > 10150497
> > > 16 3 6 1
> 1
> >
> > > 6 4
> > > 4
> > > 10150692 10157092 10157292 10164792
> 10170892
> > > 10171795 10171895
> > > 10172300
> > > 5 2 4 4
> 4
> >
> > > 4 4
> > > 1
> > > 10175195 10187802 10192499 10192897
> 10198295
> > > 10200493 10201693
> > > 10211593
> > > 1 2 2 3
> 5
> >
> > > 1 3
> > > 5
> > > > antal1 <- data.frame(antal1)
> > > > antal1
> > > antal1
> > > 1437987 2
> > > 10000100 3
> > > 10007995 3
> > > 10008295 2
> > > 10008792 3
> > > 10010203 NA
> > > 10018703 NA
> > > 10033401 2
> > > 10048900 3
> > > 10050492 1
> > > 10055897 3
> > > 10076495 3
> > > 10081892 6
> > > 10094801 2
> > > 10100692 5
> > >
> > > Thanks
> > > Rina
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R ( http://www.r/ ) ( http://www.r/
> > )-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained,
> > > reproducible code.
> > >
> >
> >
> >
> > Get news delivered with the All new Yahoo!
> > Mail. Enjoy RSS feeds
> > right on your Mail page. Start today at
> > http://mrd.mail.yahoo.com/try_beta?.intl=ca
> >
> >
>
>
>
> Be smarter than spam. See how smart SpamGuard
> is at giving junk
> http://mrd.mail.yahoo.com/try_beta?.intl=ca
>
>
>
=== message truncated ===
More information about the R-help
mailing list