Git Product home page Git Product logo

dplyrextras's People

Contributors

mtelesha avatar skranz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dplyrextras's Issues

Bug in documentation of s_ functions

Hi, Stephan

Thanks for creating these functions - they're really helpful. There seems to be a bug in the documentation of the various s_ functions. In the code snippet, you create what seems to be a vector of character variables, as follows:
cols = c("mpg","cyl, hp:vs")

Shouldn't that be cols = c("mpg", "cyl", "hp:vs") #i.e. each one is a separate quoted variable, rather than having one variable containing "cyl, hp:vs"

Instructions for Install Fix

install_github(repo="dplyrExtras", username="skranz")`

returns an error:

Warning message:
Username parameter is deprecated. Please use skranz/dplyrExtras

Code needs to be:
library(devtools); install_github(repo="skranz/dplyrExtras")

code donation: s_recode ( and SQuote )

s_recode <- function(.x, ..., .default = NULL, .missing = NULL) {

  eval.string.PAT.named_dots.default.missing(.x, "recode", .default, .missing, ...)

}

eval.string.PAT.named_dots.default.missing <- function(.x, .fun.name, .default, .missing, ...) {

  args = list(...)
  args = unlist(args)
  args = paste0(names(args), " = ", args)
  DEFAULT = if(!is.null(.default)) { paste0(", .default = ", .default) } else { "" }
  MISSING = if(!is.null(.missing)) { paste0(", .missing = ", .missing) } else { "" }
  code = paste0(.fun.name,"(.x, ", paste0(args, collapse=", "), DEFAULT, MISSING, ")" )
  v = eval(parse(text=code,srcfile=NULL))
  v
  
}

SQuote <- function(x) { sapply( x , function(xx) { paste0("'", xx, "'") }, USE.NAMES = FALSE ) }
# > SQuote(letters[1:3])
# [1] "'a'" "'b'" "'c'"

new_letters <- SQuote(c("alpha", "beta"))
names(new_letters) <- c("a","b")

# > new_letters
#         a         b
# "'alpha'"  "'beta'"

# > s_recode(letters[1:3], new_letters)
# [1] "alpha" "beta"  "c"

# > s_recode(letters[1:3], new_letters, .default = "'gamma'")
# [1] "alpha" "beta"  "gamma"

mutate_rows no longer working (breaking change in dplyr 0.7.0?)

Hello. I use mutate_rows a lot and I just started getting an error message on code that used to work fine, which I suspect has something to do with the update to dplyr 0.7.0.

For example, the code

library(dplyr)
library(dplyrExtras)
df <- tibble(a = c(1,2,1), b = letters[2:4])
df %>% mutate_rows(a == 1, b = "hello")

leads to the following error message Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'named_dots' not found'

Since named_dots is a dplyr function, I'm guessing that's where the issue is. Is there a fix that you can implement in dplyrExtras to get around whatever was changed in the dplyr update?

Feature rejected by hadley: add variable labels to the tbl_df class

The original issue is here: tidyverse/dplyr#1307

Variable labels are one of the few remaining features that are nicer in Stata. These are used for variable descriptions that are longer than appropriate for a title.

The call would be something like:

my_tbl_df %>% select(my_var_1, my_var_2) %>% labels()

And the output would be a character vector of the variable labels for my_var_1 and my_var_2.

Might be a good addition to dplyrExtras!

mutate_if.data.frame calls as.data.frame instead of as.data.table

The current version of mutate_if.data.frame seems to call as.data.frame in the first line. I think it should be as.data.table. Because later you call mutate_if.data.table on the newly created dt.

mutate_if.data.frame =function (.data,.if,...)
{
  dt = as.data.table(.data) # changed from dt = as.data.frame(.data)
  .if.quoted = substitute(.if)
  as.data.frame(mutate_if.data.table(.data=dt,.if.quoted=.if.quoted,...,inplace=TRUE, .parent.env = parent.frame()))
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.