The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Q & A / Troubleshooting / Tips

Q. How do I use a static scale or a fixed range for an axis?

#static #scale #axis

A.


Q. How to style the frame in which the plot is made?

#CSS #style #frame

A. The syntax to use is:

device <- animate$new(width, height, attr = list(style = MY_STYLE))

where MY_STYLE can be:


Q. I heard there is a trick for developing animated plot in a code chunk of an R Markdown Document?

#trick #inline #R Markdown Document #RMD #code chunk #workflow

A. Yes, the function below is a handy trick to set up the device and render the output in a code chunk.

animate_it <- function(..., width = 600, height = 600, options = click_to_play()) {
  # Setup
  require(animate)     # 'require' is designed for use inside functions
  device <- animate$new(width, height, virtual = TRUE, 
                        attr = list(style = "border:1px solid lightgray"))
  attach(device)       # Make methods of the device available in the namespace
  pryr::f(...)()       # Main code
  rmd_animate(device, options = options)  # Embed animated plot in R Markdown Document
}

# Usage
animate_it({
  id <- new_id(1:10)
  plot(1:10, runif(10, 0, 1), id = id)
  plot(1:10, runif(10, 0, 1), id = id, transition = TRUE)
})

Q. Are there any tips to improve the workflow developing in the R console?

#trick #R console #workflow

A. Yes, I sometimes use the following for development in the R console.

setup <- function(width = 600, height = 600) {
  require(animate)
  device <- animate$new(width, height, attr = list(style = "border:1px solid lightgray"))
  attach(device)
}

cleanup <- function() {
  clear()
  off()
  detach(device)
}


# Usage 
setup()
id <- new_id(1:10)
plot(1:10, runif(10, 0, 1), id = id)
plot(1:10, runif(10, 0, 1), id = id, transition = TRUE)
cleanup()

Q. What does set_max_stacksize do? Why does the device need memory?

#memory #advanced usage

A. set_max_stacksize sets the cap of the internal memory of the device. Memory is needed when one wants to make an animated plot and then export it to a file. This is by default switched on, since the memory usage is generally low, and it makes more sense to have a plot ready to be exported when it is complete.


These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.