繁体   English   中英

从R中的表绘制数据

[英]Plotting data from a table in R

刚使用“ R”。 我正在绘制空气质量数据。 我目前有一张要从我指定为“ air”的文件中提取的表格,该表格如下所示:

Ozone   Radiation
   3        4
   7        5
   8        3

以下是我的代码,但是当我要求R对其进行散点图时,会出现此错误:

Error in xy.coords(x,y,xlabel,ylabel,log) : 'x' and 
'y' lengths differ calls: etc...

这是我的代码

air<- read.table("air")

Ozone <- air[1]
Radiation <- air[2]
plot(Ozone,Radiation)

我真的只是想将这两个数据相互绘制(最好是在散点图中)。 我知道这是一个基本问题,但感谢您的关注。

带有ggplot代码将给出以下图表。

df <- data.frame(
       Ozone = c(3L, 7L, 8L),
   Radiation = c(4L, 5L, 3L)
)

library(ggplot2)
ggplot(df, aes(x = Ozone, y = Radiation)) + geom_point(color = "blue", size = 3)

在此处输入图片说明

暂无
暂无

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

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