I know I am asking a question about an R package that isn't super well know (only has 5 tags...one of which is from my previous question), but I'm still hoping I can open up a discussion here.
I have read the documentation for the textinput.typeahead
in the Shinysky package. However, the documentation leaves quite a few questions open.
I'm doing my best to figure out how to use this by following the example:
textInput.typeahead(
id="thti"
,placeholder="type 'name' or '2'"
,local=data.frame(name=c("name1","name2"),info=c("info1","info2"))
,valueKey = "name"
,tokens=c(1,2)
,template = HTML("<p class='repo-language'>{{info}}</p> <p class='repo-name'>{{name}}</p> <p class='repo-description'>You need to learn more CSS to customize this further</p>")
Usage
textInput.typeahead(id, placeholder, local, valueKey, tokens, template, limit = 20)
updateTextInput.typeahead(session, id, dataset, valueKey, tokens, template, limit = 20, placeholder = "")
First question: There is no discussion about what the difference between these two methods actually do. What's the difference, and why would someone want to pick one instead of the other?
Arguments
tokens
A list whose length equal to nrow(local) where each element is array of string tokens. Typing the tokens will select the correponding rows
The first thing that pops out here (aside from the misspelling of 'corresponding') is that tokens is supposed to be a list. But when I look at the example provided here, the argument reads ,tokens=c(1,2)
. This is a vector, not a list.
Even if a vector is ok, I'm not so sure what this does. Typing the tokens will select the correponding rows
. Does this somehow mean that I would have to explicitly tell shinysky where to look in order to populate the typeahead?
template
A hogan template on how to show the content e.g. '< p > name < / p >' where name is one of the variables in local
So not only do I need to show typeahead
where to look among the rows using a list or vector, but I need to show it which column to look into. Is this correct? If so, why does the example show 2 column names: {info}
and {name}
?
limit
An integer of the upper limit on how many hits to show in the typeahead dropdown
How does this affect the memory demands of loading all the values into the typeahead?
Anyway, thanks for reading this far. I hope we can figure out how to best use this tool in this package.