[R] Problem with plotting diagnostics - Error in object$coefficients : $ operator is invalid for atomic vectors

Manderscheid Katharina Katharina.Manderscheid at unilu.ch
Fri Nov 26 08:59:21 CET 2010


hi peter,

thanks for your reply. i was kind of hoping/thinking that others have encountered the same problem too.

i try to provide a reproducable example.

my variables are the following (just the cases 1:50). the whole dataset has about 2800 cases.
> satlife[1:50]
 [1]  9 10 11  8 11 10 11  6  7  8  3  8 10  9  8  9  7  7  9  8  8  7 10  8  9
[26]  5  7  9  9 11 11  5  3  9  8  9  3  9  6  8  5  6  6  6  9 11  6  5  9  9
> income[1:50]
 [1] 1841-2250 1111-1460 1841-2250 1841-2250 2251-2710 2711-3190 1461-1840
 [8] 3771-4550 4551-5870 3191-3770 1841-2250 1461-1840 3771-4550 2251-2710
[15] 2251-2710 2711-3190 0-1100    1841-2250 <NA>      1841-2250 1111-1460
[22] <NA>      3771-4550 <NA>      1461-1840 <NA>      2711-3190 1461-1840
[29] 0-1100    1461-1840 <NA>      1841-2250 <NA>      3191-3770 <NA>     
[36] <NA>      <NA>      2251-2710 2711-3190 <NA>      <NA>      <NA>     
[43] 2711-3190 2251-2710 3771-4550 3771-4550 <NA>      <NA>      4551-5870
[50] <NA>     
10 Levels: 0-1100 1111-1460 1461-1840 1841-2250 2251-2710 ... 5870 und mehr
> satwirt[1:50]
 [1]  3  5  6  1  5  5  4  1  4  6  4  1  4  8  1  4  6  5 10  7  8  1  2  4  4
[26]  5  4  4  8 NA  3  4  5  8  6 NA  6  8  6  4  4  3  6  8  6  3  4  1  9  8
> freunde[1:50]
 [1] 4 5 7 4 6 7 7 3 3 4 2 4 4 5 3 6 7 4 5 2 4 4 5 4 4 6 5 4 4 6 6 6 4 4 5 4 5 6
[39] 3 7 4 5 6 5 5 5 4 2 3 5
> gesund[1:50]
 [1] gesund       gesund       gesund       gesund       nicht gesund
 [6] gesund       gesund       nicht gesund nicht gesund gesund      
[11] gesund       nicht gesund gesund       gesund       nicht gesund
[16] gesund       gesund       nicht gesund gesund       gesund      
[21] gesund       gesund       gesund       gesund       nicht gesund
[26] gesund       gesund       gesund       nicht gesund gesund      
[31] gesund       gesund       nicht gesund gesund       gesund      
[36] nicht gesund nicht gesund nicht gesund nicht gesund gesund      
[41] nicht gesund gesund       nicht gesund gesund       nicht gesund
[46] gesund       gesund       gesund       gesund       gesund      
Levels: gesund nicht gesund

and this is the regression model:
> reg.satlife <- lm(satlife ~ as.numeric(income)+ freunde + gesund+ satwirt)

the problem appears when calling
> par(mfrow=c(2,2))
> plot(reg.satlife)

the problem persists also when running the model without the factors income and gesund.

do you need more information?

thanks,
katharina

________________________________________
Von: Peter Ehlers [ehlers at ucalgary.ca]
Gesendet: Donnerstag, 25. November 2010 21:54
An: Manderscheid Katharina
Cc: 'r-help at r-project.org'; 'Duncan Murdoch'
Betreff: Re: [R] Problem with plotting diagnostics - Error in object$coefficients : $ operator is invalid for atomic vectors

On 2010-11-25 02:25, Manderscheid Katharina wrote:
> this problem seems to only exist in R 2.12.0 but not in R  2.11.1.
> any ideas? a bug?
>

Duncan *did* say that he was using  R 2.12.0. So that's not likely
to be the problem. Most of the time, when users claim that a
problem exists in a new version that did not exist in an older
version, it's due to a change in the user's setup or to not
updating packages or to not checking the NEWS file.

Since you still have not provided a *reproducible* example,
it's not likely that anyone can help. Can't you make up a
small example that shows exactly how you are using lm()
and that will generate the error?

Peter Ehlers

>
> ----------------------------------------------
> dr. katharina manderscheid
>
> soziologisches seminar
> universität luzern
>
> kasernenplatz 3
> 6000 luzern 7
>
> tel. ++41 41 228 4657
>
> web: http://www.unilu.ch/deu/dr.-katharina-manderscheid_346380.aspx
>
> -----Ursprüngliche Nachricht-----
> Von: Duncan Murdoch [mailto:murdoch.duncan at gmail.com]
> Gesendet: Mittwoch, 17. November 2010 16:33
> An: Manderscheid Katharina
> Cc: 'r-help at r-project.org'
> Betreff: Re: [R] Problem with plotting diagnostics - Error in object$coefficients : $ operator is invalid for atomic vectors
>
> On 17/11/2010 10:28 AM, Manderscheid Katharina wrote:
>> hi all,
>> after fitting a multiple linear regression
>> model<- lm(y ~ a + b+ c+d)
>> i wanted to plot diagnostics
>> plot(model)
>> but get the error message
>> Error in object$coefficients : $ operator is invalid for atomic vectors.
>> which does not make a lot of sense, since there is no "$" - i am working with an attached dataset.
>> can anyone help, please??
>> thanks a lot,
>> kat
>
>
> I just tried those lines (with fake data for a,b,c,d and y) and got no error message.  I was using R 2.12.0.
>
> I think you need to show us a reproducible example, and the
> sessionInfo() to go with it, to help with this.
>
> Duncan Murdoch
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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