From simon.urbanek at r-project.org  Wed Jun 20 16:33:52 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Wed, 20 Jun 2012 10:33:52 -0400
Subject: [Rd] how to manipulate dput output format
In-Reply-To: <CACU3EkN5m=xrHMS+6d-LCuVbPPciywdmMeq+5SKLFFgEd6XA+g@mail.gmail.com>
References: <CACU3EkN5m=xrHMS+6d-LCuVbPPciywdmMeq+5SKLFFgEd6XA+g@mail.gmail.com>
Message-ID: <524CBA07-EA04-4037-A650-4EE49DCF1DE1@r-project.org>


On Jun 19, 2012, at 11:04 AM, andre zege wrote:

> I am reading into Java dput output for a matrix, more specifically for a
> file backed big-matrix. I basically need to lift dimnames for a matrix from
> dput output. It's no big deal, but the code is very 'hackish' due to the
> need to get rid of quotes, endlines, parenthesis, etc. I was wondering if i
> could manipulate to an extent dput output with some options that define it,
> for example, get rid of quoting each element  in matirx dimnames somehow.
> Another great thing wiould be to make dput dump rownames and colnames on
> two separate lines, but i don't think it's possible. To give a specific
> example, instead of dput output like
> 
> 
> **new("big.matrix.descriptor"
>    , description = structure(list(sharedType = "FileBacked", filename =
> "res", totalRows = 1528,
>    totalCols = 53040, rowOffset = c(0, 1528), colOffset = c(0,
>    53040), nrow = 1528, ncol = 53040, rowNames = c("A", "AA",
>    "RNT.A", "ADVA", "AAPL", "AAS", "ABFS", "ABM", "ABT", "ACI",
>    .......
> 
> I'd prefer ideally to have it in the form where rownames and colnames don't
> have quotes and newlines and if possible are on separate lines
> 
> new("big.matrix.descriptor"
>    , description = structure(list(sharedType = "FileBacked", filename =
> "res", totalRows = 1528,
>    totalCols = 53040, rowOffset = c(0, 1528), colOffset = c(0,
>    53040), nrow = 1528, ncol = 53040,
> rowNames = c(A, AA, RNT.A, ADVA, AAPL, AAS, ABFS, ABM, ABT, ... )
> colNames = c(...)
> 

dput() is intended to be parsed by R so the above is not possible without massaging the output. But why in the would would you use dput() for something that you want to read in Java? Why don't you use a format that Java can read easily - such as JSON?

Cheers,
Simon


> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] how to manipulate dput output format
Simon Urbanek