jeroenjanssens / data-science-at-the-command-line

Data Science at the Command Line
https://datascienceatthecommandline.com
Other
3.8k stars 764 forks source link

Rio -d flag #41

Closed crazyhottommy closed 7 years ago

crazyhottommy commented 9 years ago

Hi there, I have a tab delimited file, and when I use Rio -d "\t" -e "summary(df)", I got some errors. cat iris.tsv | head | Rio -d"\t" -e "summary(df)" ARGUMENT '',stringsAsFactors=F);summary(df);last<-.Last.value;if(is.matrix(last)){last<-as.data.frame(last)};if(is.data.frame(last)){write.table(last,'/var/folders/h5/3xs5c90n0njgp7n9_qdwwj2m0000gn/T//Rio-fK1bGblg.png',sep=',',quote=T,qmethod='double',row.names=F,col.names=T);}else~+~if(is.vector(last)){cat(last,sep='\n',~+~file='/var/folders/h5/3xs5c90n0njgp7n9_qdwwj2m0000gn/T//Rio-fK1bGblg.png')}else~+~if(exists('is.ggplot')&&is.ggplot(last)){ggsave('/var/folders/h5/3xs5c90n0njgp7n9_qdwwj2m0000gn/T//Rio-fK1bGblg.png',last,dpi=72,units='cm',width=20,height=15);}else{sink('/var/folders/h5/3xs5c90n0njgp7n9_qdwwj2m0000gn/T//Rio-fK1bGblg.png');print(last);}' ignored

Do you have any idea? Thanks, Ming Tang

jeroenjanssens commented 9 years ago

I'm not sure, but I'm suspecting that Rscript (on line 52) doesn't like whitespace. I encountered a similar error when I wanted to break that ugly line into multiple lines. I don't know how to fix this. For now, as an intermediate solution, I hope you can use:

cat iris.tsv | head | tr "\t" , | Rio -e "summary(df)"
crazyhottommy commented 9 years ago

I know tr can do the trick, but I intentionally want Rio to work with tab delimited file, and to test that, I got a tsv file to test cat iris.csv | tr "," "\t" > iris.tsv

on line52, you may change read.csv to read.table?

Thanks. Ming

jeroenjanssens commented 7 years ago

This is a good idea, but I don't have time to implement this, so I'm closing this issue. Please submit a PR if anyone else wants to fix this.