Is there a way to restrict editing of a cell to only the factor levels in a DT in R?
Here's some sample data:
structure(list(boatName = c("Sunny Bay", "STI Solidarity", "STI Rambla",
"STI La Boca", "STI San Telmo", "STI Esles II", "STI Jardins",
"SKY", "Steel", "Bahra"), VesselType = structure(c(5L, 1L, 1L,
5L, 5L, 5L, 5L, 2L, 2L, 1L), .Label = c("AFRAMAX LR2 POOL", "HANDYMAX POOL",
"LR1 POOL", "MID RANGE", "MID RANGE POOL"), class = "factor"),
IceClass = c("NO", "N/A", "No", "NO", "YES", "YES", "YES",
"Yes", "Yes", "-")), row.names = c(NA, 10L), class = "data.frame")
If I run datatable(df, editable=TRUE), I can edit the individual cells. But I would want the values for say, VesselType to be restricted only to the factor levels of the variable.
I know rhandsontable has this option by specifying type = "dropdown" in hot_col(), but can this be done in DT. And can editing be limited to only a few columns?