理解 “Error in ggplot(data = penguins) : object ‘penguins’ not found”

huangapple go评论123阅读模式
英文:

Understanding "Error in ggplot(data = penguins) : object 'penguins' not found"

问题

install.packages("palmerpenguins")
正在安装包到 '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
(as 'lib' is unspecified)
尝试 URL 'http://rspm/default/linux/focal/latest/src/contrib/palmerpenguins_0.1.1.tar.gz'
内容类型 'application/x-gzip' 长度为 3001167 字节 (2.9 MB)
==================================================
已下载 2.9 MB

  • 正在安装 binary 包 'palmerpenguins' ...
  • 完成 (palmerpenguins)

已下载的源代码包在
'/tmp/RtmphP3P09/downloaded_packages' 中

library(palmerpenguins)
ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=species))
出现错误:ggplot(data = penguins) : 无法找到函数 "ggplot"
install.packages(ggplot)
出现错误:找不到对象 'ggplot'
install.packages("ggplot2")
出现错误:正在更新已加载的包

正在重新启动 R 会话...

install.packages("ggplot2")
出现错误:正在更新已加载的包

正在重新启动 R 会话...

install.packages("ggplot2")
出现错误:正在更新已加载的包

正在重新启动 R 会话...

install.packages("ggplot2")
出现错误:正在更新已加载的包
install.packages("ggplot2")
正在安装包到 '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
(as 'lib' is unspecified)
尝试 URL 'http://rspm/default/linux/focal/latest/src/contrib/ggplot2_3.4.1.tar.gz'
内容类型 'application/x-gzip' 长度为 4203322 字节 (4.0 MB)
==================================================
已下载 4.0 MB

  • 正在安装 binary 包 'ggplot2' ...
  • 完成 (ggplot2)

已下载的源代码包在
'/tmp/RtmpesapFQ/downloaded_packages' 中

library(ggplot2)
ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=g))
出现错误:对象 'penguins' 未找到

试验

ggplot(data=penguins) + 
  geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=g)) 

以生成散点图。但我每次都遇到以下错误。

错误

出现错误:ggplot(data = penguins) : 未找到对象 'penguins'

帮助:请指出我在代码中需要纠正的地方,谢谢。

英文:
> install.packages("palmerpenguins")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/palmerpenguins_0.1.1.tar.gz'
Content type 'application/x-gzip' length 3001167 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *binary* package ‘palmerpenguins’ ...
* DONE (palmerpenguins)

The downloaded source packages are in
	‘/tmp/RtmphP3P09/downloaded_packages’
> library(palmerpenguins)
> ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=species))
Error in ggplot(data = penguins) : could not find function "ggplot"
> install.packages(ggplot)
Error in install.packages : object 'ggplot' not found
> install.packages("ggplot2")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("ggplot2")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("ggplot2")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("ggplot2")
Error in install.packages : Updating loaded packages
> install.packages("ggplot2")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/ggplot2_3.4.1.tar.gz'
Content type 'application/x-gzip' length 4203322 bytes (4.0 MB)
==================================================
downloaded 4.0 MB

* installing *binary* package ‘ggplot2’ ...
* DONE (ggplot2)

The downloaded source packages are in
	‘/tmp/RtmpesapFQ/downloaded_packages’
> library(ggplot2)
> ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=g))
Error in ggplot(data = penguins) : object 'penguins' not found

trial:

ggplot(data=penguins) + 
  geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g, color=g)) 

to generate scatter plot. But I am facing following error everytime.
error:

Error in ggplot(data = penguins) : object 'penguins' not found

Help: Please rectify exactly what should I correct in the code.
thanks

答案1

得分: 0

你试图使用ggplot绘图,但没有提供数据(数据丢失)。你还没有创建颜色向量。
确保也加载了ggplot2包。

# 加载包
library(ggplot2)
library(palmerpenguins)

data(penguins) # 加载数据

ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g))
英文:

You tried to ggplot it, without data (The data is missing). The colors vector you did not create.
Be sure to load the ggplot2 package too

# Load the packages
library(ggplot2)
library(palmerpenguins) 

data(penguins) # Load the data

ggplot(data=penguins) + geom_point(mapping = aes(x=flipper_length_mm, y=body_mass_g))

huangapple
  • 本文由 发表于 2023年2月24日 02:05:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定