0

Splitting a large table into smaller ones, I tried to export all my output as .csv and then as .doc files. My code works for the first but not for the second.

####Given a Tibble called data:

namen <- unique(data$Fundort)
for (i in 1:length(unique(data$Fundort))) {
  dat <- data %>%
    filter(Fundort == namen[i], Familie == 'Apidae', Nachweistyp == 'Fang: Handfang') %>%
    select(c('Art','Anzahl','Datum')) %>%
    group_by(Art) %>%
    summarise (Anzahl = sum (Anzahl)) %>%
    left_join(status, by = 'Art')
  write.table(dat, paste("daten", namen[i],'.csv', sep = ""), sep = ';', na = '', row.names = FALSE)
  tab_df(dat, file = paste("daten", namen[i],'.doc', sep = ""))
}

This code outputs a number of '.csv' files, which I expected to be accompanied by '.doc' files. Instead I only get the csv and no trace of the doc

I would like to add that the code in question works for individual files outside of the loop, so I can't see how I can fix this.

Tuck
  • 3
  • 2
  • I solved this making a list of tables and applying tab_dfs(). Still don't really get why the first option wouldn't work though. – Tuck Jan 16 '23 at 13:27

0 Answers0