knitr::opts_chunk$set(echo = TRUE, message = FALSE, dev="svg", out.height = "500px", strip.white=TRUE ,collapse = TRUE, dev.args = list(bg="transparent") ) library(data.table)
Task | How
------------- | -------------
Read CSV | irisDT <- fread("iris.csv")
Return everything | irisDT irisDT[ ]
Select columns | irisDT[ , .(Sepal.Length, Sepal.Width) ]
Update column | irisDT[,Sepal.Area:=Sepal.Length*Sepal.Width]
Restrict rows | irisDT[ Sepal.Length >=5 , ]
Aggregate | irisDT[ , mean(Sepal.Length)]
Aggregate by group | irisDT[ , mean(Sepal.Length) , Species ]
Count | irisDT[ , .N ]
colnames<-paste0("reallyLongColumnNamesSuuuuuck",1:13000) rows<-13000 sampledt<-data.table(a=1:rows) sampledt[,c(colnames):=1] fwrite(sampledt,"sample.csv")
qRead<-fread("sample.csv") system.time( fwrite(qRead,"sample.csv"))
irisDT<-data.table(iris) knitr::kable( irisDT[, .SD[which.min(Petal.Length)] , Species])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.