【发布时间】:2017-05-09 15:55:18
【问题描述】:
我正在疯狂地混淆我的工作。
代码中的细节并不重要,我有两种选择
第一个:
ggplot(dta_fin, aes(x=PVT_0610_Z, y=PVT_1115_Z)) +
geom_point(shape=1) +
geom_vline(xintercept = 0, linetype="dashed") +
geom_hline(yintercept = 0, linetype="dashed") +
geom_smooth(method='lm') +
facet_wrap(~ GROUP, scales="fixed", ncol=3)
R中函数使用的第二个:
aFunction <-function(dataname,xx,yy)
{
ggplot(dataname, aes(x=xx, y=yy)) +
geom_point(shape=1) +
geom_vline(xintercept = 0, linetype="dashed") +
geom_hline(yintercept = 0, linetype="dashed") +
geom_smooth(method='lm') +
facet_wrap(~ GROUP, scales="fixed", ncol=3)
}
aFunction(dta_fin,PVT_0610_Z,PVT_1115_Z)
从第一个和第二个得到相同的图形是很自然的,但是我从两个代码中得到不同的图形。是什么原因??............
【问题讨论】:
-
您能否提供一些数据和一个最小示例,以便我们重现您的问题?
-
在函数内部使用
aes_string,并使用字符串而不是裸名来传递列名