Open aldsanms opened 1 year ago
Here is the program for controller movement. This program allows to see the movement of the controller and the state of the various moles.
Answers to your comments on my 1st pull request:
I managed to use this library to read CSV in data file. However I created a csv "AllMoles.csv" containing the id of the moles and their position on the wall, I failed to include it with the "LoadFromDirectory()" function.
I solved this data processing problem. Now I directly read the data sent by R.
My program doesn't work without the "new Date()", i tried several ways without success.
I managed to use this library to read CSV in data file. However I created a csv "AllMoles.csv" containing the id of the moles and their position on the wall, I failed to include it with the "LoadFromDirectory()" function.
I think it's better if you generate a dataset describing all moles, based on the imported dataset from LoadFromDirectory(). See e.g. the three lines from our Whack-A-Mole Dashboard: https://github.com/med-material/Whack_A_Mole_RShiny/blob/master/modules/plot_grid_performance_module.R#L78
col_count = df_vis %>% filter(!is.na(WallColumnCount)) %>% select(WallColumnCount)
row_count = df_vis %>% filter(!is.na(WallRowCount)) %>% select(WallRowCount)
Wall_moles <- expand.grid(1:tail(col_count, n=1)[,1], 1:tail(row_count, n=1)[,1]) %>%
dplyr::rename(x = Var1, y = Var2)
I solved this data processing problem. Now I directly read the data sent by R.
👍
My program doesn't work without the "new Date()", i tried several ways without success.
What variable type is the Timestamp data in your JS file when it arrives from R? Is it just a vector of strings?
I managed to use this library to read CSV in data file. However I created a csv "AllMoles.csv" containing the id of the moles and their position on the wall, I failed to include it with the "LoadFromDirectory()" function.
I think it's better if you generate a dataset describing all moles, based on the imported dataset from LoadFromDirectory(). See e.g. the three lines from our Whack-A-Mole Dashboard: https://github.com/med-material/Whack_A_Mole_RShiny/blob/master/modules/plot_grid_performance_module.R#L78
col_count = df_vis %>% filter(!is.na(WallColumnCount)) %>% select(WallColumnCount) row_count = df_vis %>% filter(!is.na(WallRowCount)) %>% select(WallRowCount) Wall_moles <- expand.grid(1:tail(col_count, n=1)[,1], 1:tail(row_count, n=1)[,1]) %>% dplyr::rename(x = Var1, y = Var2)
I solved this data processing problem. Now I directly read the data sent by R.
👍
My program doesn't work without the "new Date()", i tried several ways without success.
What variable type is the Timestamp data in your JS file when it arrives from R? Is it just a vector of strings?
Timestamp data in my JS file when it arrives from R is a string, I tried to work with Date.parse() but still have problems which I don't have with new Date(). I keep watching.
@aldsanms let me know what you find out - see the r2d3 documentation here: https://rstudio.github.io/r2d3/articles/data_conversion.html
I commented on the whole program.
I updated the program, now:
I corrected the structure of the program.
I managed to use this library to read CSV in data file. However I created a csv "AllMoles.csv" containing the id of the moles and their position on the wall, I failed to include it with the "LoadFromDirectory()" function.
I think it's better if you generate a dataset describing all moles, based on the imported dataset from LoadFromDirectory(). See e.g. the three lines from our Whack-A-Mole Dashboard: https://github.com/med-material/Whack_A_Mole_RShiny/blob/master/modules/plot_grid_performance_module.R#L78
col_count = df_vis %>% filter(!is.na(WallColumnCount)) %>% select(WallColumnCount) row_count = df_vis %>% filter(!is.na(WallRowCount)) %>% select(WallRowCount) Wall_moles <- expand.grid(1:tail(col_count, n=1)[,1], 1:tail(row_count, n=1)[,1]) %>% dplyr::rename(x = Var1, y = Var2)
I solved this data processing problem. Now I directly read the data sent by R.
👍
My program doesn't work without the "new Date()", i tried several ways without success.
What variable type is the Timestamp data in your JS file when it arrives from R? Is it just a vector of strings?
The dates that R2D3 sends to D3.js are in String format.
@aldsanms
The dates that R2D3 sends to D3.js are in String format.
This answer is a bit unclear. Is it because R2D3 converts the dates to string? or is it something to do with the JSON conversion?
I looked a bit further into this myself. I tried the following code.
data_to_json <- function(data) {
jsonlite::toJSON(data, dataframe = "rows", auto_unbox = FALSE, rownames = TRUE)
}
t <- data_to_json(testdata)
and then I printed "t" on the terminal. I could see that the date was indeed converted into a string. I then searched online and discovered that JSON does not support serializing datetime. https://weblog.west-wind.com/posts/2014/jan/06/javascript-json-date-parsing-and-real-dates https://stackoverflow.com/questions/10286204/what-is-the-right-json-date-format
So the above links are the real answer to this problem. Thus the way you serialize the timestamp column into date is fine - in fact it's the only solution, as it's not something that JSON.parse()
supports - all its sees is a string.
@aldsanms see my comments above and let me know when they can be resolved. 👍
add Controller_movement v1