[R] Dependent data validation in R

Manish Mukherjee m@n|@hmukherjee @end|ng |rom hotm@||@com
Sat Jun 6 11:42:49 CEST 2020

Hi All ,
I need help in creating dependent data validation in R while creating an excel workbook
So i have two columns one has country and other states . I have to create the excel workbook in such a way that when i select the one specific country , the corresponding states appear in the next column . Something similar to dependent input in shiny ,
Here is the code what i have written

wb <- createWorkbook()
addWorksheet(wb, "Input")
addWorksheet(wb, "list")

df = data.frame("Country"=c("India","US"))
df1=data.frame("IndiaStates"=c("tamilnadu","Andhra pradesh"))

# Add drop-down values "
writeData(wb, sheet = "list", x = df, startCol = 1)
writeData(wb, sheet = "list", x = df1, startCol = 2)
writeData(wb, sheet = "list", x = df2, startCol = 3)
#Add drop-downs to the column
dataValidation(wb, "input", col = 1, rows = 2:5, type = "list", value =

dataValidation(wb, "input", col = 2, rows = 2:5, type = "list", value =

dataValidation(wb, "input", col = 3, rows = 2:5, type = "list", value =

saveWorkbook(wb, "dataValidationExample.xlsx", overwrite = TRUE)

The states should be in single column in exported excel workbook with dependent data validation

Thanks, and Regards

Manish Mukherjee

	[[alternative HTML version deleted]]

More information about the R-help mailing list