hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
262 stars 36 forks source link

Relative path error when creating trelliscope visualization from R Markdown #104

Open kaneplusplus opened 3 years ago

kaneplusplus commented 3 years ago

Please note that this appears to be related to, but not quite the same as, issue #13. The following R Markdown header:

---
title: "Trelliscope Test"
output: 
  html_document:
    self_contained: no
---

with the body

library(ggplot2)
library(trelliscopejs)
library(tidyr)
library(dplyr)
library(purrr)

iris %>% 
  nest(data = -Species) %>%
  mutate(panel_col = map(data, ~ ggplot(.x, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point())) %>%
  trelliscope(name = "iris-test", panel_col = "panel_col", path = "../iris-test", self_contained = TRUE) 

Gives the error:

Error: Path for trelliscope output while inside knitr or Shiny must be
       relative.

Please note that the trelliscope output path provided "../iris-test" is relative.

kaneplusplus commented 3 years ago

As a follow up, it looks like the error emanates from helpers.R, line 105. The grep() statement on 104 defines a relative path as one that starts with a letter, number, or underscore.

Are there constraints on the construction of a trelliscope object such that it has to be within orig_path? If not, {xfun} has a function, is_abs_path() that could be used directly or would be a good basis for a replacement.