Skip to contents

Parse all user data

Usage

parse_users_chat_data(
  csv_file = NULL,
  dat = NULL,
  idcol = "ResponseId",
  chat_col_patterns = c("chathistory"),
  chat_cols = "",
  join_str = "\"\"",
  nrows = Inf,
  verbose = FALSE
)

Arguments

csv_file

Path to csv file in character. Defaults to NULL.

dat

Dataframe/tibble with raw chat data in one or more columns. Defaults to NULL.

idcol

Name of column that is the user ID column in character. Must contain unique values.

chat_col_patterns

Patterns to match chat columns in character. Defaults to "chathistory".

chat_cols

Chat columns in character. Defaults "". If specified, overwrites chat_col_patterns.

join_str

Join string in character. Defaults to '\"\"'.

nrows

Number of rows to process. Defaults to Inf. Use fewer rows to debug the function/parser.

verbose

Whether to print processing status. Defaults to FALSE.

Value

A list with the following keys:

info

A vector indicating total number of rows processed, number of success/error/warning parses.

info_df

A dataframe/tibble with info on each user's chat data, where the status column indicates parsing status and mobile column indicates mobile (1) or not (0).

json_list

A list of JSON data for each user. Contains full data and can be a very large list.

df_success

A dataframe/tibble with successful parses. Contains only chat messages and not other data.

df_fail

A dataframe/tibble with failed parses. Contains only chat messages and not other data.

Examples

csv_file <- file.path(system.file("extdata", package = "chatlogr"), "mtcars.csv")
chatdata <- parse_users_chat_data(csv_file, idcol = "user_id")
#> Processing 32 rows...
#> Chat columns: chathistory1, chathistory2
#> Parsing summary
#>    total  success   errors warnings 
#>       32        0       32        0