object2script | R Documentation |
Display the source code corresponding to an object.
object2script(object, ...)
## S3 method for class 'numeric'
object2script(object, digits = NULL, print = TRUE, final.space = "\n", ...)
## S3 method for class 'matrix'
object2script(object, digits = NULL, print = TRUE, final.space = "\n", ...)
## S3 method for class 'data.frame'
object2script(object, digits = NULL, print = TRUE, final.space = "\n", ...)
## S3 method for class 'data.table'
object2script(object, digits = NULL, print = TRUE, final.space = "\n", ...)
## S3 method for class 'list'
object2script(object, digits = NULL, print = TRUE, ...)
object |
a vector, matrix, data.frame, data.table, or a list of these elements. |
... |
for compatibility with the generic function. |
digits |
[interger,>0] indicating the number of decimal places to be used. Passed to |
print |
[logical] should the result be displayed. |
final.space |
[character] Character string to be added at the end. For internal use. |
## vector
vec <- 1:10
object2script(vec)
object2script(setNames(vec, 1:10))
## matrix
M <- matrix(rnorm(16), 4, 4)
object2script(M)
colnames(M) <- c("a","b","c","d")
object2script(M)
rownames(M) <- c("a","b","c","d")
object2script(M)
## data.frame
df <- data.frame(matrix(rnorm(16), 4, 4),"a")
object2script(df, digits = 5)
## data.table
dt <- data.table(matrix(rnorm(16), 4, 4),"a")
object2script(dt, digits = 5)
## list
l <- list(vec, dt = dt, df = df)
object2script(l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.