[R] Forestplot, grid graphics Viewplot grid.arange

2022-10-10 Thread Putt, Mary


I have created several plots using the forestplot package and the link shown 
here. 
 
Great package !
Next step is to combine two plots into a single graphic. The code provided on 
the link results in 'bleeding' of the graphics/text into each other. I don't 
want to clip it as I need the text elements. I am guessing the problem involves 
the combination of text and graphics in the 'plot'. I fooled around with the 
original post and also did some hunting online but no luck Thanks in advance.
library(foresplot)
data("dfHRQoL")

#create individual forest plots for Sweden and Denmark
fp_sweden <- dfHRQoL |>
  filter(group == "Sweden") |>
  mutate(est = sprintf("%.2f", mean), .after = labeltext) |>
  forestplot(labeltext = c(labeltext, est),
 title = "Sweden",
 clip = c(-.1, Inf),
 xlab = "EQ-5D index",
 new_page = FALSE)

fp_denmark <- dfHRQoL |>
  filter(group == "Denmark") |>
  mutate(est = sprintf("%.2f", mean), .after = labeltext) |>
  forestplot(labeltext = c(labeltext, est),
 title = "Denmark",
 clip = c(-.1, Inf),
 xlab = "EQ-5D index",
 new_page = FALSE)



#now combine into a single plot using the web code; but this one bleeds into 
each other
library(grid)

#
#Put plots together using grid graphics
#Attempt 1 from website

#
grid.newpage()
borderWidth <- unit(4, "pt")
width <- unit(convertX(unit(1, "npc") - borderWidth, unitTo = "npc", valueOnly 
= TRUE)/2, "npc")
pushViewport(viewport(layout = grid.layout(nrow = 1,
   ncol = 3,
   widths = unit.c(width,
   borderWidth,
   width))
)
)
pushViewport(viewport(layout.pos.row = 1,
  layout.pos.col = 1))
fp_sweden
upViewport()
pushViewport(viewport(layout.pos.row = 1,
  layout.pos.col = 2))
grid.rect(gp = gpar(fill = "grey", col = "red"))
upViewport()
pushViewport(viewport(layout.pos.row = 1,
  layout.pos.col = 3))
fp_denmark
upViewport(2)



#Attempt 2 from website, still a problem.

grid.newpage()
borderWidth <- unit(4, "pt")
width <- unit(convertX(unit(1, "npc") - borderWidth, unitTo = "npc", valueOnly 
= TRUE)/2, "npc")
pushViewport(viewport(layout = grid.layout(nrow = 1,
   ncol = 3,
   widths = c(0.45, 0.1, 0.45))
)
)
pushViewport(viewport(layout.pos.row = 1,
  layout.pos.col = 1))
fp_sweden
upViewport()

pushViewport(viewport(layout.pos.row = 1,
  layout.pos.col = 3))
fp_denmark
upViewport(2)

###
#Attempt 3 converting to grobs and use patchwork
###
library(ggplotify)
library(patchwork)

fpd_grob <- grid2grob(print(fp_denmark))

p1 <- grid2grob(print(fp_denmark))
p2 <- grid2grob(print(fp_sweden))
p_both <- wrap_elements(p1) + wrap_elements(p2)
p_both

#same problem with grid.arrange()**strong text**



Mary Putt, PhD, ScD
Professor of Biostatistics
Department of Biostatistics, Epidemiology & Informatics
Pereleman School of Medicine
University of Pennsylvania

215-573-7020

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] ggplot2 install.package

2022-10-10 Thread sibylle.stoeckli
Dear R members

 

I am working with RStudio R 4.2.0 and using ggplot2 and gridExtra. 

Since some windows updates I get some error when loading  ggplot2.

*   It seems that I am able to install ggplot2. The problem is when
loading ggplot2 with library().
*   Do you have any ideas to solve the problem?

 

 

Kind regards

Sibylle

 


**

install.packages("ggplot2", dependencies = TRUE)

WARNING: Rtools is required to build R packages but is not currently
installed. Please download and install the appropriate version of Rtools
before proceeding:



https://cran.rstudio.com/bin/windows/Rtools/

Installiere Paket nach �C:/Users/Sibylle
St�ckli/AppData/Local/R/win-library/4.2�

(da �lib� nicht spezifiziert)

trying URL
'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.3.6.zip'

Content type 'application/zip' length 4122980 bytes (3.9 MB)

downloaded 3.9 MB



Paket �ggplot2� erfolgreich ausgepackt und MD5 Summen abgeglichen



