Skip to content

Commit 68377a0

Browse files
Merge pull request #2 from DiogoRibeiro7/feat/implement-features
Add goodbye function with docs and tests
2 parents 5bdb47e + d9214ee commit 68377a0

File tree

13 files changed

+119
-56
lines changed

13 files changed

+119
-56
lines changed

.Rbuildignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
^README\.md$
2+
^\.gitignore$
3+
^\.Rproj\.user$
4+
^\.Rhistory$
5+
^\.RData$
6+
^\.DS_Store$
7+
^vignettes/

DESCRIPTION

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: myrpackage
2+
Type: Package
3+
Title: A Minimal R Package
4+
Version: 0.0.0.9000
5+
Authors@R:
6+
person(given = "Diogo", family = "Ribeiro", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0009-0001-2022-7072", affiliation = "ESMAD - Instituto Politécnico do Porto"))
7+
Description: A short description of what the package does.
8+
License: MIT + file LICENSE
9+
Encoding: UTF-8
10+
LazyData: true
11+
RoxygenNote: 7.3.0

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export(hello)
2+
export(goodbye)

R/goodbye.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' Say Goodbye
2+
#'
3+
#' This function prints a friendly farewell.
4+
#'
5+
#' @return No return value, called for side effects.
6+
#' @export
7+
goodbye <- function() {
8+
print("Goodbye, world!")
9+
}

R/hello.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' Say Hello
2+
#'
3+
#' This function prints a friendly greeting.
4+
#'
5+
#' @return No return value, called for side effects.
6+
#' @export
7+
hello <- function() {
8+
print("Hello, world!")
9+
}

README.md

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ myrpackage/
1111
├── DESCRIPTION # Package metadata
1212
├── NAMESPACE # Generated from roxygen2 docs
1313
├── R/
14-
│ └── hello.R # Example R function with documentation
14+
│ ├── hello.R # Example R function with documentation
15+
│ └── goodbye.R # Another example function
1516
├── man/
16-
│ └── hello.Rd # Generated manual file
17+
│ ├── hello.Rd # Generated manual file
18+
│ └── goodbye.Rd # Manual for goodbye
1719
├── tests/
1820
│ └── testthat/
19-
│ └── test-hello.R # Unit test
21+
│ ├── test-hello.R # Unit test
22+
│ └── test-goodbye.R # Unit test
2023
│ └── testthat.R # Testthat runner setup
2124
├── vignettes/
2225
│ └── intro.Rmd # Long-form documentation (optional)
2326
├── .Rbuildignore # Files ignored during build
2427
├── .gitignore # Git ignore rules
28+
├── inst/
29+
│ └── CITATION # Citation information
2530
├── LICENSE # Open-source license (MIT recommended)
2631
└── README.md # Project overview and usage
2732
```
@@ -59,9 +64,22 @@ hello <- function() {
5964
print("Hello, world!")
6065
}
6166
```
62-
6367
---
6468

69+
## 📄 R/goodbye.R
70+
71+
```r
72+
#' Say Goodbye
73+
#'
74+
#' This function prints a friendly farewell.
75+
#'
76+
#' @return No return value, called for side effects.
77+
#' @export
78+
goodbye <- function() {
79+
print("Goodbye, world!")
80+
}
81+
```
82+
---
6583
## 🧪 tests/testthat/test-hello.R
6684

6785
```r
@@ -102,67 +120,22 @@ test_check("myrpackage")
102120
```
103121
MIT License
104122
105-
Copyright (c) 2025 Your Name
123+
Copyright (c) 2025 Diogo Ribeiro
106124
107125
Permission is hereby granted, free of charge, to any person obtaining a copy...
108126
```
109-
110127
---
111128

112-
## 📄 vignettes/intro.Rmd (Optional)
129+
## 📑 Citation
113130

114-
````rmd
115-
---
116-
title: "Getting Started with myrpackage"
117-
output: rmarkdown::html_vignette
118-
vignette: >
119-
%\VignetteIndexEntry{Getting Started}
120-
%\VignetteEngine{knitr::rmarkdown}
121-
%\VignetteEncoding{UTF-8}
122-
---
131+
To cite this package, run `citation("myrpackage")` in R. This will display the bibliographic information from `inst/CITATION`.
123132

124-
```{r setup, include = FALSE}
125-
library(myrpackage)
126-
````
127-
128-
This is an introduction to using the package.
129-
130-
````
131133

132134
---
133135

134-
## 🚀 Development Workflow
135-
136-
1. **Set up the package in RStudio or manually**:
137-
```r
138-
usethis::create_package("myrpackage")
139-
usethis::use_git()
140-
usethis::use_mit_license()
141-
usethis::use_roxygen_md()
142-
usethis::use_testthat()
143-
devtools::document()
144-
````
145-
146-
2. **Check your package**:
147-
148-
```r
149-
devtools::check()
150-
```
151-
152-
3. **Install locally**:
153-
154-
```r
155-
devtools::install()
156-
```
157-
158-
4. **Submit to CRAN**:
159-
160-
```r
161-
devtools::release()
162-
```
136+
## 📄 vignettes/intro.Rmd (Optional)
163137

138+
````rmd
164139
---
165-
166-
## ✅ Summary
167-
168-
This scaffold provides everything needed to start building an R package with good development hygiene, testing, documentation, and CRAN readiness.
140+
title: "Getting Started with myrpackage"
141+
output: rmarkdown::html_vignette

inst/CITATION

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
citHeader("To cite myrpackage in publications use:")
2+
3+
bibentry(
4+
"Manual",
5+
title = "myrpackage: A Minimal R Package",
6+
author = person(given = "Diogo", family = "Ribeiro",
7+
email = "[email protected]",
8+
role = c("aut", "cre"),
9+
comment = c(ORCID = "0009-0001-2022-7072",
10+
affiliation = "ESMAD - Instituto Politécnico do Porto")),
11+
year = format(Sys.Date(), "%Y"),
12+
note = "R package version 0.0.0.9000",
13+
url = "https://github.com/DiogoRibeiro7/myrpackage"
14+
)
15+
16+
citFooter("Please cite this package when using it.")

man/goodbye.Rd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
\name{goodbye}
2+
\alias{goodbye}
3+
\title{Say Goodbye}
4+
\usage{goodbye()}
5+
\description{This function prints a friendly farewell.}
6+
\examples{goodbye()}

man/hello.Rd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
\name{hello}
2+
\alias{hello}
3+
\title{Say Hello}
4+
\usage{hello()}
5+
\description{This function prints a friendly greeting.}
6+
\examples{hello()}

tests/testthat.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(testthat)
2+
library(myrpackage)
3+
4+
test_check("myrpackage")

0 commit comments

Comments
 (0)