#' @title Get attribute values from a dzVis table
#'
#' @description Gets the top values of a column from a dzVis database table and saves the results in a .json file.
#'
#' @param column A \code{character} value. The name of the column to be selected
#' @param table A \code{character} value. The name of the table to be selected
#' @param nvalues A \code{numeric} value. The number of values to be selected from the top.
#'
#' @return The name of the file in which the results were written.
#'
#' @seealso \code{\link{connect}}
#'
#' @export
#' @import DBI
getColumnValues <- function(column, table, nvalues){
filename <- "attributes.json"
connection <- connect()
query <- paste("select", column, "from", table, "limit", nvalues, ";")
data <- DBI::dbGetQuery(connection, query)
disconnect(connection)
if(createJSONFile(list(values = data[,1]), filename) == TRUE) {
return(filename)
}
stop("JSON file was not created.")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.