r - 修改对象时分配的变量正在改变 - ggplot
问题描述
我遇到了 ggplot 的问题。
我有一个x1
分配给变量的 ggplot 对象y1
然后我修改x1
,并将其分配给y2
.
由于我更改为x1
,y1
也更改了。这让我有点失望,不确定我是否理解变量在 R 中的链接方式。示例如下:
x1 <- ggplot() + geom_vline(xintercept = 10)
y1 <- x1
# x1 and y1 print plot with vline at 10
x1[["layers"]][[1]][["data"]][["xintercept"]] <- 20
y2 <- x1
# x1 y2 and y1 print plot with vline at 20
# why is y1 being modified?
任何输入表示赞赏。
解决方案
推荐阅读
- java - 在 webview 中包含一个小部件
- r - 从 R 中的持续时间列中拆分小时和分钟
- javascript - 什么时候真正发出“可读”事件?流.可读
- javascript - 无法连接到 Node JS 上的 Mysql 数据库
- javascript - 如何在不和谐的消息中找到数字?
- html - 带滚动的全屏 gif,像视差视频效果
- python - 为什么我的 matplotlib 刻度标签不可见?相同的代码适用于 Jupyter 笔记本
- mfc - Msftedit 似乎在文件末尾处理段落标记 (\par) 不一致
- php - 如何检查复选框并在 jQuery 中显示输入字段?
- php - PHP 你可以在不同的类中使用相同的属性吗