Skip to content

Instantly share code, notes, and snippets.

View mkearney's full-sized avatar
📈
Data Sciencing

Michael W. Kearney mkearney

📈
Data Sciencing
View GitHub Profile
@mkearney
mkearney / split_txt.R
Last active September 22, 2016 14:20
> # generate text for txt file
> lipsum <- function() paste(sample(letters, runif(1, 3, 10)), collapse = "")
> lipsum_lines <- function() paste0(paste(replicate(10, lipsum()), collapse = " "), "\n")
>
> # create txt file
> cat(replicate(100, lipsum_lines()), file = "splitxt.txt")
>
> # read n lines from txt file
> spltxt <- readLines("splitxt.txt", n = 50)
> spltxt[1:5]
@mkearney
mkearney / save_as_csv.R
Last active August 20, 2016 17:11
rtweet save_as_csv function(s)
## this function is now included in the development version
## of rtweets. install instructions can be found on the
## package readme (or my github rtweet repo)
## Read in the following functions
save_as_csv <- function(x, file_name) {
if (missing(file_name)) {
stop("must provide file_name.", call. = FALSE)
}
lite.as.feather <- function(path){
data <- read.csv(path)
newpath <- paste0(sub(".csv", "", path), ".feather")
feather::write_feather(data, newpath)
}