rDevices_rpng: rpng

Description Usage Arguments Details See Also Examples

Description

Provide a graphic device locally for plots generated on server of Remote R

rpng() generates locally a device/window.

rpng.new() generates locally a device/window.

rpng.off() turns off locally a device/window.

dev.off() is an alias of rpng.off() in order to consisten with th original device function grDevices::dev.off().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
rpng.new(
  expr,
  filename = NULL,
  width = 587,
  height = 586,
  units = "px",
  pointsize = 12,
  bg = "white",
  res = 96,
  ...
)

rpng.off(which = grDevices::dev.cur())

dev.off(which = grDevices::dev.cur())

Arguments

expr

An expression or a function generating a plot. This checks in the following orders: expression or ggplot. The ggplot are eval'd within the rpng.new(), while the expression is eval'd at parent.frame().

filename

A temporary file to save the plot on server

width

width of the plot as in grDevices::png()

height

height of the plot as in grDevices::png()

units

units of the width and height as in grDevices::png()

pointsize

pointsze of the plotted text as in grDevices::png()

bg

background colour as in grDevices::png()

res

resolution as in grDevices::png()

...

additional arguments as in grDevices::png()

which

An integer specifying a device number as in grDevices::dev.off()

Details

Remote R PNG Device

See Also

rDevices

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Not run: 
### Prompts are listed to clarify when something is eval'd locally vs
### remotely
> # suppressMessages(library(remoter, quietly = TRUE))
> # client()
> remoter::client("192.168.56.101")

### Regular R plotting
remoter> plot(1:5)
remoter> rpng.off()

### Manually open a remoting plotting device
remoter> rpng()
remoter> plot(iris$Sepal.Length, iris$Petal.Length)
remoter> rpng.off()

### Work with ggplot2-like plotting
remoter> library(ggplot2)
remoter> g1 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length,
remoter+              color = Species)) +
remoter+       geom_point(aes(shape = Species))

### Method 1a
remoter> rpng()
remoter> print(g1)
remoter> rpng.off()

### Method 1b
remoter> rpng()
remoter> print(g1 + geom_line())
remoter> rpng.off()

### Method 1c
remoter> g1 + geom_smooth(method = "lm")

### Testing aside
remoter> rpng.new(plot(1:5))

### Method 1d
remoter> rpng.new(g1)

### Testing again
remoter> b <- function() plot(iris$Sepal.Length, iris$Petal.Length)
remoter> rpng.new(b)

### Work with other plotting device
remoter> da <- data.frame(x = rnorm(100), y = rnorm(100))
remoter> g2 <- ggplot(da, aes(x, y)) + geom_point()

### Save on the server
remoter> pdf()
remoter> g2
remoter> print(g2 + geom_line())
remoter> dev.off()

### Testing for errors with ggplot
remoter> g3 <- ggplot(da, aes(x, yy)) + geom_point()
remoter> g3

remoter> rpng()
remoter> print(g3)
remoter> rpng.off()

### Disconnect the server and keep it alive
remoter> q()
>

## End(Not run)

wrathematics/remoter documentation built on Nov. 21, 2021, 2:30 a.m.