pvar {Smisc} | R Documentation |
A convenience function for writing the names and values of objects to the session window (and/or to another object). Especially useful to keep track of variables within loops.
pvar(..., digits = NULL, abbrev = NULL, sep = ";", verbose = TRUE)
... |
Objects whose names and values are to be printed, separated by commas. Can also be a simple list. |
digits |
Number of digits to display for numeric objects. Defaults to
|
abbrev |
Number of characters to display for character objects.
Defaults to |
sep |
Character string that separates the objects that are printed |
verbose |
|
Input objects can be numeric, character, and/or logical. They can also be atomic or vectors. It will accept data frames and matrices without error, but the results won't be easily readable.
Invisibly returns a character string containing the names of the objects and their values
Landon Sego
x <- 10 y <- 20.728923 z <- "This.long.string" pvar(x, y, z) pvar(x, y, z, digits = 2) pvar(x, y, z, abbrev = 4) pvar(x, y, z, digits = 2, abbrev = 4) pvar(x, y, z, sep = ",") # values can be vectors too x <- 10:12 y <- c("This","That") v2 <- pvar(x, y, verbose = FALSE) v2 # Or a simple list pvar(list(x = 1:2, y = "this", z = TRUE)) # Can be useful for keeping track of iterations in loops for (i in 1:2) { for (j in letters[1:2]) { for (k in c("this","that")) { pvar(i, j, k) } } }