ggobi / tourr

A implementation of tour algorithms in R
http://ggobi.github.io/tourr/
Other
65 stars 21 forks source link

render_gif generates an error when generated frames are less than the frames argument specified #114

Closed huizezhang-sherry closed 2 years ago

huizezhang-sherry commented 2 years ago

An error with render_gif():

library(tourr)
set.seed(123)
gif_file <- file.path(tempdir(), "test.gif")
tourr::render_gif(
  flea[1:6],
  tour_path = guided_tour(holes()),
  display = display_xy(),
  frames = 70,
  gif_file = gif_file
)
#> Converting input data to the required matrix format.
#> Value  0.538   43.4 % better  - NEW BASIS
#> Using half_range 0.98
#> Value  0.730   35.6 % better  - NEW BASIS
#> Value  0.780   6.8 % better  - NEW BASIS
#> Value  0.846   8.5 % better  - NEW BASIS
#> Value  0.872   3.2 % better  - NEW BASIS
#> Value  0.883   1.3 % better  - NEW BASIS
#> Value  0.887   0.4 % better  - NEW BASIS
#> Value  0.891   0.5 % better  - NEW BASIS
#> Value  0.897   0.7 % better  - NEW BASIS
#> Value  0.903   0.7 % better  - NEW BASIS
#> Value  0.906   0.3 % better  - NEW BASIS
#> Value  0.906   0.0 % better 
#> Value  0.910   0.5 % better  - NEW BASIS
#> Value  0.910   0.0 % better 
#> Value  0.912   0.3 % better  - NEW BASIS
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#> 0.333  0.486  
#> 0.338  -0.344  
#> 0.412  -0.189  
#> 0.381  -0.337  
#> 0.467  0.644  
#> 0.492  -0.285
#> Error in normalizePath(png_files, mustWork = TRUE): path[61]="/var/folders/_t/v9kjp3yn2k73wm16y_jlphgsbbd6_6/T//Rtmph3qiEy/frame061.png": No such file or directory

Created on 2022-10-06 by the reprex package (v2.0.1)

This is because only 60 frames are generated with this guided tour configeration while 70 frames are asked to be rendered. This can be validated by usingtourr::render():

library(tourr)
set.seed(123)
png_files <- file.path(tempdir(), "test-%03d.png")
tourr::render(
  data = flea[,1:6],
  tour_path = guided_tour(holes()),
  display = display_xy(),
  frames = 100, "png",
  png_files)
#> Converting input data to the required matrix format.
#> Value  0.538   43.4 % better  - NEW BASIS
#> Using half_range 0.98
#> Value  0.730   35.6 % better  - NEW BASIS
#> Value  0.780   6.8 % better  - NEW BASIS
#> Value  0.846   8.5 % better  - NEW BASIS
#> Value  0.872   3.2 % better  - NEW BASIS
#> Value  0.883   1.3 % better  - NEW BASIS
#> Value  0.887   0.4 % better  - NEW BASIS
#> Value  0.891   0.5 % better  - NEW BASIS
#> Value  0.897   0.7 % better  - NEW BASIS
#> Value  0.903   0.7 % better  - NEW BASIS
#> Value  0.906   0.3 % better  - NEW BASIS
#> Value  0.906   0.0 % better 
#> Value  0.910   0.5 % better  - NEW BASIS
#> Value  0.910   0.0 % better 
#> Value  0.912   0.3 % better  - NEW BASIS
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.1 % better 
#> Value  0.913   0.0 % better 
#> Value  0.913   0.0 % better 
#> No better bases found after 25 tries.  Giving up.
#> Final projection: 
#> 0.333  0.486  
#> 0.338  -0.344  
#> 0.412  -0.189  
#> 0.381  -0.337  
#> 0.467  0.644  
#> 0.492  -0.285
length(list.files(tempdir()))
#> [1] 60

Created on 2022-10-06 by the reprex package (v2.0.1)