Git Product home page Git Product logo

Comments (4)

markfairbanks avatar markfairbanks commented on August 20, 2024

Do you have the latest version installed? When I run this on my computer it works.

Edit: Ah yep - you have tidytable 0.3.2 installed. Run this.

devtools::install_github("markfairbanks/tidytable")

tidytable is now on version 0.4.1

library(data.table)
library(tidytable)

x = iris %>% as.data.table() %>% dt_select(Sepal.Length, Sepal.Width)
y = iris %>% as.data.table() %>% dt_select(Sepal.Width, Sepal.Length) 

dt_bind_rows(x, y)
#>      Sepal.Length Sepal.Width
#>   1:          5.1         3.5
#>   2:          4.9         3.0
#>   3:          4.7         3.2
#>   4:          4.6         3.1
#>   5:          5.0         3.6
#>  ---                         
#> 296:          6.7         3.0
#> 297:          6.3         2.5
#> 298:          6.5         3.0
#> 299:          6.2         3.4
#> 300:          5.9         3.0

from tidytable.

nick-youngblut avatar nick-youngblut commented on August 20, 2024

I didn't realize that I was so out-of-date! Sorry to waste your time

from tidytable.

markfairbanks avatar markfairbanks commented on August 20, 2024

No worries! It's worth noting that using by = list(col1, col2) no longer works in the newer versions. See the example below:

test_df <- data.table(a = c("x","x","y"), b = c("x","x","y"), c = 1:3)

# Using by = list(a, b) no longer works
test_df %>%
  dt_summarize(avg_c = mean(c), by = list(a, b))
#> Error: Using by = list(col1, col2) is deprecated. Please use by = c(col1, col2)

# Use by = c(a, b)
test_df %>%
  dt_summarize(avg_c = mean(c), by = c(a, b))
#>    a b avg_c
#> 1: x x   1.5
#> 2: y y   3.0

The new way allows you to do stuff like this:

test_df %>%
  dt_summarize(avg_c = mean(c), by = is.character)

test_df %>%
  dt_summarize(avg_c = mean(c), by = c(is.character, is.factor))

Also every function now has both a dt_verb() and verb.() alias:

test_df %>%
  summarize.(avg_c = mean(c), by = is.character)

from tidytable.

leungi avatar leungi commented on August 20, 2024

@markfairbanks: not sure if I'm missing something even after checking the man; dplyr::summarise_at/all/if() are not yet implemented, ya?

Something like:

library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.6.3
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

iris %>% 
    summarise_if(is.numeric, mean, na.rm = TRUE)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1     5.843333    3.057333        3.758    1.199333

iris %>% 
    summarise_at(vars(contains("Sepal")), sum, na.rm = TRUE)
#>   Sepal.Length Sepal.Width
#> 1        876.5       458.6

from tidytable.

Related Issues (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.