Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no such file or directory when animint(out.dir="something") #85

Open
tdhock opened this issue Mar 29, 2023 · 1 comment
Open

no such file or directory when animint(out.dir="something") #85

tdhock opened this issue Mar 29, 2023 · 1 comment

Comments

@tdhock
Copy link
Collaborator

tdhock commented Mar 29, 2023

library(animint2)
data(WorldBank)
not.na <- subset(WorldBank, !(is.na(life.expectancy) | is.na(fertility.rate)))
subset(not.na, is.na(not.na$population))
subset(not.na, country == "Kuwait" & 1991 <= year & year <= 1995)
not.na[not.na$country=="Kuwait", "population"] <- 1700000
BOTH <- function(df, top, side){
  data.frame(df,
             top=factor(top, c("Fertility rate", "Years")),
             side=factor(side, c("Years", "Life expectancy")))
}
TS <- function(df)BOTH(df, "Years", "Life expectancy")
SCATTER <- function(df)BOTH(df, "Fertility rate", "Life expectancy")
TS2 <- function(df)BOTH(df, "Fertility rate", "Years")
years <- unique(not.na[, "year", drop=FALSE])
by.country <- split(not.na, not.na$country)
min.years <- do.call(rbind, lapply(by.country, subset, year == min(year)))
min.years$year <- 1958
animint(
  ts=ggplot()+
    theme_bw()+
    theme(panel.margin=grid::unit(0, "lines"))+
    xlab("")+
    ylab("")+
    geom_tallrect(aes(
      xmin=year-1/2, xmax=year+1/2),
      clickSelects="year",
      data=TS(years), alpha=1/2)+
    theme_animint(width=1000, height=800)+
    geom_line(aes(
      year, life.expectancy, group=country, colour=region),
      clickSelects="country",
      data=TS(not.na), size=4, alpha=3/5)+
    geom_point(aes(
      year, life.expectancy, color=region, size=population),
      showSelected="country", clickSelects="country",
      data=TS(not.na))+
    geom_text(aes(
      year, life.expectancy, colour=region, label=country),
      showSelected="country",
      clickSelects="country",
      data=TS(min.years), hjust=1)+
    geom_widerect(aes(
      ymin=year-1/2, ymax=year+1/2),
      clickSelects="year",
      data=TS2(years), alpha=1/2)+
    geom_path(aes(
      fertility.rate, year, group=country, colour=region),
      clickSelects="country",
      data=TS2(not.na), size=4, alpha=3/5)+
    geom_point(aes(
      fertility.rate, year, color=region, size=population),
      showSelected="country", clickSelects="country",
      data=TS2(not.na))+
    geom_point(aes(
      fertility.rate, life.expectancy, colour=region, size=population,
      key=country), # key aesthetic for animated transitions!
      clickSelects="country",
      showSelected="year",
      data=SCATTER(not.na))+
    geom_text(aes(
      fertility.rate, life.expectancy, label=country,
      key=country), #also use key here!
      showSelected=c("country", "year", "region"),
      clickSelects="country",
      data=SCATTER(not.na))+
    scale_size_animint(breaks=10^(9:5))+
    facet_grid(side ~ top, scales="free")+
    geom_text(aes(
      5, 85, label=paste0("year = ", year),
      key=1),
      showSelected="year",
      data=SCATTER(years)),
  time=list(variable="year", ms=3000),
  duration=list(year=1000),
  first=list(year=1975, country=c("United States", "Vietnam")),
  selector.types=list(country="multiple"),
  title="World Bank data (multiple selection, facets)",
  out.dir="WorldBank-facets")

The above gives:

Error in data.table::fwrite(x, file.path(meta$out.dir, csv.name), quote = FALSE,  : 
  No such file or directory: 'WorldBank-facets/geom1_tallrect_ts_chunk1.tsv'. Unable to create new file for writing (it does not exist already). Do you have permission to write here, is there space on the disk and does the path exist?

I expected this should work and create the WorldBank-facets directory, what is going on?
This should be added as a test case.
Removing out.dir from the above code does work.

@Tushar98644
Copy link

I am not able to reproduce the issue , in my case out.dir option creates a directory for the output files if not already present (overrides the older output if present)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants