Last active
August 29, 2015 14:01
-
-
Save randyzwitch/34a793f7c06c4a103fc2 to your computer and use it in GitHub Desktop.
JSON in R using paste
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#"metrics" would be a user input into a function arguments | |
metrics <- c("a", "b", "c") | |
#Loop over the metrics list, appending proper curly braces | |
metrics_conv <- lapply(metrics, function(x) paste('{"id":', '"', x, '"', '}', sep="")) | |
#Collapse the list into a proper comma separated string | |
metrics_final <- paste(metrics_conv, collapse=", ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment