`CreateGRiwrm` crashes when keeping all columns and rename some
See example below:
text = "id_amont lambert2.x lambert2.y area nom id_aval distance_aval model
H8100021 537912.994 2455749.314 64420.94 La Seine à Vernon NA NA RunModel_CemaNeigeGR4J
H7900010 578113 2437649 61642.28 La Seine à Poissy H8100021 76.28 RunModel_CemaNeigeGR4J
H5920010 602213 2427449 43824.66 La Seine à Paris [Austerlitz après création lacs] H7900010 82.26 RunModel_CemaNeigeGR4J"
BS_reseau <- read.csv(text = text, sep = "\t")
library(airGRiwrm)
> griwrm <- CreateGRiwrm(BS_reseau,
cols = list(id = "id_amont",
down = "id_aval",
length = "distance_aval"),
keep_all = TRUE)
which leads to this error:
Error in if (typeof(df[[x]]) != coltypes[[x]]) { :
argument is of length zero
4.
FUN(X[[i]], ...)
3.
lapply(names(df), function(x) {
if (typeof(df[[x]]) != coltypes[[x]]) {
stop(sprintf("The '%s' column is of type %s, a column of type %s is required",
x, typeof(df[[x]]), coltypes[[x]])) ... at CreateGRiwrm.R#95
2.
CheckColumnTypes(db, list(id = "character", down = "character",
length = "double", model = "character", area = "double")) at CreateGRiwrm.R#69
1.
CreateGRiwrm(BS_reseau, cols = list(id = "id_amont", down = "id_aval",
length = "distance_aval"), keep_all = TRUE)