Maybe I\'m imagining this, but I think there is a built-in R function that lets you print an R vector (and possibly other objects like matrices and data frames) in the forma
dput
maybe?
> test <- c(1,2,3)
> dput(test)
c(1, 2, 3)
You can also dump
out multiple objects in one go to a file that is written in your working directory:
> test2 <- matrix(1:10,nrow=2)
> test2
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> dump(c("test","test2"))
dumpdata.r
will then contain:
test <-
c(1, 2, 3)
test2 <-
structure(1:10, .Dim = c(2L, 5L))