Skip to content

Commit 314b9d7

Browse files
author
JooYoung Seo
committed
Use tidyverse style
1 parent 6b03093 commit 314b9d7

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

R/merge_mbox_all.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ merge_mbox_all <-
3838
function(path = ".", file = NULL) { # Function starts:
3939

4040
if (length(list.files(path, pattern = "(*.mbox)$")) > 0) {
41-
# if (path != ".") {
42-
# current_wd <- getwd()
43-
# setwd(path)
44-
# }
41+
# if (path != ".") {
42+
# current_wd <- getwd()
43+
# setwd(path)
44+
# }
4545

4646
multi_mbox <- list.files(path, pattern = "(*.mbox)$") %>%
4747
purrr::map_df(~ mboxr::read_mbox(.))
4848

49-
# if (path != ".") {
50-
# setwd(current_wd)
51-
# }
49+
# if (path != ".") {
50+
# setwd(current_wd)
51+
# }
5252

5353
if (!is.null(file)) {
5454
fileExt <- tolower(tools::file_ext(file))
@@ -61,7 +61,7 @@ merge_mbox_all <-
6161
}
6262
}
6363

64-
class(multi_mbox) <- c("mbox_df", class(multi_mbox))
64+
class(multi_mbox) <- c("mbox_df", class(multi_mbox))
6565
return(multi_mbox)
6666
} else {
6767
stop("No mbox file is found in the current directory.")

R/preprocessing.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
# Remove carriage return and trim white spaces in subject line
55
trim_subject <- function(mbox_df) {
6-
if(!inherits(mbox_df, "mbox_df")) {
7-
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
8-
}
6+
if (!inherits(mbox_df, "mbox_df")) {
7+
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
8+
}
99

10-
mbox_df %>%
11-
dplyr::mutate(subject = stringr::str_replace_all(string = subject, pattern = "[[:cntrl:]]+", replacement = " ")) %>%
12-
dplyr::mutate(subject = stringr::str_replace_all(string = subject, pattern = "[[:space:]]+", replacement = " "))
10+
mbox_df %>%
11+
dplyr::mutate(subject = stringr::str_replace_all(string = subject, pattern = "[[:cntrl:]]+", replacement = " ")) %>%
12+
dplyr::mutate(subject = stringr::str_replace_all(string = subject, pattern = "[[:space:]]+", replacement = " "))
1313
}
14-

R/thread.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@
3030
#' @author Soyoung Choi, \email{[email protected]}
3131

3232
num_thread <- function(mbox_df) {
33-
if(!inherits(mbox_df, "mbox_df")) {
34-
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
35-
}
33+
if (!inherits(mbox_df, "mbox_df")) {
34+
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
35+
}
3636

3737
mbox_df %>%
38-
is_thread() %>%
39-
sum(., na.rm = TRUE)
38+
is_thread() %>%
39+
sum(., na.rm = TRUE)
4040
}
4141

4242

4343
#' @rdname num_thread
4444
#' @export
4545

4646
is_thread <- function(mbox_df) {
47-
if(!inherits(mbox_df, "mbox_df")) {
48-
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
49-
}
47+
if (!inherits(mbox_df, "mbox_df")) {
48+
stop("You need an mbox_df object for this function: Convert your mbox file through `read_mbox()` first.")
49+
}
5050

5151
mbox_df$num_discussants > 1
5252
}

0 commit comments

Comments
 (0)