[R] grid.table and expression in table body?

baptiste auguie baptiste.auguie at googlemail.com
Tue Aug 17 21:43:04 CEST 2010


On 17 August 2010 18:38, Johannes Graumann <johannes_graumann at web.de> wrote:
> Hi - I can't get this figured out ...
>
> Thanks for any hint.

The parse=TRUE argument means that all the table content will be
parsed and interpreted as expression. In your content you have invalid
expressions (e.g. text with spaces), which cause the error. You could
try to reformat the labels,

# replace the spaces
m = gsub(" ","~",as.matrix(absoluteTable))
# wrap the < sign in ""
m = gsub("<","\"<\"",m)
library(gridExtra)
grid.table(data.frame(m),parse=T)

but I don't see the point of using parse in your example (there is not
plotmath expression to render).

Of course, I welcome any suggestion to create a matrix of valid
expressions, I have no clue how to deal with these.

baptiste



>
> Joh
>
>> load("/tmp/AbsoluteTable.Rdata")
>> absolutetable
>> library(gridExtra)
>> grid.table(absoluteTable)#Works
>> grid.table(absoluteTable,parse=TRUE)
> Error in parse(text = d[ii]) : unexpected symbol in "Survey Scans"
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> x86_64-pc-linux-gnu
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] grid      stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] gridExtra_0.7
>
> loaded via a namespace (and not attached):
> [1] tools_2.11.1
>
> On Monday 09 August 2010 12:02:03 baptiste auguie wrote:
>> I just uploaded version 0.7 on googlecode. I had inadvertently messed
>> up the previous attempt (uploaded an older version from another
>> computer). Fingers crossed it should build on r-forge in the next few
>> days.
>>
>> baptiste
>>
>> On 6 August 2010 17:11, Johannes Graumann <johannes_graumann at web.de> wrote:
>> > I updated the package from r-forge, but despite the fact that
>> > "grid.table" does not complain about the "parse" option if given, your
>> > example below is not being printed as a parsed expression.
>> >
>> > How can I check the actual version of the installed/loaded gridExtra
>> > package?
>> >
>> > Thanks, Joh
>> >
>> > On Wednesday 04 August 2010 16:47:12 you wrote:
>> >> I added a parse argument to grid.table so that when switched to TRUE
>> >> (default FALSE) all the text strings are interpreted as expressions
>> >> (inspired by ggplot2::geom_text),
>> >>
>> >> d <- data.frame("alpha", "beta")
>> >> grid.table(d, parse=T)
>> >>
>> >> you'll need revision 258 of gridExtra for this to work (googlecode now,
>> >> r-forge in the following days, CRAN in the next stable version).
>> >>
>> >> HTH,
>> >>
>> >> baptiste
>> >>
>> >> On Aug 4, 2010, at 9:56 AM, Johannes Graumann wrote:
>> >> > Hi Baptiste,
>> >> >
>> >> > This is, I fear a bit beyond my level of competency ... What I want to
>> >> > be able to do is things like put "<2.2%*%10^{-16}" in a table cell,
>> >> > who's name I can already set to "p[Wilcoxon]" ...
>> >> >
>> >> > Joh
>> >> >
>> >> > On Wednesday 04 August 2010 09:15:43 you wrote:
>> >> >> Hi,
>> >> >>
>> >> >> I don't know the answer to your question (how to make a data.frame
>> >> >> with expressions), but if you have a list of expressions you could
>> >> >> try the following,
>> >> >>
>> >> >> http://code.google.com/p/gridextra/wiki/testExpressions
>> >> >>
>> >> >> I'm open to suggestions for your original query (what is the best way
>> >> >> to do it – parse each string and coerce it as an expression?)
>> >> >>
>> >> >> HTH,
>> >> >>
>> >> >> baptiste
>> >> >>
>> >> >> On Aug 4, 2010, at 12:05 AM, Johannes Graumann wrote:
>> >> >>> Hi,
>> >> >>>
>> >> >>> Is there any way to get an expression into a data.frame, such that
>> >> >>> "grid.table" from "gridExtra" will plot it evaluated in the table
>> >> >>> body? The docu does it for the header, but is the body possible?
>> >> >>>
>> >> >>> Thanks, Joh
>> >> >>>
>> >> >>> ______________________________________________
>> >> >>> 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.
>



More information about the R-help mailing list