algorithmia
: R interface to the Algorithmia API
The following functions are implemented:
algo_api_key
: Get or set ALGORITHMIA_API_KEY valuealgo_call
: Call an Algorithmia algorithmalgo_client
: Initialize a new Algorithmia API client callalgo_dir_exists
: Test if a directory existsalgo_dir_list
: List a directory accessible by the Algorithmia servicealgo_download_file
: Read a file from a URI accessible by the Algorithmia service & write to diskalgo_file_exists
: Test if a file existsalgo_options
: Set options for an algorithm callalgo_pipe
: Execute an Algorithmia algorithm callalgo_read_file
: Read a file from a URI accessible by the Algorithmia servicepurrr::safely()
output=void
optiondevtools::install_github("hrbrmstr/algorithmia")
options(width=120)
library(algorithmia) # current verison packageVersion("algorithmia")
library(algorithmia) library(testthat) library(magrittr) library(dplyr)
date() algo_client() %>% algo_call("demo", "Hello", "0.1.1") %>% algo_options(30) %>% algo_pipe("there", "text") # Have to provide some assistance to `httr` if the input is not a named list # and the content type is set to "json" algo_client() %>% algo_call("demo", "Hello", "0.1.1") %>% algo_options(30) %>% algo_pipe('"there"', "json") algo_client() %>% algo_dir_exists("s3://public-r-data/") algo_client() %>% algo_dir_list("s3://public-r-data/") algo_client() %>% algo_file_exists("s3://public-r-data/ghcran.json") algo_client() %>% algo_read_file("s3://public-r-data/ghcran.json", fmt="parsed") -> cran str(cran[[1]]) txt <- "A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone." algo_client() %>% algo_call("nlp", "Summarizer", "0.1.3") %>% algo_pipe(txt, "text") URL <- 'rud.is/b/2016/07/12/slaying-cidr-orcs-with-triebeard-a-k-a-fast-trie-based-ipv4-in-cidr-lookups-in-r/' algo_client() %>% algo_call("util", "Html2Text", "0.1.4") %>% algo_pipe(URL, "text") bits <- list("This is a test of what this is. Hopefully this is going to work well as a test.", 2, 5, FALSE, TRUE) out <- algo_client() %>% algo_call("WebPredict", "GetNGramFrequencies", "0.1.1") %>% algo_pipe(bits, "json") bind_rows(out$result) algo_client() %>% algo_call("TimeSeries", "TimeSeriesSummary", "0.1.2") %>% algo_pipe(list(uniformData=as.double(USAccDeaths)), "json") # matches the `base::svd()` example hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") } X <- hilbert(9)[, 1:6] algo_client() %>% algo_call("joannetang", "SVD", "0.1.0") %>% algo_pipe(X, "json") -> svd_out matrix(unlist(svd_out$result$U), ncol=6, byrow=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.