-1

I want to achieve exactly same info like answer in below link

Adding table within the plotting region of a ggplot in r but I am trying to put my extra table info in on the top left corner with header on it.I tried changing xmin,xmax,ymin,ymax values but it did not work. My X axis is a factor I think that added another layer of complexity. Can somebody help.

I tried following below suggestion too but unfortunately there is no grid() package anymore.

http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/

Your help is appreciated.

Edit: Code copied from comments

ggplot(data=AMIClean, aes(x=Month_Year_Final, y=Observed_Rate, group=1)) 
+ geom_line(aes(group=1),colour = "forestgreen")+ geom_point(size=3, colour="black") 
+ xlab("Month Year(N=Denominator Cases)") + ylab("Readmission Rate(%)") 
+ ggtitle("AMI Trend (%)")+ theme_bw() 
+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) 
+ theme(axis.text.x = element_text(angle = 45, hjust = 1)) 
+ annotation_custom(tableGrob(AMITableCurrent),xmax=24,xmin=0 ymin=0, ymax=30)
Community
  • 1
  • 1
user2612244
  • 21
  • 1
  • 2
  • 8
  • Of there was no grid package there would be no ggplot2 package. The latter depends on the former. – Roland Jul 31 '15 at 14:52
  • Hello Roland, if I go to package list. I can see gridBase,gridDebug,....gridSVG but not grid. I am new on R. AM I missing basic steps here? This is my steps in windows 7 64 bit version Packages>>choose mirror>>and scroll down till you find grid – user2612244 Jul 31 '15 at 14:57
  • # here is my code ggplot(data=AMIClean, aes(x=Month_Year_Final, y=Observed_Rate, group=1)) + geom_line(aes(group=1),colour = "forestgreen")+ geom_point(size=3, colour="black") + xlab("Month Year(N=Denominator Cases)") + ylab("Readmission Rate(%)") + ggtitle("AMI Trend (%)")+ theme_bw()+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ annotation_custom(tableGrob(AMITableCurrent),xmax=24,xmin=0 ymin=0, ymax=30) – user2612244 Jul 31 '15 at 14:58
  • @user2612244 Familiarize yourself with how to post code on this site. Dumping it into the comments makes it reallllllly hard to read. There are tutorials on how to ask good questions here. – Señor O Jul 31 '15 at 15:00
  • @user2612244 As for the grid package, it does still exist. Did you try to install it by running `library(grid)`? You need to do `install.packages(grid)` first – Señor O Jul 31 '15 at 15:00
  • 1
    grid comes with R by default. https://github.com/wch/r-source/tree/trunk/src/library/grid – Dason Jul 31 '15 at 15:22
  • Just loaded and one step ahead. Thank you everybody for the comment. I will update once I am able to move forward. – user2612244 Jul 31 '15 at 15:27
  • I did it. For some reason I can not post my code. I was confused about x and y min and max but it makes sense perfectly. Thank you @senor for your help. I promise I will make my document better moving forward. – user2612244 Jul 31 '15 at 16:37
  • you probably mean to attach `gridExtra` in this case; that's where a `tableGrob` function is defined (not `grid`). – baptiste Jul 31 '15 at 22:17

1 Answers1

0
# Here is my code. Again Thank you everybody. 
  ggplot(data=AMIClean, aes(x=Month_Year_Final, y=Observed_Rate, group=1)) +
  geom_line(aes(group=1),colour = "forestgreen")+
  geom_point(size=3, colour="black") +
  xlab("Month Year(N=Denominator Cases)") +
  ylab("Readmission Rate(%)") +
  ggtitle("AMI Readmission Trend (%)")+
  theme_bw()+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  annotation_custom(tableGrob(AMI_Inset),xmin=17, xmax=22, ymin=29, ymax=30)
user2612244
  • 21
  • 1
  • 2
  • 8