2

我有一个 ggplot 元素,称为“p”:

p <- qplot(hp, mpg, data=mtcars, shape=am, color=am, 
facets=gear~cyl, main="Scatterplots of MPG vs. Horsepower",
xlab="Horsepower", ylab="Miles per Gallon")

然后我打电话给“p”并得到一个情节。

如何调用 p 以便查看变量的分配:

>somefunction(p)

qplot(hp, mpg, data=mtcars, shape=am, color=am, 
facets=gear~cyl, main="Scatterplots of MPG vs. Horsepower",
xlab="Horsepower", ylab="Miles per Gallon")
4

1 回答 1

4

您可以尝试使用summary()将显示数据(数据框中所有变量的名称)、值映射以及使用哪种分面以及使用哪种几何图形的函数。

 summary(p)
data: mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb [32x11]
mapping:  colour = am, shape = am, x = hp, y = mpg
faceting: facet_grid(gear ~ cyl) 
-----------------------------------
geom_point:  
stat_identity:  
position_identity: (width = NULL, height = NULL)
于 2013-11-04T16:34:53.917 回答