Error in ggplot(df, aes(x = x, y = y)) : could not find function “ggplot“

Error in ggplot(df, aes(x = x, y = y)) : could not find function "ggplot"

目录

Error in ggplot(df, aes(x = x, y = y)) : could not find function "ggplot"

问题:

解决:

完整错误:


问题:

没有安装ggplot2包怎么能使用其中的函数那:

#create data frame
df <- data.frame(x=c(1, 2, 4, 5, 7, 8, 9, 10),
                 y=c(12, 17, 27, 39, 50, 57, 66, 80))

#create scatterplot of x vs. y
ggplot(df, aes(x=x, y=y)) +
  geom_point()

解决:

#导入library(ggplot2)

#install.packages('ggplot2')

#导入library(ggplot2)

#install ggplot2 and all dependencies

install.packages("ggplot2", dependencies=TRUE)

#删除之后重新安装;

#remove ggplot2
remove.packages("ggplot2")

#install ggplot2
install.packages("ggplot2")

#load ggplot2
library(ggplot2)

library(ggplot2)

#create scatterplot of x vs. y
ggplot(df, aes(x=x, y=y)) +
  geom_point()

如果前面的修复都不起作用,可能需要简单地验证在R中运行的代码块是否正确,是否是在当前环境中安装并加载了ggplot2包。 

完整错误:

#create data frame
df <- data.frame(x=c(1, 2, 4, 5, 7, 8, 9, 10),
                 y=c(12, 17, 27, 39, 50, 57, 66, 80))

#create scatterplot of x vs. y
ggplot(df, aes(x=x, y=y)) +
  geom_point()

Error in ggplot(df, aes(x = x, y = y)) : could not find function "ggplot"

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Data+Science+Insight

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值