Align a column to the left using a text block (gplots or PerformanceAnalytics)

I am writing some text in data.frame for a PDF device using textplot () in gplots (also tried using the version in PerformanceAnalytics). My par () options are standard, except that I change the font / fields (CM is the family that I defined in my site profile).

par( family = "CM" , omi = rep( .5 , 4 ) ) 

I am trying to get the “Plot” column so that it can be justified. Here is my unsuccessful attempt ... to notice an overlap in the text

 textplot( tableOfContents , show.rownames = FALSE , show.colnames = TRUE , hadj = 0 ) 

enter image description here

Right justified works great:

 textplot( tableOfContents , show.rownames = FALSE , show.colnames = TRUE , hadj = 1 ) 

enter image description here




EDIT If someone else struggles with alignment in texplot, I suggest taking a look at this modified version that I wrote: https://gist.github.com/1487363


EDIT2
You might want to remove my fix cex = 1. After some more reading, I realize that cex in the functional parameters is supposed to be applied to par (cex), which I think is confusing and excessive, but seems to be standard R practice

+6
source share
1 answer

Looking at the source code, I think the best way is with a little modification so that the x position adapts to hadj , rather than staying constant. It might be advisable to propose this change to the developer. Here is the point where you can download the modified version:

https://gist.github.com/1482973

Then just enter it in R using source() and you can use the function as usual.

 source('textplot.R') n = 10 data = data.frame(Section=1:n, Plot=replicate(n, paste(LETTERS[sample(26, sample(20), replace=T)], collapse='')), Page=sort(rep(1:4, len=n)), stringsAsFactors=FALSE) textplot(data, show.rownames = FALSE, show.colnames = TRUE, hadj=0) 

enter image description here

+7
source

Source: https://habr.com/ru/post/903857/


All Articles