Die heruntergeladenen Bin�rpakete sind in 

C:\Users\Sibylle
St�ckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages

Error in nchar(homeDir) : invalid multibyte string, element 1


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] ggplot2 install.package

2022-10-10 Thread Ebert,Timothy Aaron
Can you please provide us with a copy of the error msg? I have used ggplot2 
with R 4.2.1, and probably R 4.2.0 in RStudio on Windows 11 and not had 
trouble. You might need to update R, or RStudio. R and RStudio need to be 
compatible versions.

Tim

-Original Message-
From: R-help  On Behalf Of sibylle.stoec...@gmx.ch
Sent: Monday, October 10, 2022 9:33 AM
To: R-help@r-project.org
Subject: [R] ggplot2 install.package

[External Email]

Dear R members



I am working with RStudio R 4.2.0 and using ggplot2 and gridExtra.

Since some windows updates I get some error when loading  ggplot2.

*   It seems that I am able to install ggplot2. The problem is when
loading ggplot2 with library().
*   Do you have any ideas to solve the problem?





Kind regards

Sibylle




**

install.packages("ggplot2", dependencies = TRUE)

WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:



https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2FRtools%2F&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=PKqDjS%2FEfL4Mtho3TRywJUuy%2FpGQ9A3seBjgGr6IScM%3D&reserved=0

Installiere Paket nach  C:/Users/Sibylle St 
ckli/AppData/Local/R/win-library/4.2 

(da  lib  nicht spezifiziert)

trying URL
'https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2Fcontrib%2F4.2%2Fggplot2_3.3.6.zip&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=b5dcFImQLYrE850p5SnbOyibj9KV0JrZIvfL8trNI84%3D&reserved=0'

Content type 'application/zip' length 4122980 bytes (3.9 MB)

downloaded 3.9 MB



Paket  ggplot2  erfolgreich ausgepackt und MD5 Summen abgeglichen



Die heruntergeladenen Bin rpakete sind in

C:\Users\Sibylle
St ckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages

Error in nchar(homeDir) : invalid multibyte string, element 1


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] ggplot2 install.package

2022-10-10 Thread sibylle.stoeckli
Dear R users

Thanks a lot. I will try again. The error code was below the email, but there 
was some encryption:
- Error in nchar(homeDir:invalid multibyte string, element 1
- I realised that I was able to install ggplot2, but the error is afterwards 
when loading ggplot2 (library()). 

Kind regards
Sibylle

install.packages("ggplot2", dependencies = TRUE)
WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:

Installiere Paket nach ‘C:/Users/Sibylle 
Stöckli/AppData/Local/R/win-library/4.2’
(da ‘lib’ nicht spezifiziert)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.3.6.zip'
Content type 'application/zip' length 4122980 bytes (3.9 MB)
downloaded 3.9 MB

Paket ‘ggplot2’ erfolgreich ausgepackt und MD5 Summen abgeglichen

Die heruntergeladenen Binärpakete sind in 
C:\Users\Sibylle 
Stöckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages
Error in nchar(homeDir) : invalid multibyte string, element 1

-Ursprüngliche Nachricht-
Von: Ebert,Timothy Aaron  
Gesendet: Dienstag, 11. Oktober 2022 02:42
An: sibylle.stoec...@gmx.ch; R-help@r-project.org
Betreff: RE: [R] ggplot2 install.package

Can you please provide us with a copy of the error msg? I have used ggplot2 
with R 4.2.1, and probably R 4.2.0 in RStudio on Windows 11 and not had 
trouble. You might need to update R, or RStudio. R and RStudio need to be 
compatible versions.

Tim

-Original Message-
From: R-help  On Behalf Of sibylle.stoec...@gmx.ch
Sent: Monday, October 10, 2022 9:33 AM
To: R-help@r-project.org
Subject: [R] ggplot2 install.package

[External Email]

Dear R members



I am working with RStudio R 4.2.0 and using ggplot2 and gridExtra.

Since some windows updates I get some error when loading  ggplot2.

*   It seems that I am able to install ggplot2. The problem is when
loading ggplot2 with library().
*   Do you have any ideas to solve the problem?





Kind regards

Sibylle




**

install.packages("ggplot2", dependencies = TRUE)

WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:



https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2FRtools%2F&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=PKqDjS%2FEfL4Mtho3TRywJUuy%2FpGQ9A3seBjgGr6IScM%3D&reserved=0

Installiere Paket nach  C:/Users/Sibylle St 
ckli/AppData/Local/R/win-library/4.2 

(da  lib  nicht spezifiziert)

trying URL
'https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2Fcontrib%2F4.2%2Fggplot2_3.3.6.zip&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=b5dcFImQLYrE850p5SnbOyibj9KV0JrZIvfL8trNI84%3D&reserved=0'

Content type 'application/zip' length 4122980 bytes (3.9 MB)

downloaded 3.9 MB



Paket  ggplot2  erfolgreich ausgepackt und MD5 Summen abgeglichen



Die heruntergeladenen Bin rpakete sind in

C:\Users\Sibylle
St ckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages

Error in nchar(homeDir) : invalid multibyte string, element 1


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] ggplot2 install.package

