r - 通过新功能传递图形参数
问题描述
我正在使用基本 R 函数在 R 中编写一个包含绘图选项的plot()
函数。如何将图形参数从新函数“传递”到plot()
函数中?
请参见下面的示例:
test.plot <- function(dat.x, dat.y, ...) { #Function with two parameters, pass on graphical parameters
plot(x = dat.x, # Plot data
y = dat.y) # Do graphical input parameters go here?
}
test.plot(dat.x = c(5.4, 2.7, 3.3, 2.1),
dat.y = c(0.2, 1.9, 0.5, 1.3),
xlab = "test axis") # I want this graph to have the x label I put in
有任何想法吗?
解决方案
添加...
到plot()
.
test.plot <- function(dat.x, dat.y, ...) {
plot(x = dat.x,
y = dat.y, ...)
}
test.plot(dat.x = c(5.4, 2.7, 3.3, 2.1),
dat.y = c(0.2, 1.9, 0.5, 1.3),
xlab = "test axis",
col = "red",
pch = 10,
cex = 5)
推荐阅读
- php - PHP:如何正确地制作这个“包装器”方法?
- sql - 如何识别指定值的日期范围/间隔?
- bash - 如何将 bash 脚本插入 Hocon 变量
- macos - 在 mac os x 上以编程方式简单的 Spark 启动
- python - 如何增加熊猫系列中截断的显示行数
- sql - 如何使用似乎忽略索引的窗口函数提高查询的性能?
- python - 如何在python中创建一个具有多个数组的单个数组?
- android - 如何使用 Retrofit 调用 Json
- javascript - 退出 AJAX 循环或在 html 页面列表中查找 alt 以进行比较
- reporting-services - SSRS 特定字符串的颜色格式