简体   繁体   English

ggplot2 stat_smooth上的错误

[英]error on ggplot2 stat_smooth

I receive an error when I try to use ggplot2 but I do not understand why. 当我尝试使用ggplot2时收到错误消息,但我不明白为什么。 I am probably doing some little mistake somewhere... 我可能在某处犯了一些小错误...

    > head(d)
      TargetGroup2012 TargetGroup2000     bmi3 age3 PA_Score education3 asthma3 allasthma3 tres3
    1               2               2 20.89796   55        2          2       0          0     0
    2               2               2 20.20038   49        3          2       0          0     0
    3               2               2 30.47797   58        3          1       0          0     0
    4               2               2 34.13111   51        2          2       0          0     0
    5               3               2 23.24380   52        3          1       0          0     0
    6               3               2 16.76574   62        2          3       0          0     0
      wheeze3 SmokingGroup_Kai groupchange
    1       0                4           4
    2       1                4           4
    3       0                5           4
    4       1                4           4
    5       0                3           5
    6       0                3           5
    > 

    ggplot() + 
      stat_smooth(data=d,aes(x=bmi3,y=asthma3),
                  method="gam",
                  formula=asthma3~bmi3, 
                  family="binomial")

# this is the ouput
# Error in eval(expr, envir, enclos) : object 'asthma3' not found


#this one works

    ggplot()+ stat_smooth(data=d,aes(x=bmi3,y=asthma3),
                  formula=asthma3~bmi3, 
                  family="binomial")

What's wrong with my code? 我的代码有什么问题?

将stat_smooth中的公式参数更改为:

 formula = y ~ x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM