Reputation: 3515
The most recent version of the DT package allows editing
I was hoping that you could use the table visually to replace values in the underlying data.frame as a swift option to coding such as:-
df[1,2] <- 76
df[63,45] <- "foo"
But this does not seem to be the case. Am I missing something? Or is this a potential enhancement. Edit+save seems the obvious usage
Upvotes: 3
Views: 905
Reputation: 6669
"But this does not seem to be the case. Am I missing something?"
From what I understand, you want to visually replace some value in your data frame but you have not succeeded. I am not sure what you have tried but this is what I have done and it works for me in RStudio.
library(DT)
datatable(iris)
DT::datatable(head(iris), editable = TRUE)
Edit:
OP's question was unclear to me. He/she has made it clear that is it possible to save once editing any value. I could not find anything within the DT package as such, if that is what is expected. However, there are a few workarounds for editing a dataframe via a GUI.
1) editData package: https://cran.r-project.org/web/packages/editData/README.html
2) Assigning the dataframe as df <- edit(df)
opens up a GUI which can be edited and just closed, it saves the state of the dataframe. While I cross checked this feature, the source of this answer is from here: https://support.rstudio.com/hc/en-us/community/posts/206908027-Data-Editor-GUI-modifying-values-Feature-and-Error-
Feel free to add a solution pertaining to DT package if found.
Upvotes: 5