Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

write.csv() in dplyr chain

Tags:

file-io

r

csv

dplyr

I've come across this problem before, but just wrote the export function outside of the chain. Is there a way to include a write.csv statement within a dplyr chain?

library(dplyr)

data_set %>%
filter(Date == Sys.Date() - 1 | Date == Sys.Date()) %>%
write.csv('data_set_twodays.csv', row.names = F) %>%
filter(Date = Sys.Date()) %>%
write.csv('data_set_today.csv', row.names = F)
NULL
like image 328
maloneypatr Avatar asked May 27 '14 20:05

maloneypatr


1 Answers

This appeared to work for me in version 0.2:

mtcars %>% filter(cyl == 4) %>% write.csv(.,file = "~/Desktop/piping.csv")
like image 183
joran Avatar answered Oct 24 '22 07:10

joran