[R] pretty formatting of lists

Thomas Petzoldt thpe at simecol.de
Sun Mar 16 14:47:06 CET 2008


Hello,

is there already a function in any R package which does
source code formatting of deparsed lists?

Let's create the following list:

x <- list(a = round(rnorm(3), 2),
           b = round(rnorm(3), 2))

xx <-c(aa = round(rnorm(30)), f = function(a) a + b, list(x, x))


Now, I want deparse it in a way that yields something like:


list(
   aa = c(0.25, 0.18, 0.84, -1.25, 0.09, -0.99, 1.64,
     1.42, -1.29, -0.14, -1.07, -1.05, 0.98, 0.33,
     1.76, -1.66, 0.96, -0.21, -1.29, 0.78, -0.4,
     -1.63, -0.78, -1.05, 1.27, -1.44, 0.12, -0.4,
     0.02, 1.03),
   f = function (a) a + b,
   list(
     a = c(2.22, 0.36, 0.74),
     b = c(0.46, 0.41, 1.46)
   ),
   list(
     a = c(2.22, 0.36, 0.74),
     b = c(0.46, 0.41, 1.46)
   )
)


Thanks a lot!

Thomas P.



More information about the R-help mailing list