Skip to content

Commit

Permalink
Merge branch 'release/0.3-3' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Müller committed Mar 18, 2016
2 parents 9fff95f + 3cc26eb commit 0cc8550
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 42 deletions.
1 change: 0 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
.Rprofile
inst/db
man-roxygen
NEWS\.md
demo/pandas
^\.httr-oauth$
^cran-comments\.md$
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ r:
- devel

r_github_packages:
- jimhester/covr#154
- jimhester/covr

after_success:
- Rscript -e 'covr::codecov()'
Expand Down
22 changes: 8 additions & 14 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
Encoding: UTF-8
Package: tibble
Type: Package
Version: 0.3-2
Date: 2016-03-17
Encoding: UTF-8
Version: 0.3-3
Title: Simple Data Frames
Description: Provides a 'tbl_df' class that offers better checking and
printing capabilities than traditional data frames.
Authors@R: c( person("Hadley", "Wickham", , "[email protected]", role
= "aut"), person("Romain", "Francois", ,
"[email protected]", role = "aut"), person("Kirill",
"Müller", , "[email protected]", role = c("aut", "cre")),
person("RStudio", role = "cph") )
Authors@R: c( person("Hadley", "Wickham", , "[email protected]",
"aut"), person("Romain", "Francois", ,
"[email protected]", "aut"), person("Kirill", "Müller",
, "[email protected]", c("aut", "cre")), person("RStudio",
role = "cph") )
URL: https://github.com/krlmlr/tibble
BugReports: https://github.com/krlmlr/tibble/issues
Depends: R (>= 3.1.2)
Imports: methods, assertthat, utils, lazyeval (>= 0.1.10), Rcpp
Suggests: testthat, knitr, rmarkdown, Lahman (>= 3.0.1), magrittr,
microbenchmark
LinkingTo: Rcpp
LazyData: yes
License: MIT + file LICENSE
RoxygenNote: 5.0.1
LinkingTo: Rcpp
VignetteBuilder: knitr
Collate: 'RcppExports.R' 'all-equal.r' 'rownames.R' 'dataframe.R'
'frame-data.R' 'glimpse.R' 'repair-column-names.R'
'src-local.r' 'src.r' 'tbl-df.r' 'tibble.R' 'type-sum.r'
'utils-format.r' 'utils.r'
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 0.3-3 (2016-03-18)
===

- `[[.tbl_df()` now falls back to regular subsetting when used with anything other than a single string (#29).
- When used in list-columns, S4 objects only print the class name rather than the full class hierarchy (#33).
- Further cleanup for `repair_names()`.
- Add test that `[.tbl_df()` does not change class (#41, @jennybc).


Version 0.3-2 (2016-03-17)
===

Expand Down
19 changes: 9 additions & 10 deletions R/repair-column-names.R → R/repair-names.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#' Check validity/format of a data.frame or tbl.
#' Repair object names.
#'
#' Ensure the object (e.g., tbl, data.frame or list) has legitimate and unique
#' names without leading or trailing blanks.
#' \code{repair_names} ensures its input has non-missing and
#' unique names. It also strips any leading or trailing spaces.
#' Valid names are left as is.
#'
#' The function does not change any names that are correct already.
#'
#' @param x named object
#' @param prefix character, the prefix to use for new column names
#' @param sep character, a character string to separate the terms. Not
#' \code{NA_character_}.
#' @return input with reparied names
#' @param x A named vector.
#' @param prefix A string, the prefix to use for new column names.
#' @param sep A string, inserted between the column name and de-duplicating
#' number.
#' @return \code{x} with valid names.
#' @export
#' @examples
#' repair_names(list(3, 4, 5)) # works for lists, too
Expand Down
4 changes: 2 additions & 2 deletions R/tbl-df.r
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ print.tbl_df <- function(x, ..., n = NULL, width = NULL) {

#' @export
`[[.tbl_df` <- function(x, i, exact = TRUE) {
if (is.character(i) && !(i %in% names(x)))
if (is.character(i) && length(i) == 1L && !(i %in% names(x)))
stop("Unknown name", call. = FALSE)
if (!exact) {
warning("exact ignored", call. = FALSE)
}

.subset2(x, i)
NextMethod()
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/utils-format.r
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ obj_type.default <- function(x) {
} else if (!isS4(x)) {
paste0("<S3:", paste0(class(x), collapse = ", "), ">")
} else {
paste0("<S4:", paste0(methods::is(x), collapse = ", "), ">")
paste0("<S4:", paste0(methods::is(x)[[1]], collapse = ", "), ">")
}
}

Expand Down
22 changes: 10 additions & 12 deletions man/repair_names.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/testthat/test-tbl-df.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ test_that("[ never drops", {
expect_equal(mtcars2[, 1], mtcars2[1])
})

test_that("[ retains class", {
mtcars2 <- tbl_df(mtcars)
expect_identical(class(mtcars2), class(mtcars2[1:5, ]))
expect_identical(class(mtcars2), class(mtcars2[, 1:5]))
expect_identical(class(mtcars2), class(mtcars2[1:5, 1:5]))
})

test_that("[ with 0 cols creates correct row names (#656)", {
zero_row <- tbl_df(iris)[, 0]
expect_is(zero_row, "tbl_df")
Expand All @@ -31,3 +38,9 @@ test_that("[[.tbl_df ignores exact argument",{
expect_warning(foo[["x", exact = FALSE]], "ignored")
expect_identical(getElement(foo, "y"), 1:10)
})

test_that("can use recursive indexing with [[", {
foo <- data_frame(x = list(y = 1:3, z = 4:5))
expect_equal(foo[[c(1, 1)]], 1:3)
expect_equal(foo[[c("x", "y")]], 1:3)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-trunc-mat.r
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ test_that("trunc_mat output matches known output", {
knit_cacheable = TRUE)
)
})

test_that("obj_type shows only first class name for S4", {
A <- methods::setClass("A")
expect_equal(obj_type(A), "<S4:classGeneratorFunction>")
})
1 change: 0 additions & 1 deletion tibble.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --no-build-vignettes
PackageRoxygenize: rd,collate,namespace

0 comments on commit 0cc8550

Please sign in to comment.