0

I am really new at this and I hope you could help me.

I am trying to represent in a a4 papper (Pageorientation: Landscape) two plots against two tables. In this case I am using the same table (from a .dat file) to simplify the example.

I started to read the file:

dat<-read.table("d:\\Users\\...\\xxxxxxxx.dat",header=TRUE,sep="\t")

Now I want to divide my a4papper in 4 (2X2):

par(mfrow=c(2,2))

Now I define my vectos and represent them:

v<- c(1,2,3,4,5,6,7,8,9,10)
z<- c(2,4,6,8,10,12,14,16,18,20)
w<- c(1,7,17,18,35,55,98,100)
q<- c(2,4,5,6,7,50,67,99)

plot(v,z)
plot(w,q)

Now I represent my data.frame in a table (X2) (with grid):

grid.table(dat, gpar.coretext = gpar(fontsize=6), gpar.coltext = gpar(fontsize=6), padding.h=unit(2, "mm"), padding.v=unit(2, "mm"), show.rownames = F)
grid.table(dat, gpar.coretext = gpar(fontsize=6), gpar.coltext = gpar(fontsize=6), padding.h=unit(2, "mm"), padding.v=unit(2, "mm"), show.rownames = F)

RGui represents me: the two plots (in their respective positions in (1,1) and (1,2)) and the table centered.

After doing some research I found out that grid.table uses grid graphics, a system that is mostly incompatible with base graphics. I think I should use Gridbase, lattice or ggplot2 and then combine it with gridarrangement (I don't understant why, beacause we already define that we want a 2X2 matrix so our table should adapt itself to his space).

BUT:

1) Looking into Gridbase and Lattice package I didn't found any function that allows me to represent my data.frame in a tabular/table with grid properly like grid.table().

2) When I try to run my ggplot2:

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘munsell’ Error: package or namespace load failed for ‘ggplot2’

If somebody could help me with the code I would be really apreciated

Best regards

user3844140
  • 23
  • 1
  • 5
  • [link to the original comment that triggered this question, apparently](http://stackoverflow.com/questions/24798200/textplot-function-formatting-gplot-package?noredirect=1#comment38502872_24798200) – baptiste Jul 18 '14 at 08:15
  • You are right in your comment Baptiste. I have tried in this post to make my problem more clear and tried to add a reproducible example (following this http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). If you could give me some guide lines that I should follow I would be really apreciated. – user3844140 Jul 18 '14 at 08:17
  • a reproducible example means that we can directly reproduce your results; in this case we're still missing the data `dat`. – baptiste Jul 18 '14 at 08:19
  • you should probably close the original question, since you've opened a new one for the same problem, and the original title doesn't correspond to the question anymore. – baptiste Jul 18 '14 at 08:23
  • Ok! One cuestion, how can I upload my .dat file to make this post reproducible example? – user3844140 Jul 18 '14 at 08:25
  • better not to, usually people use a built-in dataset (`?data`), or alternatively use `dput()` on a small sample of your data to produce an output that we can copy and paste. – baptiste Jul 18 '14 at 08:29

1 Answers1

2

Here is a reproducible example using lattice for the plot

require(gridExtra)
require(lattice)

p = xyplot(1~1)
g = tableGrob(head(iris))

grid.arrange(p, g)

your issue with ggplot2 is unrelated; you need to install the package with its dependencies if you want to use it.

Alternatively, see this question for a gridBase approach.

Community
  • 1
  • 1
baptiste
  • 75,767
  • 19
  • 198
  • 294