diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..c83486b --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,3 @@ +^centralperk\.Rproj$ +^\.Rproj\.user$ +^README\.Rmd$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..807ea25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.Rproj.user +.Rhistory +.RData diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..43e6398 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,19 @@ +Package: centralperk +Title: What the Package Does (One Line, Title Case) +Version: 0.0.0.9000 +Authors@R: + person(given = "Ryo", + family = "Nakagawara", + role = c("aut", "cre"), + email = "ryonakagawara@gmail.com") +Description: What the package does (one paragraph). +License: `use_mit_license()`, `use_gpl3_license()` or friends to + pick a license +Encoding: UTF-8 +LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.1.1 +Suggests: + testthat +Imports: + httr diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6ae9268 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,2 @@ +# Generated by roxygen2: do not edit by hand + diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..97e0182 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# centralperk 0.0.0.9000 + +* Added a `NEWS.md` file to track changes to the package. diff --git a/R/api.R b/R/api.R new file mode 100644 index 0000000..1bbcf51 --- /dev/null +++ b/R/api.R @@ -0,0 +1,98 @@ +friends_quotes_api <- function(path) { + + #path <- "random" + + base_url <- "https://friends-quotes-api.herokuapp.com" + + if (path != "quotes" & path != "") { + path <- paste0("/quotes/", path) + } + + if (path == "") { + path <- "/quotes/" + } + + set_url <- httr::modify_url(base_url, path = path) + ua <- httr::user_agent("https://github.com/Ryo-N7/centralperk") + + + resp <- httr::GET(set_url, ua) + + + structure( + list( + content = httr::content(resp), + path = path, + response = resp + ), + class = "friends_quotes_api" + ) + +} + + +print.friends_quotes_api <- function(x, ...) { + cat("\n", sep = "") + utils::str(x$content) + invisible(x) +} + +print.centralperk <- function(x, ...) { + cat("\n", + x$quote, + "\n\n", + paste(">", x$character)) +} + + + +single_character <- function(character) { + allquotes <- friends_quotes_api("")$content + char_list <- map(allquotes, "character") %>% unlist() + names(allquotes) <- char_list + char_index <- which(names(allquotes) == character) + char_index_random <- sample(char_index, 1) + single_quote <- pluck(allquotes, char_index_random) + structure(single_quote, class = "centralperk") + + + + + asdf <- as_tibble(allquotes, .name_repair = "minimal") + + names(asdf) <- char_list + + asdf %>% select(contains("Jo")) + + + + + + + + names(allquotes) <- char_list + + allquotes[["Joey"]] + + structure(friends_quotes_api("")$content, class = "centralperk") +} + + +centralperk <- function() { + structure(friends_quotes_api("random")$content, class = "centralperk") +} + + + + + +contento <- httr::content(resp, as = "text") + + + + + +httr::GET(url = "https://friends-quotes-api.herokuapp.com/quotes/random") -> elrespon + + +httr::content(elrespon) diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..d28a615 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,54 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# centralperk + + + + +The goal of centralperk is to ... + +## Installation + +You can install the released version of centralperk from [CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("centralperk") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +```{r example} +#library(centralperk) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: + +```{r cars} +summary(cars) +``` + +You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. + +You can also embed plots, for example: + +```{r pressure, echo = FALSE} +plot(pressure) +``` + +In that case, don't forget to commit and push the resulting figure files, so they display on GitHub! diff --git a/README.md b/README.md new file mode 100644 index 0000000..56ee07d --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ + + + +# centralperk + + + + + +The goal of centralperk is to … + +## Installation + +You can install the released version of centralperk from +[CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("centralperk") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +``` r +#library(centralperk) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? +You can include R chunks like so: + +``` r +summary(cars) +#> speed dist +#> Min. : 4.0 Min. : 2.00 +#> 1st Qu.:12.0 1st Qu.: 26.00 +#> Median :15.0 Median : 36.00 +#> Mean :15.4 Mean : 42.98 +#> 3rd Qu.:19.0 3rd Qu.: 56.00 +#> Max. :25.0 Max. :120.00 +``` + +You’ll still need to render `README.Rmd` regularly, to keep `README.md` +up-to-date. + +You can also embed plots, for example: + + + +In that case, don’t forget to commit and push the resulting figure +files, so they display on GitHub\! diff --git a/centralperk.Rproj b/centralperk.Rproj new file mode 100644 index 0000000..69fafd4 --- /dev/null +++ b/centralperk.Rproj @@ -0,0 +1,22 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/man/figures/README-pressure-1.png b/man/figures/README-pressure-1.png new file mode 100644 index 0000000..c092055 Binary files /dev/null and b/man/figures/README-pressure-1.png differ diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..032cfb2 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(centralperk) + +test_check("centralperk")