had*_*ley 23
不,但你可以自己写:
q <- function(...) {
sapply(match.call()[-1], deparse)
}
Run Code Online (Sandbox Code Playgroud)
只是为了表明它有效:
> q(a, b, c)
[1] "a" "b" "c"
Run Code Online (Sandbox Code Playgroud)
flo*_*del 11
我已将此函数添加到我的Rprofile.site文件中(请参阅?Startup您是否不熟悉)
qw <- function(x) unlist(strsplit(x, "[[:space:]]+"))
qw("You can type text here
with linebreaks if you
wish")
# [1] "You" "can" "type" "text"
# [5] "here" "with" "linebreaks" "if"
# [9] "you" "wish"
Run Code Online (Sandbox Code Playgroud)
流行的Hmisc包提供了Cs()执行此操作的功能:
library(Hmisc)
Cs(foo,bar)
[1] "foo" "bar"
Run Code Online (Sandbox Code Playgroud)
它使用与hadley的答案类似的策略:
Cs
function (...)
{
if (.SV4. || .R.)
as.character(sys.call())[-1]
else {
y <- ((sys.frame())[["..."]])[[1]][-1]
unlist(lapply(y, deparse))
}
}
<environment: namespace:Hmisc>
Run Code Online (Sandbox Code Playgroud)