# From Steve Miller's post at
# http://www.dataversity.net/frequencies-r-part-1/
install.packages("dtplyr")
Installing package into 'C:/Users/v-thbeta/Documents/R/win-library/3.3' (as 'lib' is unspecified)
package 'dtplyr' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\v-thbeta\AppData\Local\Temp\RtmpeUeyLf\downloaded_packages
install.packages("readr")
Installing package into 'C:/Users/v-thbeta/Documents/R/win-library/3.3' (as 'lib' is unspecified)
package 'readr' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\v-thbeta\AppData\Local\Temp\RtmpeUeyLf\downloaded_packages
install.packages("pryr")
Installing package into 'C:/Users/v-thbeta/Documents/R/win-library/3.3' (as 'lib' is unspecified)
package 'pryr' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\v-thbeta\AppData\Local\Temp\RtmpeUeyLf\downloaded_packages
install.packages("feather")
Installing package into 'C:/Users/v-thbeta/Documents/R/win-library/3.3' (as 'lib' is unspecified) also installing the dependency 'hms'
package 'hms' successfully unpacked and MD5 sums checked package 'feather' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\v-thbeta\AppData\Local\Temp\RtmpeUeyLf\downloaded_packages
install.packages("data.table")
Installing package into 'C:/Users/v-thbeta/Documents/R/win-library/3.3' (as 'lib' is unspecified) also installing the dependency 'chron'
package 'chron' successfully unpacked and MD5 sums checked package 'data.table' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\v-thbeta\AppData\Local\Temp\RtmpeUeyLf\downloaded_packages
library(data.table)
library(stringr)
library(feather)
library(data.table)
suppressMessages(library(pryr))
suppressMessages(library(readr))
suppressMessages(library(dtplyr))
setwd("C://Users//v-thbeta//Desktop//examples//data//medicaid")
import(data.table)
Error in eval(expr, envir, enclos): could not find function "import" Traceback:
mkdata <- function(text)
{
slug <- strsplit(text,"[.]")[[1]][1]
len <- length(slug)
suppressMessages(cols <- names(read_tsv(text,n_max=1)))
suppressMessages(dt <- tbl_dt(read_tsv(text,skip=2,col_names=FALSE)))
setnames(dt,gsub("_", "",tolower(cols)))
df[,year:=year]
}
md_df <-rbindlist(lapply(list.files(path = ".", pattern="*.txt"), mkdata),
use.names=TRUE, fill=TRUE) %>% tbl_dt
Warning message: "10612 parsing failures. row col expected actual 695 X20 no trailing characters .7 2327 X20 no trailing characters .6 2758 X20 no trailing characters .5 3095 X20 no trailing characters .1 3780 X20 no trailing characters .1 .... ... ...................... ...... See problems(...) for more details. "
Error in `:=`(year, year): Check that is.data.table(DT) == TRUE. Otherwise, := and `:=`(...) are defined for use in j, once only and in particular ways. See help(":="). Traceback: 1. rbindlist(lapply(list.files(path = ".", pattern = "*.txt"), mkdata), . use.names = TRUE, fill = TRUE) %>% tbl_dt 2. eval(lhs, parent, parent) 3. eval(expr, envir, enclos) 4. rbindlist(lapply(list.files(path = ".", pattern = "*.txt"), mkdata), . use.names = TRUE, fill = TRUE) 5. lapply(list.files(path = ".", pattern = "*.txt"), mkdata) 6. FUN(X[[i]], ...) 7. `:=`(year, year) # at line 8 of file <text> 8. stop("Check that is.data.table(DT) == TRUE. Otherwise, := and `:=`(...) are defined for use in j, once only and in particular ways. See help(\":=\").")
help(":=")