Introduction
The myrpackage
package provides simple greeting
functions that demonstrate proper R package structure and documentation.
This vignette introduces the main functionality of the package and shows
examples of how to use it.
Basic Usage
The package contains two main functions:
Saying Hello
The hello()
function generates a friendly greeting. By
default, it says “Hello, world!”:
hello()
#> Hello, world!
You can customize the greeting with a different name:
hello("R Users")
#> Hello, R Users!
Multilingual Greetings
Both functions support multiple languages. Currently supported languages are:
- English (default)
- Spanish
- French
- Portuguese
- German
- Italian
Here are examples of greetings in different languages:
Capitalizing Names
You can capitalize the first letter of the name:
hello("r users", capitalize = TRUE)
#> Hello, R users!
Error Handling
Both functions include input validation and helpful error messages:
# These will generate errors:
hello(name = c("world", "everyone"))
#> Error in hello(name = c("world", "everyone")): 'name' must be a single character string
hello(exclamation = "yes")
#> Error in hello(exclamation = "yes"): 'exclamation' must be a single logical value
The functions also provide helpful warnings when unsupported languages are requested:
hello("world", language = "klingon")
#> Warning in hello("world", language = "klingon"): Language 'klingon' not
#> supported. Using English instead. Supported languages: english, spanish,
#> french, portuguese, german, italian
#> Hello, world!
Further Reading
For complete details about function arguments and behavior, refer to the function documentation:
?hello
?goodbye
For more advanced usage patterns, see the “Advanced Usage” vignette:
vignette("advanced", package = "myrpackage")
Conclusion
myrpackage
is a simple demonstration package that
showcases proper R package development practices. It includes:
- Well-documented functions
- Comprehensive tests
- Properly structured package components
- Vignettes for user documentation
- Input validation and error handling
While the functionality is minimal, the package structure follows best practices for R package development.