Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Added ifelse -> IF() function mapping #53
This pull request adds
Google BigQuery has a direct equivalent to R's
An example test case is listed below
library(dplyr) library(bigrquery) BILLING_PROJECT <- "<YOUR_BILLING_PROJECT>" BILLING_DATASET <- "<DATASET_INSIDE_THAT_PROJECT>" bq <- src_bigquery(BILLING_PROJECT, BILLING_DATASET) # Upload the test data frame to your project df <- data.frame(a = 1:100, b = 101:200) ifelse_test_df <- copy_to(bq, df, name = "ifelse_test_df") # Perform a simple mutate query with ifelse ifelse_test_df %>% mutate( z = ifelse(a <= 10L, 1L, 0L) ) %>% summarise( sum_z = sum(z) ) %>% collect
The use of function with NAs as one of the arguments requires one to specify the type of NA.
# Perform a simple mutate query with ifelse and NULLs ifelse_test_df %>% mutate( z = ifelse(a <= 10L, 1L, INTEGER(NULL)) ) %>% summarise( sum_z = sum(z) ) %>% collect
Please note that running the test does require to have a Google Cloud billing project set up already.
Thank you for consideration!