Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有一种方法可以以“解释器可读”的方式打印对象,它会执行如下所示的操作:
> x <- c(1:5,8) > print.ir(x) c(1,2,3,4,5,8) > x <- matrix(1:4, ncol=2) > print.ir(x) matrix(c(1,2,3,4), ncol=2, nrow=2)
这样可以将结果复制粘贴到 R 脚本或另一个 R 会话中。
用于dput()此:
dput()
x <- c(1:5,8) dput(x) c(1, 2, 3, 4, 5, 8) x <- matrix(1:4, ncol=2) dput(x) structure(1:4, .Dim = c(2L, 2L))
试试看:
z <- structure(1:4, .Dim = c(2L, 2L)) z [,1] [,2] [1,] 1 3 [2,] 2 4