[R] pretty formatting of lists

From: Thomas Petzoldt <thpe_at_simecol.de>
Date: Sun, 16 Mar 2008 14:47:06 +0100


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.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 16 Mar 2008 - 13:55:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Mar 2008 - 16:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive