hafen / trelliscopejs

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

jsonp File name too long #93

Open dbjornn opened 4 years ago

dbjornn commented 4 years ago

I'm trying to get a Trelliscope display up and running, but I keep running into an error that says there is a filename that is too long, so it can't be written. I find that it doesn't matter the size of my data, I can get it to work sometimes with a couple million rows or a few thousand.

It's consistently failing on certain variables. For example, if I limit it to a single combination of variable 1 and variable 2 to plot and I have a value of A in variable 1 and a value of B in variable 2, it will always render the display correctly along with all my cognostics. However, a value of D in variable 1 and a value of B in variable 2 will always run into this error.

I thought that the length of the name for the display (specified in the name argument) and the names of the values of my variables might be contributing to this as well as the number of directories prior to the location I was writing to (/home/ is fewer characters than /home/username/documents/project-name/project-sub-directory). To test this hypothesis, I tried to write the display to my home directory and reduced the display name as well as the two variables to single characters. Thus, the number of characters that I had control of was to an absolute minimum (write directory = /home/rstudio, display name = a, variable 1 value = A, variable 2 value = a). A screen clipping of the error on this attempt is attached.

I do have a large number of cognostics (61) I'm calculating, but that hasn't caused issues in the past with the exact same code on a different data set. It also doesn't cause problems on certain values of the two variables that are actually working. I don't know if the cognostic values are somehow contributing to the extra numbers and underscores that get put in the file name.

Here's some specs of the software I'm running: trelliscopejs = version 0.2.4 OS = Ubuntu 16.04 RStudio = Server version 1.1.383 R = version 3.4.2

Screen Shot 2020-06-24 at 12 04 56 AM

hafen commented 4 years ago

Interesting. The file names are strictly based on the conditioning variables. Are you using ggplot or the nest/map approach? A somewhat reproducible example would be helpful.

scyurt commented 4 years ago

I am having the same issue. When I use a few conditioning variables, it works fine but when I use many conditions, the file name gets too long and I get the same error. Is there a way to change the name of this auto-generated file with something shorter instead of all conditions in the name?

library(trelliscopejs)
library(ggplot2)
df <- mtcars
df$longcolumnNameConditiningValue0 <- rownames(mtcars)
df$longcolumnNameConditiningValue1 <- mtcars$disp
df$longcolumnNameConditiningValue2 <- mtcars$drat
df$longcolumnNameConditiningValue3 <- mtcars$wt
df$longcolumnNameConditiningValue4 <- mtcars$qsec

qplot(mpg, hp, data = df) +
  theme_bw() +
  facet_trelliscope(~ cyl + disp+drat+wt+qsec+vs+gear+carb+
                      longcolumnNameConditiningValue0+
                      longcolumnNameConditiningValue1+
                      longcolumnNameConditiningValue2+
                      longcolumnNameConditiningValue3+
                      longcolumnNameConditiningValue4, nrow = 2, ncol = 7, width = 300,
                      path = "files")

Error message: Error in file(file, ifelse(append, "a", "w")) : cannot open the connection

if I plot with less column and shorter column names, it works fine

df <- mtcars
df$cars <- rownames(mtcars)
qplot(mpg, hp, data = df) +
  theme_bw() +
  facet_trelliscope(~ cyl + disp+drat+wt+qsec+vs+gear+carb+
                      cars, nrow = 2, ncol = 7, width = 300,
                      path = "file")

Session info:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

other attached packages:
[1] ggplot2_3.3.2       trelliscopejs_0.2.5 gapminder_0.3.0