Created
December 14, 2017 13:12
-
-
Save romainfrancois/6576c7a57fc707b4ca5d45f05d76c8a7 to your computer and use it in GitHub Desktop.
history if is.na
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(glue) | |
# i have my reasons, please dont burn my computer | |
setwd("~/git/r-source") | |
extract_isna <- function(.){ | |
cat( "\r", . ) | |
invisible( system(paste0('git checkout -q -f ', .)) ) | |
if( !file.exists("src/main/coerce.c")) return("") | |
lines <- read_lines("src/main/coerce.c") | |
start <- grep( "SEXP.*do_isna[(]", lines) | |
if( !length(start)) return("") | |
end <- grep( "^}", lines) | |
end <- first( end[ end > start ] ) | |
paste( lines[ seq(start, end) ], collapse = "\n" ) | |
} | |
realsxp_case <- function(.){ | |
txt <- str_split(., "\n")[[1]] | |
start <- grep( "case REALSXP", txt )[1] | |
end <- grep( "case", txt) | |
end <- end[ end > start ][1] | |
paste( txt[ seq(start+1, end-1) ], collapse = "\n" ) | |
} | |
commits <- system("git rev-list --pretty=oneline --all -- src/main/coerce.c", intern = TRUE) %>% | |
tibble( x = .) %>% | |
separate(x, into = c("id", "msg"), sep= " ", extra = "merge") | |
data <- commits %>% | |
mutate( isna = map_chr(id, extract_isna)) %>% | |
filter( isna != "") %>% | |
mutate( case_realsxp = map_chr( isna, realsxp_case) ) | |
data %>% | |
slice(n():1) %>% | |
distinct( case_realsxp ) %>% | |
pull() |
Author
romainfrancois
commented
Dec 14, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment