Giter Site home page Giter Site logo

drlib's Introduction

David Robinson's Personal R Package

Travis-CI Build Status

This is the personal R package of David Robinson.

I'm making this public for my own convenience, without any guarantees. Functions are documented, though.

drlib's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

drlib's Issues

reorder_within and two faceting variables?

Hi David,

Thanks for these, they are great.

I am trying to use reorder_within with facet_grid with two faceting variables. Now it seems like it was not designed for this and I was trying to update the functions to fit. It's easy enough with reorder_within but I cannot quite figure out how to do it with scale_x_reordered().

Example below of why scale_x_reorder needs to be rejigged for it, but I haven't a clue where to start. Any help definitely appreciated.

library(tidyverse)
library(drlib)
#> 
#> Attaching package: 'drlib'
#> The following object is masked from 'package:tidyr':
#> 
#>     expand_grid
library(datasets)
data(iris)
df<-iris%>%
  gather(Type, value, -Species)%>%
  separate(Type, c("type", "attribute"), sep="[.]")


#using jsut reorder_within to test that it works
df%>%
  ggplot(aes(reorder_within(Species, value, type), value, color=type))+
  geom_point()+
  facet_grid(.~type, scales = "free_x")+
  scale_x_reordered()

#creating a new reorder that would work with 2 varaibles
reorder_within_2 <- function(x, by, within, within1, fun = mean, sep = "___", ...) {
  new_x <- paste(x, within, within1, sep = sep)
  stats::reorder(new_x, by, FUN = fun)
}

#but now, creating the chart below, the species names repeat. 

df%>%
  ggplot(aes(reorder_within_2(Species, value, type, attribute), value, color=type))+
  geom_point()+
  facet_grid(attribute~type, scales = "free_x")+
  scale_x_reordered()+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Created on 2020-01-27 by the reprex package (v0.3.0)

accumulate_while() produces as_function() error

Hi David, I love accumulate_while, any chance it could get updated to avoid the error below (the results it produces are still correct).

drlib::accumulate_while(17,~.+1,~.<20)

as_function() is deprecated; please use as_mapper() or rlang::as_function() insteadas_function() is deprecated; please use as_mapper() or rlang::as_function() instead[[1]]
[1] 17
[[2]]
[1] 18
[[3]]
[1] 19
[[4]]
[1] 20


Another request: could you create accumulate_while_*, where * = lgl, int, dbl, chr, etc., so in the example above i would have used

drlib::accumulate_while_int(17L,~.+1L,~.<20L)

[1] 17 18 19 20

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.