View source: R/catmaid_connection.R
catmaid_fetch | R Documentation |
catmaid_fetch
carries out a GET operation when
body=NULL
, POST otherwise. The http status code of the response will
be checked - if invalid an error will be thrown.
catmaid_fetch( path, body = NULL, conn = NULL, parse.json = TRUE, include_headers = TRUE, simplifyVector = FALSE, ... )
path |
The path on the CATMAID server relative to the CATMAID root |
body |
The (optional) body of the post request, usually in the form of a
named list. See the |
conn |
A |
parse.json |
Whether or not to parse a JSON response to an R object
(default |
include_headers |
Whether to include basic headers from the http request
as attributes on the parsed JSON object (default |
simplifyVector |
Whether to use jsonlite::simplifyVector |
... |
Additional arguments passed to the |
When parse.json=FALSE
an object of class response
otherwise the raw R object generated by calling
jsonlite::fromJSON
on the body of the response.
catmaid_login
, GET
,
POST
## Not run: ## Make a catmaid_connection object to use for these requests conn=catmaid_login() ## fetch a demo skeleton using a GET request # raw response skel.response=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) # list object skel=catmaid_fetch("1/10418394/0/0/compact-skeleton", conn=conn) ## Get the names of two skeletons using a POST request # NB that the skids[n] elements are quoted when constructing the list since # they are not valid R names. catmaid_fetch("/1/skeleton/neuronnames", conn=conn, body=list(pid=1, 'skids[1]'=10418394, 'skids[2]'=4453485)) ## get all skeletons with more than 1000 nodes skids=as.integer(catmaid_fetch("/1/skeletons/?nodecount_gt=1000")) ## fetch user history since 1st April 2016 uh = catmaid_fetch('1/stats/history?start_date=2016-04-01', simplifyVector = T, include_headers = F) uh$date=as.Date(uh$date,"%Y%m%d") library(dplyr) # select top 10 users by nodes added top10=uh %>% group_by(name) %>% summarise(total=sum(count)) %>% arrange(desc(total)) %>% top_n(10) # plot cumulative nodes traced library(ggplot2) uh %>% group_by(name) %>% mutate(ccount = cumsum(count)) %>% filter(name %in% top10$name) %>% ggplot(aes(date, ccount, col = name)) + geom_line() ## demonstrate that bad urls will result in an error catmaid_fetch("/1/rhubarb/crumble") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.