[R] Very simple question about list components
ckalexa2 at ncsu.edu
Fri Sep 9 17:14:04 CEST 2011
Thank you all. And thanks for pointing out I have an lm object, not a list.
@ Steve, I knew I wasn't crazy when I saw him type "ans$" in the
prompt. I didn't see him hit <tab> though. So a special thanks to you
for helping me validate my sanity! :-)
On Fri, Sep 9, 2011 at 11:08 AM, Steve Lianoglou
<mailinglist.honeypot at gmail.com> wrote:
> Hi Clemontina,
> On Fri, Sep 9, 2011 at 11:01 AM, Clemontina Alexander <ckalexa2 at ncsu.edu> wrote:
>> I have a list 'ans' from the following code:
>> tt <- rnorm(50)
>> rr <- rnorm(50)
>> ans <- lm(rr~tt)
>> ans is "$coefficients", ans is "$residuals", ans is
>> "$effects", ... and so on up to ans. Is there an easy way to
>> display just these names and not the data they contain?
> In this case, you can simply do:
> R> names(ans)
>  "coefficients" "residuals" "effects" "rank"
>  "fitted.values" "assign" "qr" "df.residual"
>  "xlevels" "call" "terms" "model"
>> saw my advisor type "ans$" and they were displayed, but when I tried
>> it, it just goes to the next line waiting for input like this:
> If you are in the R prompt and you hit <tab> twice after `ans$`, it
> should show you the names of the elements in the `ans` list. If you
> use Rstudio, the doube <tab> hit will give you a handy dropdown
> menu list you can choose from.
>  For what it's worth, I'm not sure how far along in your R-learning
> you are, but if I were starting out learning R today, I might pick
> Rstudio as my IDE/interface of choice.
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
> | Memorial Sloan-Kettering Cancer Center
> | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
Department of Statistics
NC State University
Raleigh, NC 27695
Phone: (850) 322-6878
Email: ckalexa2 at ncsu.com
More information about the R-help