Skip to content

Commit 95ca0da

Browse files
committed
Minor changes to project structure.
1 parent df1bb83 commit 95ca0da

22 files changed

+392
-155
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Suggests:
1313
covr,
1414
knitr,
1515
rmarkdown,
16-
spelling
16+
spelling,
17+
usethis
1718
RoxygenNote: 6.1.1
1819
URL: https://github.com/jacobkap/meditations
1920
BugReports: https://github.com/jacobkap/meditations/issues

R/data.R

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1+
clean_data <- function() {
2+
3+
file <- system.file("inst/extdata",
4+
"meditations.txt",
5+
package = "meditations")
6+
7+
raw_book <- suppressWarnings(readLines(file))
8+
# Remove intro and closing non-book text
9+
raw_book <- raw_book[15:4315]
10+
11+
raw_book <- gsub("^BOOK.*|-----.*", "", raw_book)
12+
13+
meditations_quotes <- c()
14+
temp <- ""
15+
for (i in 1:length(raw_book)) {
16+
temp <- paste(temp, raw_book[i])
17+
if (raw_book[i] == "") {
18+
meditations_quotes <- c(meditations_quotes, temp)
19+
temp <- ""
20+
}
21+
}
22+
meditations_quotes <- trimws(meditations_quotes)
23+
meditations_quotes <- meditations_quotes[meditations_quotes != ""]
24+
meditations_quotes <- data.frame(quotes = meditations_quotes,
25+
stringsAsFactors = FALSE)
26+
usethis::use_data(meditations_quotes, internal = FALSE)
27+
}
128

229

330
#' All 507 quotes from Marcus Aurelius' book Meditations
431
#'
532
#' A dataset containing the complete list of quotes of Marcus Aurelius from Meditations
633
#'
7-
#' @format A data frame with 53940 rows and 10 variables:
34+
#' @format A data frame with 507 rows and 1 variable:
835
#' \describe{
936
#' \item{quotes}{The text of the quote}
1037
#' ...

R/main.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ meditations <- function(number = NULL) {
1919
}
2020

2121
if (is.null(number)) {
22-
return(sample(meditations_quotes$quotes, 1))
22+
return(sample(meditations::meditations_quotes$quotes, 1))
2323
} else {
24-
return(meditations_quotes$quotes[number])
24+
return(meditations::meditations_quotes$quotes[number])
2525
}
2626
}
2727

R/sysdata.rda

-62 KB
Binary file not shown.

data-raw/clean.R

-26
This file was deleted.

data/meditations_quotes.rda

-20.6 KB
Binary file not shown.

docs/404.html

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

+18-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)