Skip to contents

Get and view chat history of a user

Usage

get_user_chat(chatdata, user_id = NULL, random_user = FALSE)

Arguments

chatdata

Chat data list object from parse_users_chat_data or chat history dataframe.

user_id

A user ID in character. Default is NULL.

random_user

A logical value. If TRUE, a random user will be selected. Default is FALSE.

Value

Chat history of a user in a tibble.

Examples

# read and process raw data
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 

# pass in chatdata list object
get_user_chat(chatdata, user_id = 1)
#> Chat history for user 1
#> --------------------
#> NA (1 words): ab
#> 
#> --------------------
#> # A tibble: 1 × 6
#>   user_id role  content createdAt id    n_words
#>     <dbl> <lgl> <chr>   <lgl>     <lgl>   <int>
#> 1       1 NA    ab      NA        NA          1

# pass in chat history dataframe
get_user_chat(chatdata$df_success, user_id = 1)
#> Chat history for user 1
#> --------------------
#> NA (NA words): NA
#> 
#>  ( words): 
#> 
#> --------------------
#> # A tibble: 0 × 6
#> # ℹ 6 variables: user_id <dbl>, role <lgl>, content <chr>, createdAt <lgl>,
#> #   id <lgl>, n_words <int>