Skip to content

Commit

Permalink
unverify update to README file
Browse files Browse the repository at this point in the history
unverfiy update to README# Please enter the commit message for your changes. Lines starting
  • Loading branch information
jpmonteagudo28 committed Aug 1, 2024
1 parent d0dc5fa commit 3da7520
Show file tree
Hide file tree
Showing 49 changed files with 518 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
^despair\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.httr-oauth
.DS_Store
.quarto
docs
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
Package: despair
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Title: (de)Motivational quotes and Shakespearian bard–bits for use in personal projects
Version: 0.1.0
Authors@R:
person("JP", "Monteagudo",
email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0009-0003-6465-6658"))
comment = c(ORCID = "0009-0003-6465-6658"))
Maintainer: JP Monteagudo <[email protected]>
Description: This generates demotivation and motivational quotes that a user can consider for their personal projects, to mitigate the unavoidable sadness after long hours of coding, or to share with friends. The user can also supply a numeric or character seed to ensure reproducible results.
Description: This generates (de)motivational quotes and Shakespearian word combintations (bard–bits) that a user can consider for their personal projects, to mitigate the unavoidable sadness after long hours of coding, or to share with friends. The user can also supply a numeric or character seed to ensure reproducible results.
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
LazyData: true
URL: https://github.com/jpmonteagudo28/despair
BugReports: https://github.com/jpmonteagudo28/despair/issues
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(bard.bits)
export(demotivate)
export(despair.message)
export(motivate)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# despair (development version)
# despair 0.1.0

