-
-
Save vfulco/54a80c20e86f008d9341e80790958eb0 to your computer and use it in GitHub Desktop.
Revisions
-
m-Py revised this gist
Feb 9, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ # This function reads a Rmd file and returns the word count # It uses the wordcountaddin and koRpus packages text_stats_file <- function(rmdFile) { rmd <- file(rmdFile, "rt") text <- readLines(rmd) @@ -11,8 +12,7 @@ text_stats_file <- function(rmdFile) { return(wordcountaddin:::text_stats_fn_(conText)) } # This function renders a Rmd file and prints the word count render_and_count <- function(rmdFile) { rmarkdown::render(rmdFile) n_words <- text_stats_file(rmdFile)$n_words_korp -
m-Py revised this gist
Feb 9, 2017 . 1 changed file with 8 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,20 @@ # this function returns a list, better to process the word count stats text_stats_file <- function(rmdFile) { rmd <- file(rmdFile, "rt") text <- readLines(rmd) conText <- "" for (i in text) { conText <- paste(conText, i) } close(rmd) # count words - uses an internal function of the wordcountaddin package return(wordcountaddin:::text_stats_fn_(conText)) } # this function renders the Rmd file and prints the word count # (don't use this if your manuscript consists of several Rmd files) render_and_count <- function(rmdFile) { rmarkdown::render(rmdFile) n_words <- text_stats_file(rmdFile)$n_words_korp cat("\n\nword count: ", n_words, "\n\n") } -
m-Py revised this gist
May 13, 2016 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,3 +9,22 @@ text_stats_file <- function(rmdFile) { # alternatively use the function text_stats_fn_, which returns a list return(wordcountaddin:::text_stats_fn(conText)) } # this function returns a list, better to process the word count stats text_stats_file_ <- function(rmdFile) { text <- file(rmdFile, "rt") text <- readLines(text) conText <- "" for (i in text) { conText <- paste(conText, i) } # count words - uses an internal function of the wordcountaddin package return(wordcountaddin:::text_stats_fn_(conText)) } # this function renders the Rmd file and prints the word count render_and_count <- function(rmdFile) { rmarkdown::render(rmdFile) n_words <- text_stats_file_(rmdFile)$n_words_korp cat("\n\nword count: ", n_words, "\n\n") } -
m-Py revised this gist
May 12, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,5 +6,6 @@ text_stats_file <- function(rmdFile) { conText <- paste(conText, i) } # count words - uses an internal function of the wordcountaddin package # alternatively use the function text_stats_fn_, which returns a list return(wordcountaddin:::text_stats_fn(conText)) } -
m-Py revised this gist
May 12, 2016 . No changes.There are no files selected for viewing
-
m-Py created this gist
May 12, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ text_stats_file <- function(rmdFile) { text <- file(rmdFile, "rt") text <- readLines(text) conText <- "" for (i in text) { conText <- paste(conText, i) } # count words - uses an internal function of the wordcountaddin package wordcountaddin:::text_stats_fn(conText) }