Forum Discussion
[R] Leaflet Visual works on Desktop, breaks on Service
- 1 year ago
Coming back to this thread with the solution:
I noticed that the class(df[,4]) with 4 being one of my True/False Layer returned different types on local and on services. On Local i received character which i succesfully casted on logical. On Services this line of code returned integer. I played around with more robust casting and datatype differentiation and fixed it like this:
for (col in extra_columns) { if (col %in% colnames(df)) { if (!is.logical(df[[col]])) { df[[col]] <- as.logical(ifelse(df[[col]] %in% c("True", "true", "1"), TRUE, FALSE)) } } }
Two thoughts come to mind. One, Leaflet is a JavaScript library and the R package simply allows you to use that library to create maps. So, perhaps there is something about the JavaScript running in Desktop versus the Service that is different?
The other is perhaps there is a difference in the sub-packages:
Coming back to this thread with the solution:
I noticed that the class(df[,4]) with 4 being one of my True/False Layer returned different types on local and on services. On Local i received character which i succesfully casted on logical. On Services this line of code returned integer. I played around with more robust casting and datatype differentiation and fixed it like this:
for (col in extra_columns) {
if (col %in% colnames(df)) {
if (!is.logical(df[[col]])) {
df[[col]] <- as.logical(ifelse(df[[col]] %in% c("True", "true", "1"), TRUE, FALSE))
}
}
}