* Initial CRAN submission.
* Initial development release
95 changes: 89 additions & 6 deletions R/bard.bits.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
bard.bits <- functions(cat,
#' Generate unique bard bits using Shakespeare's work and DSM-5 adjectives
#'
#' @description
#' \code{bard.bits()} generates bard bits using Shakespeare's works and the DSM-5 to use in personal projects. The term bard–bits comes from Shakespeare's title
#' 'The Bard of Avon' and the bits ( Shakespeare's characters, places, professions) used to come up with coherent combinations.
#'
#' @details
#' When the category is 'any' (the default), the function combines Shakespeare's adjectives,
#' DSM-5 adjectives, colors and the characters, jobs, animals and things data frames
#' to then sample one adjective and one noun from each of the two combinations.
#'
#' When the category is 'alliterate', the function combines the adjectives and colors
#' data frames and the animals and characters data frame. After an adjective is selected,
#' the first letter will be used to match against a noun.
#'
#' When the category is 'character', the function will derive a bard bit from a data frame of Shakespeare's
#' characters and the adjectives data frame.
#'
#' When the category is 'jobs', the function will derive a bard bit from the adjectives and colors data frame
#' and sample one value from the Shakespeare's jobs data frame.
#'
#' When the category is 'dsm_5', the function will derive a bard bit from the combined jobs,
#' characters, animals and the DSM-5 adjectives data frame.
#'
#' @param cat a category to be used as bard–bit. Defaults to "any", but "character",
#' "jobs","alliterate", "dsm_5" are available.
#' @param seed an optional numeric or character seed for reproducible results.
#'
#' @return \code{bard.bits()} takes a category and an optional numeric or character seed
#' to produce a bard–bit.
#' @export
#'
#' @author JP Monteagudo
#'
#' @examples
#' bard.bits("any")
#' bard.bits("dsm_5", seed = 1234)
#' bard.bits("jobs", seed = "horrid antonio")
#'
bard.bits <- function(cat,
seed = NULL){

valid_cats <- c("any","character",
"jobs","alliterate")
"jobs","alliterate",
"dsm_5")

cat <- match.arg(cat,
valid_cats,
Expand All @@ -18,13 +59,55 @@ bard.bits <- functions(cat,
set.seed(seed)
}

if(cat == "any"){}
if(cat == "any"){
adjs <- rbind(shake_adjectives,shake_clrs, dsm_5)
one_adj <- sample(unique(adjs$values),1)

nouns <- rbind(shake_animals,shake_jobs,shake_things,shake_chars)
one_noun <- sample(unique(nouns$values),1)

my_bit <- paste(one_adj,one_noun)
}

if(cat == "character"){
one_adj <- sample(shake_adjectives$values,1)

one_noun <- sample(shake_chars$values,1)

my_bit <- paste(one_adj, one_noun)
}

if(cat == "jobs"){
adjs <- rbind(shake_adjectives,shake_clrs)
one_adj <- sample(unique(adjs$values),1)

if(cat = "character"){}
one_noun <- sample(shake_jobs$values,1)

if(cat = "jobs"){}
my_bit<- paste(one_adj,one_noun)
}

if(cat == "alliterate"){
adjs <- rbind(shake_adjectives, shake_clrs)
adjs <- subset(adjs, sapply(strsplit(adjs$values, " "), length) == 1)

nouns <-rbind(shake_animals, shake_chars)
one_noun <- sample(unique(nouns$values),1)
one_st <- substring(one_noun,1,1)

if(cat = "alliterate"){}
letter_match <- subset(adjs,substr(adjs$values,1,1)== one_st)
one_adj <- sample(letter_match$values,1)

my_bit <- paste(one_adj,one_noun)
}

if(cat == "dsm_5"){
nouns <- rbind(shake_jobs,shake_chars,shake_animals)
one_noun <- sample(unique(nouns$values),1)

one_adj <- sample(dsm_5$values,1)

my_bit <- paste(one_adj,one_noun)
}

return(my_bit)
}
99 changes: 88 additions & 11 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @format a data frame with 13 observations and1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"family"
Expand All @@ -15,7 +15,7 @@
#'
#' @format a data frame with 27 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"life"
Expand All @@ -26,7 +26,7 @@
#'
#' @format a data frame with 22 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"lit"
Expand All @@ -36,7 +36,7 @@
#' This is a data frame of modern and contemporary historical and pop-culture icons used in \code{motivate()}
#' @format a data frame of with 40 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"modern"
Expand All @@ -47,7 +47,7 @@
#'
#' @format a data frame with 34 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"psych"
Expand All @@ -58,7 +58,7 @@
#'
#' @format a data frame with 21 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"rednecks"
Expand All @@ -69,7 +69,7 @@
#'
#'@format a data frame with 45 observations and 1 column.
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"religion"
Expand All @@ -80,7 +80,7 @@
#'
#' @format a data frame of 27 observations and 1 column.
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"science"
Expand All @@ -91,7 +91,7 @@
#'
#' @format a data frame with 32 observations and 1 column.
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"stoic"
Expand All @@ -102,7 +102,7 @@
#'
#' @format a data frame with 23 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"tv"
Expand All @@ -113,7 +113,84 @@
#'
#' @format a data frame with 31 observations and 1 column
#' \describe{
#' \item{\code{value}}{a character vector}
#' \item{\code{values}}{a character vector}
#' }
#'
"work"

#' A data frame of Shakespeare's characters
#'
#' This is a data frame of Shakespeare's characters
#'
#' @format a data frame with 137 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_chars"

#' A data frame of Shakespeare's adjectives
#'
#' This is a data frame of adjectives used in Shakespeare's works.
#'
#' @format a data frame with 100 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_adjectives"

#' A data frame of Shakespeare's animals
#'
#' This is a data frame of animals used in Shakespeare's works
#'
#' @format a data frame with 150 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_animals"

#' A data frame of Shakespeare and unusual colors
#'
#' This is a data frame of colors used in Shakespeare's work and other unusual colors
#'
#' @format a data frame with 300 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_clrs"

#' A data frame of Shakespeare's jobs
#'
#' This is a data frame of professions used in Shakespeare's works.
#'
#' @format a data frame with 103 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_jobs"

#' A data frame of Shakespeare's objects
#'
#' This is a data frame of objects used in Shakespeare's works.
#'
#' @format a data frame with 150 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"shake_things"

#' A data frame of DSM-5 adjectives
#'
#' This is a data frame of adjectives used in the DSM-5 to describe mental states
#'
#' @format a data frame with 150 observations and 1 column
#' \describe{
#' \item{\code{values}}{a character vector}
#' }
#'
"dsm_5"
2 changes: 1 addition & 1 deletion R/demotivate.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ demotivate <- function(cat = "any",
if(cat == "family"){
my_quote <- sample(family$values,1)
}
return(cat(my_quote))
return(my_quote)
}
2 changes: 2 additions & 0 deletions R/despair_message.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Code for this function modified from package `codename` by Steven Miller under license GPL -2.

#' Display package version for \pkg{despair}
#'
#' @description \code{despair.message()} produces a message about the package version
Expand Down
2 changes: 1 addition & 1 deletion R/motivate.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ motivate <- function(cat = "any",
if(cat == "lit"){
my_quote <- sample(lit$values,1)
}
return(cat(my_quote))
return(my_quote)
}
13 changes: 8 additions & 5 deletions R/set.char.seed.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Code for this function modified from package `codename` by Steven Miller under license GPL -2.

#' Convert any character vector to an integer for setting a reproducible seed
#'
#' @description
Expand All @@ -9,7 +11,7 @@
#' numbers are concatenated and divided by 2^39 - 1, and the remainder of this division
#' is used as the numeric reproducible seed.
#'
#' If you get a warning about 'loss of accuracy", consider using a more succint character
#' If you get a warning about 'loss of accuracy", consider using a more succinct character
#' vector, otherwise you may get a seed of 0.
#'
#' @param char a character vector
Expand All @@ -18,6 +20,8 @@
#'
#' @author JP Monteagudo
#'
#' @keywords internals
#'
#'
#' @examples
#' set.char.seed("The Sticky Chicken")
Expand All @@ -30,14 +34,13 @@ set.char.seed <- function(char) {
names(temp) <- c(LETTERS, letters, 0:9)

char <- gsub("[^0-9a-zA-Z]","",as.character(char))
char_split <- temp[ strsplit(char,'')[[1]] ]
char_split
split_it <- temp[ strsplit(char,'')[[1]] ]
split_it

num_seed <- as.numeric(paste(char_split, collapse=""))
num_seed <- as.numeric(paste(split_it, collapse=""))
num_seed

seed <- as.integer( num_seed %% (2^31-1) )
return(seed)

}

Loading

0 comments on commit 3da7520

Please sign in to comment.