History: Profile_r_test13_parse_body
Source of version: 10
Copy to clipboard
! Unfinished work. Alfa state. This page first of all produces a simple barchart using conventional R body content ie with !!- Fetch data using TrackerList to fetch data __Wiki a wiki template__ {trackerlist trackerId=2 fields="9:10:11" list_mode=csv max=4 showpagination="n" tplwiki=r_demo13_template01} __Without a wiki template, and with param list_mode=csv__ {trackerlist trackerId=2 fields="9:10:11" list_mode=csv max=4 showpagination="n"} __With a wiki template, and without param list_mode=csv__ {trackerlist trackerId=2 fields="9:10:11" max=4 showpagination="n" tplwiki=r_demo13_template01} So now that you can generate output from a tracker using a trackerlist plugin, or for more flexibility using the list plugin, then a lot more options become possible with R :-) However, it doesn't work as of July 2015 (Tiki12). See bug report related to param list_mode=csv "plugin trackerlist param list_mode=csv does nothing for me" - https://dev.tiki.org/item5688 !!- Display dummy data using a Barplot {R(bg="yellow" parse_body="y" echodebug=1)} abundance <- matrix(c({trackerlist trackerId=2 fields="9:10:11" list_mode=csv max=4 showpagination="n" tplwiki=r_demo13_template01}),ncol=3,byrow=TRUE); abundance; barplot(abundance); {R} In the above the echodebug now shows the body content both pre and post parsing so that it can be checked. !! Fetch data using ajax services and display using sjPlot {RR(bg="yellow" parse_body="n" echodebug=1)} r <- getOption("repos") r["CRAN"] <- "http://ftp.heanet.ie/mirrors/cran.r-project.org/" options(repos=r) install.packages("sjPlot") library("sjPlot") ### EXAMPLE with pre-set data frame by hand marca<-c("opel","renault","renault") model<-c("corsa","laguna","modus") cilindrada<-c(1.2,1.9,1.5) color<-c("blanc","vermell","violeta") cotxes<-data.frame(marca,model,cilindrada,color) cotxes ### FETCH tracker data __using Ajax services__ Use some url such as: ^ http://localhost/tiki-ajax_services.php?controller=tracker&action=export_items&trackerId=2&encoding=UTF-8&separator=%2C&delimitorL=%22&delimitorR=%22&CR=%25%25%25&listfields[]=9&listfields[]=10&listfields[]=11&recordsMax=-1 ^ # If your tiki is not under localhost, adapt the path below for my.file my.file <- "http://localhost/tiki-ajax_services.php?controller=tracker&action=export_items&trackerId=2&encoding=UTF-8&separator=%2C&delimitorL=%22&delimitorR=%22&CR=%25%25%25&listfields[]=9&listfields[]=10&listfields[]=11&recordsMax=-1" my.df <- read.csv(my.file) #colnames(my.df) <- c("f_9", "f_10", "f_11") unlist(str_split(colnames(my.df), "\\."))[1] str_split(colnames(my.df), "\\.")[[1]][1] # field name from f_9 in this example str_split(colnames(my.df), "\\.")[[2]][1] # field name from f_10 in this example str_split(colnames(my.df), "\\.")[[3]][1] # field name from f_11 in this example # load libraries library(sjPlot) library(sjmisc) # init default theme for plots sjp.setTheme(geom.label.size = 2.5, axis.title.size = .9, axis.textsize = .9) sjp.frq(cotxes$marca) sjp.frq(cotxes[,1]) sjp.frq(my.df[,1]) {RR} See: * https://strengejacke.wordpress.com/2013/07/17/plotting-likert-scales-net-stacked-distributions-with-ggplot-rstats/ * http://strengejacke.de/sjPlot/custplot/