【发布时间】:2016-05-24 07:12:20
【问题描述】:
我有以下向量和一个组合数据框,它们是提供给下面表达式的对象。
x <- c(1,2,3,4)
y <- c(5,6,7,8)
z <- c(9,10,11,12)
h <- data.frame(x,y,z)
D <- print (( rep ( paste ( "h[,3]" ) , nrow(h) )) , quote=FALSE )
# [1] h[,3] h[,3] h[,3] h[,3]
DD <- c ( print ( paste ( (D) , collapse=",")))
# "[1] h[,3],h[,3],h[,3],h[,3]"
DDD <- print ( DD, quote = FALSE )
# However when I place DDD in expand.grid it does not work
is(DDD)
[1] "character" "vector" "data.frameRowLabels" "SuperClassMethod"
因此表达式 expand.grid(DDD) 不起作用。我怎样才能获得一个过程,其中我重复 n 次表示对象的字符元素以获得重复字符元素数量的向量,当放置在 expand.grid 中时该向量起作用。
【问题讨论】:
标签: r