Line graph with dropdown, button and split in plotly R not working properly

I have a data looks like this

Country |TableName|Date|Counts|TableType
India|A|10/01/2018|10|Static
India|A|11/01/2018|15|Static
India|B|10/01/2018|16|Dynamic
India|B|11/01/2018|16|Dynamic
USA|A|10/01/2018|12|Static
USA|A|11/01/2018|15|Static
UAE|A|10/01/2018|12|Dynamic
UAE|A|11/01/2018|15|Dynamic

my R report should list drop down on Country and button on Table type, So when i select dropdown as “INDIA” and select “Static” as button it should display line chart, I have made the code but when i use split=~TableName or color=~TableName it is showing all the tablenames in legends irrespective of the country selected.

kindly help me to sort out this.

plot_ly(test, x = ~Date,y=~Counts,type=‘scatter’,mode=‘lines+markers’,split=~TableName,
transforms = list(list(type=‘filter’,target=~TableType,operation = ‘=’,value= unique(test$TableType)[1])),
transforms = list(list(type=‘filter’,target=~Country,operation = ‘=’,value= unique(test$Country)[1]))
) %>%
layout(
title = “Drop down menus - Styling”,
updatemenus = list(
list(
y = 0.9,
type=‘dropdown’,
buttons = list(
list(method = “restyle”,
args = list(“transforms[0].value”, unique(test$Country)[1]),
label = unique(test$Country)[1]),

      list(method = "restyle",
           args = list("transforms[0].value", unique(test$Country)[2]),
           label = unique(test$Country)[2]))),
		   
	list(
    y = 0.7,
	type='buttons',
    buttons = list(
      list(method = "restyle",
           args = list("transforms[0].value", unique(test$TableType)[1]),
           label = unique(test$TableType)[1]),

      list(method = "restyle",
           args = list("transforms[0].value", unique(test$TableType)[2]),
           label = unique(test$TableType)[2])))	   
)

)