Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example of applying textfeatures() output to a new dataset. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion R/textfeatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#' @param normalize Logical indicating whether to normalize (mean center,
#' sd = 1) features. Defaults to TRUE.
#' @param newdata If a textfeatures_model is supplied to text, supply this with
#' new data to which you would like to apply the textfeatures_model.
#' new data to which you would like to apply the textfeatures_model. See examples
#' for how to extract the textfeatures_model from a previous \code{textfeatures()}
#' call.
#' @param verbose A single logical for printing logging messages as work
#' progresses.
#' @return A tibble data frame with extracted features as columns.
Expand Down Expand Up @@ -53,6 +55,11 @@
#' ## get text features of a data frame with "text" variable
#' textfeatures(df)
#'
#' ## Extract a `textfeatures` model for use on another dataset.
#' tf <- textfeatures(trump_tweets)
#' tf_model <- attr(tf, "tf_export", exact = TRUE)
#' textfeatures(tf_model, newdata = df$text)
#'
#' @export
textfeatures <- function(text,
sentiment = TRUE,
Expand Down