gpt4 book ai didi

r - 生成箱线图两个变量数据框时出错 : adding class "factor" to an invalid object

转载 作者:行者123 更新时间:2023-12-03 22:58:56 25 4
gpt4 key购买 nike

我有一个数据框,其中包含两个变量的平均值,Leptine1 和 Leptine2,来自标题 Group.1 下 122 个人的三个技术重复。

  Group.1   Leptine1    Leptine2
1 10 2.17766667 2.168000000
2 105 11.87000000 11.180000000
3 106 0.03600000 0.031000000
4 11 11.22066667 12.551333333
5 113 5.37400000 5.787333333
6 116 11.46333333 12.063333333

我想为这些数据生成箱线图。我用了
boxplot(Group.1~interaction(Leptine1, Leptine2), data=leptine.means, col=2:3)

但收到消息
Error in boxplot.default(split(mf[[response]], mf[-response]), ...) : 
adding class "factor" to an invalid object

任何与此错误作斗争的建议将不胜感激。

最佳答案

为了您的意图,您的数据类型需要是整数

leptine.means$Group.1 <-  as.integer(leptine.means$Group.1)

boxplot(Group.1~interaction(Leptine1, Leptine2), data=leptine.means, col=2:3)

输出

enter image description here

关于r - 生成箱线图两个变量数据框时出错 : adding class "factor" to an invalid object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40270341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com