Skip to content

Commit e105b61

Browse files
committed
updated function
1 parent b80defe commit e105b61

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

‎R/top3_df.R‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#' @srrstats {G1.4} roxygen2 used to document functions
44
#' @inheritParams concstats_top_df
55
#' @return A `data frame`.
6+
#' @note Note that the first column in your data frame will be the index
7+
#' and values should be unique.
68
#' @family Market structure measures
79
#' @rdname concstats_top3_df
810
#' @examples
@@ -27,6 +29,12 @@ concstats_top3_df <- function(x, y, digits = NULL) {
2729

2830
x <- tibble::as_tibble(x)
2931

32+
#' @srrstats {EA2.0, EA2.1, EA2.2, EA2.2b}
33+
attr(x, "index") <- x[[1]]
34+
if (anyDuplicated(x[[1]])) {
35+
stop("Your first column has duplicated values")
36+
}
37+
3038
#' @srrstats {G2.10, G2.11, G2.12} data frame pre-processing
3139
if (anyNA(x)) {
3240
message(paste("NA values have been removed before the calculation for the following variable: ", y))

‎R/top5_df.R‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#' @srrstats {G1.4} roxygen2 used to document functions
44
#' @inheritParams concstats_top_df
55
#' @return A `data frame`.
6+
#' @note Note that the first column in your data frame will be the index
7+
#' and values should be unique.
68
#' @family Market structure measures
79
#' @rdname concstats_top5_df
810
#'
@@ -15,10 +17,10 @@
1517
#'
1618
#' @export
1719
concstats_top5_df <- function(x, y, digits = NULL) {
18-
#' @srrstats {G2.1} Assertions on types of inputs
19-
#' @srrstats {G5.8a} Zero-length data
20-
#' @srrstats {G2.2, G2.6, G2.7, G2.16} Checking class, type, NaN handling
21-
#' @srrstats {EA2.6}
20+
#' @srrstats {G2.1} Assertions on types of inputs
21+
#' @srrstats {G5.8a} Zero-length data
22+
#' @srrstats {G2.2, G2.6, G2.7, G2.16} Checking class, type, NaN handling
23+
#' @srrstats {EA2.6}
2224
# Checking if an argument is a data frame with specific column names
2325
checkmate::assert_data_frame(x, types = c("numeric", "character"),
2426
col.names = "unique",
@@ -28,7 +30,13 @@ concstats_top5_df <- function(x, y, digits = NULL) {
2830

2931
x <- tibble::as_tibble(x)
3032

31-
#' @srrstats {G2.10, G2.11, G2.12} data frame pre-processing
33+
#' @srrstats {EA2.0, EA2.1, EA2.2, EA2.2b}
34+
attr(x, "index") <- x[[1]]
35+
if (anyDuplicated(x[[1]])) {
36+
stop("Your first column has duplicated values")
37+
}
38+
39+
#' @srrstats {G2.10, G2.11, G2.12} data frame pre-processing
3240
if (anyNA(x)) {
3341
message(paste("NA values have been removed before the calculation for the following variable: ", y))
3442
}

‎R/top_df.R‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#' restricted between 1 and default value.
1313
#' @return A `data frame`.
1414
#'
15+
#' @note Note that the first column in your data frame will be the index
16+
#' and values should be unique.
17+
#'
1518
#' @family Market structure measures
1619
#' @rdname concstats_top_df
1720
#' @importFrom stats na.omit
@@ -40,6 +43,12 @@ concstats_top_df <- function(x, y, digits = NULL) {
4043

4144
x <- tibble::as_tibble(x)
4245

46+
#' @srrstats {EA2.0, EA2.1, EA2.2, EA2.2b}
47+
attr(x, "index") <- x[[1]]
48+
if (anyDuplicated(x[[1]])) {
49+
stop("Your first column has duplicated values")
50+
}
51+
4352
#' @srrstats {G2.10, G2.11, G2.12} data frame pre-processing
4453
if (anyNA(x)) {
4554
message(paste("NA values have been removed before the calculation for the following variable: ", y))

0 commit comments

Comments
 (0)