I am writing a function that uses plot_ly for a pieplot. The tilde (~) within argument labels = ~ is in conflict with the unquote operator !!. Is there a solution for this problem?
pieplotr <- function (df, Property){
Property_Name <- enquo(Property)
Pie <- plot_ly(df,
labels = ~!!Property_Name,
type = "pie")
return(Pie)
}
Toy_dataframe <- data.frame(
Sex = c("Male", "Female", "Female", "Male", "Male","NA"),
Height = c(12,11,7,3,9,NA),
Name = c("John", "Dora", "Dora","Dora", "Anna", "John"),
Last = c("Henry", "Paul", "House", "Houze", "Henry", "Bill"),
Location = c("Chicago", "Chicago", "Portland", "NYC", "NYC", "NYC"),
stringsAsFactors = TRUE)
e.g.
pieplotr(df = Toy_dataframe,
Property = Name)
I expect to return a pieplot, but I am getting the following error message:
Error in as.list.environment(x, all.names = TRUE) :
object 'Name' not found