Skip to content

Commit

Permalink
patched is_list(), fixes #35, updated vignette, fixes #36, bumped ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
nteetor committed Jan 27, 2018
1 parent 327abf3 commit 767aade
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: zeallot
Type: Package
Title: Multiple, Unpacking, and Destructuring Assignment
Version: 0.0.6
Version: 0.1.0
Authors@R: c(
person(given = "Nathan", family = "Teetor", email = "nathanteetor@gmail.com", role = c("aut", "cre")),
person(given = "Paul", family = "Teetor", role = "ctb"))
Expand Down
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# zeallot 0.1.0

## Major Improvements

* Bumped to stable version.

## Minor Improvements

* Removed outdate language in the unpacking assignment vignette. (#36)

## Bug Fixes

* Destructuring objects with multiple classes will no longer raise a
warning. (#35)

# zeallot 0.0.6.1

## Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
is_list <- function(x) {
class(x) == 'list'
length(class(x)) == 1 && class(x) == 'list'
}

car <- function(cons) {
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ test_that("is_list returns TRUE for list object", {
expect_true(is_list(list(1, 2, 3)))
})

test_that("is_list returns FALSE for objects with multiple classes", {
expect_false(is_list(summary(x ~ y)))
expect_silent(is_list(summary(x ~ y)))
})

test_that("is_list returns FALSE for S3 objects", {
sumry <- summary(lm(mpg ~ disp, data = mtcars))
expect_false(is_list(sumry))
Expand Down
10 changes: 2 additions & 8 deletions vignettes/unpacking-assignment.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ lat
lng
```

As in the earlier example, colon and braces on the left-hand side of the
assignment tell the assignment operator to expect a list.

In this example, we call a function that returns a vector.
Now we omit the braces.
In this next example, we call a function that returns a vector.

```{r}
#
Expand Down Expand Up @@ -207,9 +203,7 @@ The previous examples dealt with unpacking a list or vector into its elements.
You can also split certain kinds of individual values into subvalues.

### Character vectors
You can assign individual characters of a string to variables. Since character
strings are vectors, do not forget to exclude braces from the assignment
expression.
You can assign individual characters of a string to variables.

```{r}
c(ch1, ch2, ch3) %<-% "abc"
Expand Down

0 comments on commit 767aade

Please sign in to comment.