Can I define a function like this?
placeholder <- function(title = NULL,
subtitle = NULL,
table = NULL,
ul = NULL){
if(!is.null(title)){
ph_title <- ph(title, "Title")
}
if(!is.null(subtitle)){
ph_subtitle <- ph(subtitle, "Subtitle")
}
if(!is.null(table)){
ph_table <- ph(table, "Table")
}
if(!is.null(ul)){
ph_ul <- ph(ul, "List")
}
placeholders <- ph_title %>%
ph_subtitle %>%
ph_table %>%
ph_ul %>%
return(placeholders)
}
and call it in the next code (for example):
my_pres <- pres %>%
remove_slide(index = 1) %>%
add_slide(layout = "Slide 1", master = "Office Theme") %>%
placeholder(title = "Title 1", subtitle = "Subtitle 1") %>%
add_slide(layout = "Slide 2", master = "Office Theme") %>%
placeholder(ul = some_value_1, table = some_value_2)
What happens with the object placeholders if some of the arguments is NULL, since the objects consisted of the arguments are pipelined? If there isn’t one of the objects in the pipeline, will the object placeholders be made?
Can someone help me, please?