Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/rel-1739223636'
Browse files Browse the repository at this point in the history
  • Loading branch information
crunchbot committed Feb 10, 2025
2 parents 92c8192 + 11e7eec commit 719292d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/as-data-frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ csvToDataFrame <- function(csv_df,
cp <- columnParser("categorical")
}
subvar_info <- parsing_info[!is.na(parsing_info$parent_alias) & parsing_info$parent_alias == alias(v), ]

Check warning on line 198 in R/as-data-frame.R

View workflow job for this annotation

GitHub Actions / test-coverage

file=R/as-data-frame.R,line=198,col=101,[line_length_linter] Lines should not be more than 100 characters. This line is 116 characters.
cols <- csv_df[, subvar_info$qualified_alias]
cols <- csv_df[, subvar_info$qualified_alias, drop = FALSE]
if (array_strategy == "alias"){
return(structure(lapply(cols, cp, v, categorical.mode), .Names = subvar_info$cond_qualified_alias))

Check warning on line 201 in R/as-data-frame.R

View workflow job for this annotation

GitHub Actions / test-coverage

file=R/as-data-frame.R,line=201,col=101,[line_length_linter] Lines should not be more than 100 characters. This line is 115 characters.
} else if (array_strategy == "qualified_alias") {
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-as-data-frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ with_mock_crunch({
expect_equivalent(df_packed, expected_packed_df)
})

test_that("csvToDataFrame handles 1 column subvariables", {
csv_df <- structure(list(`x[x1]` = 1:3, `x[x2_derived]` = 1:3, `y[y1]` = 1:3), class = "data.frame", row.names = c(NA, -3L))
expected <- data.frame(`x[x1]` = 1:3, `x2_derived` = 1:3, `y[y1]` = factor(letters[1:3], levels = letters[1:5]), check.names = FALSE)
col_info <- csvColInfo(ds_dup)

df_actual <- csvToDataFrame(csv_df, ds_dup, col_info[6:8, ])[c("x[x1]", "x2_derived", "y[y1]")]

expect_equal(df_actual, expected)
})

test_that("as.data.frame when a variable has an apostrophe in its alias", {
t2 <- forceVariableCatalog(ds)

Expand Down

0 comments on commit 719292d

Please sign in to comment.