2022-10-10 Thread Spencer Graves
	  From long and unhappy experience, I routinely reboot before reporting 
problems like this, then upgrade all software where feasible ... 
including "update.packages".  Some problems magically disappear after 
doing this.



	  If they persist, then, as it says at the end of each email on this 
thread, "PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html and provide commented, 
minimal, self-contained, reproducible code."  If you do that, it 
increases the chances that the help you get will actually be helpful ;-)



  Spencer


On 10/11/22 1:01 AM, sibylle.stoec...@gmx.ch wrote:

Dear R users

Thanks a lot. I will try again. The error code was below the email, but there 
was some encryption:
- Error in nchar(homeDir:invalid multibyte string, element 1
- I realised that I was able to install ggplot2, but the error is afterwards 
when loading ggplot2 (library()).

Kind regards
Sibylle

install.packages("ggplot2", dependencies = TRUE)
WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:

Installiere Paket nach ‘C:/Users/Sibylle 
Stöckli/AppData/Local/R/win-library/4.2’
(da ‘lib’ nicht spezifiziert)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/ggplot2_3.3.6.zip'
Content type 'application/zip' length 4122980 bytes (3.9 MB)
downloaded 3.9 MB

Paket ‘ggplot2’ erfolgreich ausgepackt und MD5 Summen abgeglichen

Die heruntergeladenen Binärpakete sind in
 C:\Users\Sibylle 
Stöckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages
Error in nchar(homeDir) : invalid multibyte string, element 1

-Ursprüngliche Nachricht-
Von: Ebert,Timothy Aaron 
Gesendet: Dienstag, 11. Oktober 2022 02:42
An: sibylle.stoec...@gmx.ch; R-help@r-project.org
Betreff: RE: [R] ggplot2 install.package

Can you please provide us with a copy of the error msg? I have used ggplot2 
with R 4.2.1, and probably R 4.2.0 in RStudio on Windows 11 and not had 
trouble. You might need to update R, or RStudio. R and RStudio need to be 
compatible versions.

Tim

-Original Message-
From: R-help  On Behalf Of sibylle.stoec...@gmx.ch
Sent: Monday, October 10, 2022 9:33 AM
To: R-help@r-project.org
Subject: [R] ggplot2 install.package

[External Email]

Dear R members



I am working with RStudio R 4.2.0 and using ggplot2 and gridExtra.

Since some windows updates I get some error when loading  ggplot2.

*   It seems that I am able to install ggplot2. The problem is when
loading ggplot2 with library().
*   Do you have any ideas to solve the problem?





Kind regards

Sibylle




**

install.packages("ggplot2", dependencies = TRUE)

WARNING: Rtools is required to build R packages but is not currently installed. 
Please download and install the appropriate version of Rtools before proceeding:



https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2FRtools%2F&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=PKqDjS%2FEfL4Mtho3TRywJUuy%2FpGQ9A3seBjgGr6IScM%3D&reserved=0

Installiere Paket nach  C:/Users/Sibylle St ckli/AppData/Local/R/win-library/4.2

(da  lib  nicht spezifiziert)

trying URL
'https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2Fcontrib%2F4.2%2Fggplot2_3.3.6.zip&data=05%7C01%7Ctebert%40ufl.edu%7C05f8820150e648d4f29108daab015484%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638010323276937614%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=b5dcFImQLYrE850p5SnbOyibj9KV0JrZIvfL8trNI84%3D&reserved=0'

Content type 'application/zip' length 4122980 bytes (3.9 MB)

downloaded 3.9 MB



Paket  ggplot2  erfolgreich ausgepackt und MD5 Summen abgeglichen



Die heruntergeladenen Bin rpakete sind in

 C:\Users\Sibylle
St ckli\AppData\Local\Temp\RtmpcBknba\downloaded_packages

Error in nchar(homeDir) : invalid multibyte string, element 1


 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.