- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to work with R tibble objects
I really like integrating R code in JSL, but how can I deal with the correct handling of a tibble (dplyr) object. It seems like the object is damaged, when displayed in JMP. The output on my PC is visible in the appended image.
R Init();
R Submit("library(dplyr)");
x = R Execute({},{data_table},"\[
data_table <- tibble(x = c("A", NA, "B", "C"), y = c("D", "E", "F", "G"))
]\"
);
data_table << New Data View();
Show(data_table);
R Term();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to work with R tibble objects
I think the problem is caused by NA in the first column. JMP does not know how to deal with it. I don't think that JMP differentiates an empty string from a missing value in a Character column. You may consider changing NA to an empty string or some special string, if that works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to work with R tibble objects
thank you peng_liu, at least it works. I was not aware that the big dot indication missing values in JMP is only for the numbers and character do not have NA values. I still hope for an better NA handling in the JSL/R interface in comming versions.
R Init();
R Submit("
library(dplyr)
library(tidyr)
");
x = R Execute({},{data_table},"\[
data_table <- tibble(x = c(1, NA, 2, 3), y = c("D", "E", "F", "G"), z = c("A", NA, "B", "C"), a = c("H", "I", "J", "K")) %>%
mutate(across(where(is.character), ~replace_na(.x, "")))
data_table
]\"
);
data_table << New Data View( );
//limits << New Data View();
Show(data_table);
R Term(); //Exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to work with R tibble objects
I am not sure what third party interfacing with R can do. If I remember correctly, NA in R is a specially encoded double precision number, so it does not align well with other elements in the same vector in memory in this case. Please contact support@jmp.com in case there is a better solution.