mypackage files

These files contain all the code we created to populate the mypackage package.

Your Files should contain:

hello.R

R/hello.R
#' Hello World!
#'
#' Print personalised hello greeting from me.
#'
#' @param name character string. Your name!
#'
#' @return prints hello greeting to console
#' @export
#'
#' @examples
#' hello()
#' hello("Lucy Elen")
hello <- function(name = NULL) {

  # create greeting
  if(is.null(name)){name <- "world"}
  greeting <- paste("Hello", name, "from Anna!")

  # randomly sample an animal
  animal_names <- names(cowsay::animals)
  i <- sample(1:length(animal_names), 1)

  cowsay::say(greeting, animal_names[i])
}

test-hello.R

tests/testthat/test-hello.R
test_that("hello works", {
  set.seed(1)
  expect_snapshot(hello())
  expect_snapshot(hello("Lucy Elen"))
})

README.Rmd

---
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%"
)
```

# mypackage

<!-- badges: start -->
[![R-CMD-check](https://github.com/annakrystalli/mypackage/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/annakrystalli/mypackage/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of mypackage is to print a personalised greeting from me!

## Installation

You can install the development version of mypackage from GitHub with:

``` r
# install.packages("remotes")
remotes::install_github("annakrystalli/mypackage")
```

## Example

This is a basic example which shows you how to print a generic greeting:

```{r example}
library(mypackage)
## basic example code
hello()
```

This is a basic example which shows you how to print a personalised greeting:

```{r}
hello(name = "Lucy Elen")
```

DESCRIPTION

DESCRIPTION
Package: mypackage
Title: Customised greetings from me!
Version: 0.0.0.9000
Authors@R: person("Anna", "Krystalli", 
  email = "annakrystalli@googlemail.com", 
  role = c("aut", "cre"))
Description: Prints a customised greeting from myself,
  delivered by a friend.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Imports: 
    cowsay
Suggests: 
    testthat (>= 3.0.0)
Config/testthat/edition: 3
Date: 2024-04-19
URL: https://github.com/annakrystalli/mypackage
BugReports: https://github.com/annakrystalli/mypackage/issues

Final Package structure

Including all auto-generated files

.
├── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── R
│   └── hello.R
├── README.Rmd
├── README.md
├── _pkgdown.yml
├── docs
│   ├── 404.html
│   ├── LICENSE-text.html
│   ├── LICENSE.html
│   ├── authors.html
│   ├── deps
│   │   ├── bootstrap-5.3.1
│   │   ├── data-deps.txt
│   │   └── jquery-3.6.0
│   ├── index.html
│   ├── link.svg
│   ├── pkgdown.js
│   ├── pkgdown.yml
│   ├── reference
│   │   ├── Rplot001.png
│   │   ├── hello.html
│   │   └── index.html
│   ├── search.json
│   └── sitemap.xml
├── man
│   └── hello.Rd
├── project.Rproj
└── tests
    ├── testthat
    │   ├── _snaps
    │   └── test-hello.R
    └── testthat.R
Back to top