Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo-N7 committed Apr 30, 2021
0 parents commit 69b3474
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^centralperk\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Rproj.user
.Rhistory
.RData
19 changes: 19 additions & 0 deletions DESCRIPTION
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
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

3 changes: 3 additions & 0 deletions NEWS.md
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.
98 changes: 98 additions & 0 deletions R/api.R
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)
54 changes: 54 additions & 0 deletions README.Rmd
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!
52 changes: 52 additions & 0 deletions README.md
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\!
22 changes: 22 additions & 0 deletions centralperk.Rproj
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
Binary file added man/figures/README-pressure-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(centralperk)

test_check("centralperk")

0 comments on commit 69b3474

Please sign in to comment.