-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69b3474
Showing
11 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
^centralperk\.Rproj$ | ||
^\.Rproj\.user$ | ||
^README\.Rmd$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[email protected]") | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# centralperk 0.0.0.9000 | ||
|
||
* Added a `NEWS.md` file to track changes to the package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<Friends-Quotes ", x$path, ">\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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
|
||
# centralperk | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# centralperk | ||
|
||
<!-- badges: start --> | ||
|
||
<!-- badges: end --> | ||
|
||
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: | ||
|
||
<img src="man/figures/README-pressure-1.png" width="100%" /> | ||
|
||
In that case, don’t forget to commit and push the resulting figure | ||
files, so they display on GitHub\! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(centralperk) | ||
|
||
test_check("centralperk") |