Skip to content

Commit 5e14c60

Browse files
committed
NB language support to table functions
1 parent 8a69909 commit 5e14c60

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Description: The package provides functions to easily create descriptive summary
88
License: GPL (>= 3)
99
Encoding: UTF-8
1010
Roxygen: list(markdown = TRUE)
11-
RoxygenNote: 7.2.0
11+
RoxygenNote: 7.2.3
1212
Imports:
1313
stats,
1414
utils,

R/oppsum_grupp.R

+12-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#' 10 unique categories).
2020
#' @param export Should the result be made export-ready (TRUE/FALSE)?
2121
#'
22+
#' @param norsk Results in Norwegian (NB)?
23+
#'
2224
#' @return A data.frame or, if export function is switched on (export=TRUE), a
2325
#' printed out table formatted for easy export to MS Word.
2426
#'
@@ -44,7 +46,7 @@
4446
#'
4547
#'
4648
#' @export
47-
oppsum_grupp <- function(dataset,variable,by.var,export=NULL){
49+
oppsum_grupp <- function(dataset,variable,by.var,export=NULL,norsk=NULL){
4850

4951
# Helper function
5052
stop_quietly <- function() {
@@ -215,10 +217,15 @@ oppsum_grupp <- function(dataset,variable,by.var,export=NULL){
215217
rm(avg,sd,med,q25,q75,min,max,nas,obs)
216218

217219
# Pretty output
218-
colnames(bytabell) <- c(by.var,"Observations",
219-
"Average","Stand. Dev.","25th percentile",
220-
"Median","75th percentile","Minimum","Maximum",
221-
"Missing")
220+
if(isTRUE(norsk)){
221+
colnames(bytabell) <- c(by.var,"Observasjoner","Gjennomsnitt","25. persentil","Median",
222+
"75. persentil","Standardavvik","Minimum","Maksimum","Manglende")
223+
}else{
224+
colnames(bytabell) <- c(by.var,"Observations",
225+
"Average","Stand. Dev.","25th percentile",
226+
"Median","75th percentile","Minimum","Maximum",
227+
"Missing")
228+
}
222229

223230
if(export==T){
224231
return(utils::write.table(format(bytabell,digits=2,nsmall=2),

R/oppsumtabell.R

+10-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#' be used.
1919
#' @param export Should the table be made export-ready (TRUE/FALSE)?
2020
#'
21+
#' @param norsk Results in Norwegian (NB)?
22+
#'
2123
#' @return A data.frame or, if export function is switched on (export=TRUE), a
2224
#' printed out table formatted for easy export to MS Word.
2325
#'
@@ -45,7 +47,7 @@
4547
#' @importFrom utils write.table
4648
#'
4749
#' @export
48-
oppsumtabell <- function(dataset,variables=NULL,variable=NULL,export=NULL) {
50+
oppsumtabell <- function(dataset,variables=NULL,variable=NULL,export=NULL,norsk=NULL) {
4951

5052
# Helper function (from https://stackoverflow.com/questions/14469522/stop-an-r-program-without-error)
5153
stop_quietly <- function() {
@@ -73,8 +75,13 @@ oppsumtabell <- function(dataset,variables=NULL,variable=NULL,export=NULL) {
7375
}
7476

7577
# Labels
76-
stats <- c("Observations","Average","25th percentile","Median","75th percentile",
77-
"Stand. Dev.","Minimum","Maximum","Missing")
78+
if(isTRUE(norsk)){
79+
stats <- c("Observasjoner","Gjennomsnitt","25. persentil","Median",
80+
"75. persentil","Standardavvik","Minimum","Maksimum","Manglende")
81+
}else{
82+
stats <- c("Observations","Average","25th percentile","Median","75th percentile",
83+
"Stand. Dev.","Minimum","Maximum","Missing")
84+
}
7885

7986
# Set default
8087
if(is.null(export)){

man/oppsum_grupp.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/oppsumtabell.Rd

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)