alexkowa / sparktable Goto Github PK
View Code? Open in Web Editor NEWsparkTable: Sparklines and graphical tables for tex and html
sparkTable: Sparklines and graphical tables for tex and html
I got this problem when trying to install sparkTable in my system:
Cheers
There is an error when exporting newSparkHist
object. For example:
library(sparkTable)
v1 <- as.numeric(table(rpois(50, 2))); v2 <- rnorm(50)
shist <- newSparkHist(values = v2, barCol = c("black", "darkgreen", "black"))
export(object = shist, outputType = "pdf",filename = file.path("figures", "first-hist"))
Error: Unknown parameters: binwidth, bins, pad
I guess this is related to a change in ggplot2
; see the issue below:
tidyverse/ggplot2#1465
Would it be possible to modify new spark objects arguments when creating a spark object?
For example it is possible to modify the line thickness of a sparkline:
sparkline <- newSparkLine(values = rlnorm(100), lineWidth = 1)
plot(sparkline)
But to modify outlier colour of a sparkbox you have to use setParameter
sparkbox <- newSparkBox(values = rlnorm(100))
sparkbox <- setParameter(sparkbox, "red", type = "outCol")
plot(sparkbox)
A consistent approach might be:
sparkbox <- newSparkBox(values = rlnorm(100), boxOutCol = "red")
plot(sparkbox)
Not sure this is still in gridExtra?
library(sparkTable)
dirflags = paste(searchpaths()[grep("sparkTable", searchpaths())], "/etc/Flaggen/",
sep="")
### EXAMPLE for EUROPE
data(EU_data)
order_eu = optimal_grid_allocation(EU_data[,16:17],8,7)
colnames(EU_data)[1] <- c("country")
EU_data[,18] <- order_eu
colnames(EU_data)[1] <- c("country")
colnames(EU_data)[18] <- c("order")
data_eu = data.frame(cbind(rep(1997,34)), EU_data$unempl_f_1997, EU_data$country,
EU_data$order)
colnames(data_eu) = c("x", "y", "names", "order")
for(year in 1998:2008){
XX <- data.frame(cbind(rep(year,34)), EU_data[,paste("unempl_f_",year,sep="")],
EU_data$country, EU_data$order)
colnames(XX) = c("x", "y", "names", "order")
data_eu = rbind(data_eu,XX)
}
dirflags_eu=paste(dirflags,"EU/",sep="")
checkerplot(data_eu, cols=8, rows=7, geom="line", img=dirflags_eu,
title = "Unemployment rate in Europe 1997 to 2008 (in perc)", title.size=18,
ylabels=c(5,10,15,20),
ybreaks=c(5,10,15,20), xbreaks=c(1998,2001,2004,2007),
xlabels=c("98","01","04","07"),
margin_yaxis=-0.05, margin_yaxis2=-0.2,
margin_xaxis=-0.4, margin_xaxis2=0 )
#Error: could not find function "pixmapGrob"
allow to export the required R-code that is required to reproduce the current graphical table.
Probably due to the latest shiny package update, the shiny apps showSparkTable and customizeSparkTable dont work anymore...!?
Hi,
I think there might be an issue with ggplot 2.2.0. This simple Knitr example produces the error below with ggplot 2.2.0 but not 2.1.0.
library(sparkTable)
sl <- newSparkLine(values = rnorm(25), lineWidth = .18, pointWidth = .4,
width = .4, height = .08)
export(sl, outputType = "png", filename = "sparkLine")
Error in theme(legend.position = "none", line = element_blank(), text = element_blank(), : formal argument "axis.ticks" matched by multiple actual arguments
6.
theme(legend.position = "none", line = element_blank(), text = element_blank(), title = element_blank(), axis.line = element_blank(), axis.ticks = element_blank(), legend.background = element_rect(fill = "white", colour = NA), plot.background = element_blank(), strip.background = element_rect(fill = "white", ...
5.
plot(.Object, ...)
4.
plot(.Object, ...)
3.
.local(object, ...)
2.
export(sl, outputType = "png", filename = "sparkLine")
1.
export(sl, outputType = "png", filename = "sparkLine")
Hi Alex,
Nice package!
I have a doubt, it's possible to use sparkTable with DT tables? It's for use with knitr, no Shiny.
Thanks!!
I want to use sparkTables within an R Markdown document - I found this package and it looks great, so I started to work on my report. Here is the example I used within the markdown file itself:
library(sparkTable)
data(AT_Soccer, package = "sparkTable")
content <- list(function(x) { sum(x) }, function(x) { round(sum(x), 2) }, function(x) { round(sum(x), 2) }, newSparkLine(lineWidth = 2, pointWidth = 6), newSparkBar())
names(content) <- c("Points", "ShotGoal", "GetGoal", "GoalDiff", "WinLose")
vars <- c("points", "shotgoal", "getgoal", "goaldiff", "wl")
stab <- newSparkTable(dataObj = AT_Soccer, tableContent = content, varType = vars)
export(stab, outputType = "tex", filename = "W:/Projects/R/Scripts/OHMR/Report Components/Markdown Files/sparkTable/first-stab", graphNames = "W:/Projects/R/Scripts/OHMR/Report Components/Markdown Files/sparkTable/first-stab", infonote=FALSE, scaleByCol=TRUE)
The last command "export" of course creates the .tex file along with all the graphics in their own PDF files. Great! Now, I notice that export command also generates output - I had to play the with r code chunk options a bit to get the # symbols out of there, but the "results='asis' seemed to do that. Now, I get an error when the markdown tries to render the LaTex syntax. I dug into it a bit, and I see the following:
\begin{table}[ht]
\centering
\begin{tabular}{rlllll}
\hline
& Points & ShotGoal & GetGoal & GoalDiff & WinLose \
\hline
Rapid &
Salzburg &
Austria &
Sturm &
Groedig &
Neustadt &
FC Wacker &
Wolfsberg &
Ried &
Admira &
\hline
\end{tabular}
\end{table}
After studying it a bit, I notice the files in the paths above do not have the ".pdf" on the end. On a hunch that might be the issue, I fire up TeXworks (part of the MikTeX software) and try to generate a PDF - I get an error in there too, so I append ".pdf" on to the end of each file name and , voila! It works. So somehow the sparkTable export command isn't appending the .pdf on to the end of the file names when it generates the LaTex. I search through all of the documentation, figuring there must be some option to do that, but I don't see one. If I add ".pdf" to the end of the file in the export command, I just get a file called "first-stab4-10.pdf.pdf" - not what I want. I'm sure this is simple, but I wonder if this may be a bug somehow in the package. Can you help me with this? Thanks so much!
cr.plot<-nakedMap(cr, title="Cropped")
Error in theme(line = element_blank(), line = element_blank(), axis.text = element_blank(), :
formal argument "line" matched by multiple actual arguments
I got this error when I am plotting raster data.
More Error Catching, better documentation
I'm stuck with an older version of R (3.3.1) and sparkTable
depends on proxy which is available only from 3.4. Is a hard dependency on proxy absolutely necessary ?
Package description says :
Provides an extensible framework for the efficient calculation of auto- and crossproximities,
along with implementations of the most popular ones.
Which seems like something that might not be necessary for sparkTable's basic features ?
Is there a way for me to hack my way round it ? I'd love to make use of sparkTable.
Hi Alex,
Warning in install.packages :
package ‘sparkTable’ is not available for this version of R
R version used was 4.2.2. Is there any plan of updating the package and continue supporting?
Hi, I am using this manual for SparkTable package: https://web.warwick.ac.uk/statsdept/user2011/TalkSlides/Contributed/18Aug_0950_FocusVI_4-ReportingData_2-Kowarik.pdf and it tells me there are functions like plotSparkLine, plotSparkTable etc. but they have all disappeared? What are the alternatives??
When I tried to use plot() on a sparktable, it gave me an error
Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
What's happening??????
Thank you very much for your work!
Would it be possible to add a background color option to newSparkBar? It could be a fourth parameter to barCol, preferably with the "transparent" option that there already exists for the newSparkLine. That would be really helpful for me, since I color every second row of my table and the white background does not look good.
I have some existing code to create a sparkTable that worked in R v3.3. When I upgraded to 3.5, I was getting an error in the reshapeExt
to prepare the sparkTable objects. I tracked it back and the internal call to reshape
is generating the error. It can be seen with this code:
testdf <- data.frame(type = c("A", "A", "A", "B", "B", "B"),
rank = c(1, 2, 3, 1, 2, 3),
val1 = c(2, 5, 7, 2, 8, 5),
val2 = c(3, 8, 6, 7, 3, 4))
testdflong <- reshape(testdf,
idvar = "type",
timevar = "rank",
varying = list(3,4),
direction = "long")
testdflong <- reshapeExt(testdf,
idvar = "type",
timevar = "rank",
varying = list(3,4))
which generates the error:
Error in
row.names<-.data.frame
(*tmp*
, value = paste(ids, times[i], :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘A.1’, ‘B.1’
Checking with various friends, this error is generated from v3.4 (Windows and Mac). In the event, I got round the problem by simply adding the attributes
to the dataframe so that it registered as being in long
format for the purposes of sparkTable.
boxShowOut is a function for newSParkBox - 'logical vector specifying if outliers should be displayed in spark boxplots'
This argument is not described in setParameter and there seems to be no guidance on how the argument should be used in the package documentation.
I would have expected the argument to work like this:
sparkbox <- newSparkBox(values = rlnorm(100), boxShowOut = FALSE)
or possibly:
sparkbox <- newSparkBox(values = rlnorm(100))
sparkbox <- setParameter(sparkbox, FALSE, type = "showOut")
plot(sparkbox)
Neither case works. I get the following error message:
Error in (function (cl, name, valueClass) :
‘boxShowOut’ is not a slot in class “sparkbox”
My workround is to use the boxOutCol argument to make the outlier colour the same as the box backgound colour. Using the boxShowOut would be more correct.
When more variables are used, and the columns are resorted the wrong variables are used
e.g. in examples from newSparkTable
It is possible to modify the width of the points used on a sparkLine
sparkline <- newSparkLine(values = rlnorm(50), pointWidth = 5)
plot(sparkline)
It would be really useful to be able to adjust the point width of the boxplot outliers so that a pleasing visual balance between the boxplot and the outliers can be achieved.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.