-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 16.6 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
install.packages('extrafont')
library(extrafont)
library(devtools)
install_github("Rttf2pt1", "wch", "freetype2")
install_github("extrafont", "wch", "freetype")
library(extrafont)
font_import()
tail(fonts(), 10)
tail(fonts(), 30)
fonts()
library(showtext)
## Loading Google fonts (http://www.google.com/fonts)
font.add.google("Gochi Hand", "gochi")
font.add.google("Schoolbell", "bell")
font.add.google("Covered By Your Grace", "grace")
font.add.google("Rock Salt", "rock")
fonts()
install.packages("Rttf2pt1")
install.packages("Rttf2pt1")
install.packages("extrafontdb")
install.packages('extrafont')
library(extrafont)
font_import()
font()
fonts()
loadfonts()
pdf("font_plot.pdf", family="Impact", width=4, height=4)
plot(mtcars$mpg, mtcars$wt,
main = "Fuel Efficiency of 32 Cars",
xlab = "Weight (x1000 lb)",
ylab = "Miles per Gallon")
install.packages("showtext")
library(showtext)
## Loading Google f
font.add.google("Gochi Hand", "gochi")
font.add.google("Schoolbell", "bell")
font.add.google("Covered By Your Grace", "grace")
font.add.google("Rock Salt", "rock")
showtext.auto()
set.seed(123)
x = rnorm(10)
y = 1 + x + rnorm(10, sd = 0.2)
y[1] = 5
mod = lm(y ~ x)
## Plotting functions as usual
## Open a graphics device if you want, e.g.
## png("demo.png", 700, 600, res = 96)
op = par(cex.lab = 2, cex.axis = 1.5, cex.main = 2)
plot(x, y, pch = 16, col = "steelblue",
xlab = "X variable", ylab = "Y variable", family = "gochi")
grid()
title("Draw Plots Before You Fit A Regression", family = "bell")
text(-0.5, 4.5, "This is the outlier", cex = 2, col = "steelblue",
family = "grace")
abline(coef(mod))
abline(1, 1, col = "red")
par(family = "rock")
text(1, 1, expression(paste("True model: ", y == x + 1)),
cex = 1.5, col = "red", srt = 20)
text(0, 2, expression(paste("OLS: ", hat(y) == 0.79 * x + 1.49)),
cex = 1.5, srt = 15)
legend("topright", legend = c("Truth", "OLS"), col = c("red", "black"), lty = 1)
par(op)
library(showtext)
png("System-Fonts.png", width=550, height=350);
par(mfrow=c(2,2))
plot(1 ~ 1, main="Lucida Bright", family = "Lucida Bright")
plot(1 ~ 1, main="Courier", family = "Courier")
plot(1 ~ 1, main="Helvetica Neue Light", family = "Helvetica Neue Light")
plot(1 ~ 1, main="Lucida Handwriting Italic", family = "Lucida Handwriting Italic")
dev.off()
warnings()
font.paths()
font.files()
font.add()
font.add("heiti", "simhei.ttf")
font.add("constan", "constan.ttf", italic = "constani.ttf")
install.packages("fRegression")
font_import(pattern="[C/c]omic")
font_import(pattern="[A/a]rial")
loadfonts(device="win")
library(extrafont)
loadfonts(device="win")
library(leaflet)
m<-leaflet(data=map.svg) %>%setView(-93.65, 42.0285, zoom = 17)
m
library(rgdal)
library(opencpu)
opencpu$browse('library/rCharts/www')
library(rCharts)
haireye%>%
morris(Freq~Hair,group="Eye",type="Bar",height=300)%>%
split_by("Sex")%>%
wrap_chart("Hair vs Eye Color",data=haireye)
library(magrittr)
library(rCharts)
haireye%>%
morris(Freq~Hair,group="Eye",type="Bar",height=300)%>%
split_by("Sex")%>%
wrap_chart("Hair vs Eye Color",data=haireye)
library(magrittr)
library(rCharts)
HairEyeColor%>%
morris(Freq~Hair,group="Eye",type="Bar",height=300)%>%
split_by("Sex")%>%
wrap_chart("Hair vs Eye Color",data=HairEyeColor)
demo(rCharts)
?hat()
install.packages(c("texreg","vizreg",RcppArmadillo))
install.packages(c("texreg","vizreg","RcppArmadillo"))
install.packages(c("vizreg","rgdal","locfit","mgcv","gam"))
install.packages("visreg")
devtools::install_github('rstudio/DT')
install.packages("cairo")
install.packages("Cairo")
devtools::install_github("rstudio/rsconnect")
devtools::install_github('ramnathv/htmlwidgets')
install.packages(c("ggtree","ggallery"))
install.packages(c("ggtree"))
devtools::install_github('htmlwidgets/sparkline')
devtools::install_github("GuangchuangYu/ggtree")
install.packages("ADGofTest")
install.packages("normtest")
install.packages(c("xlsx","gdata","dismo","quantreg","LaF"))
install.packages(c("systemfit"))
install.packages("rgdal")
install.packages(c("rgdal","plm"))
install.packages(c('multilevelPSA')
install.packages(c('multilevelPSA'))
install.packages(c("psy","mcmc","MCMCpack"))
install.packages(c("microbenmark","glmmAK","MCMCglmm"))
install.packages(c("microbenchmark","arm"))
install.packages(c("tseries","fBasics","moments"))
#lemma!!!
install.packages(c("Stat5303libs","cfcdae","oehlert"))
library(DT)
datatable(iris)
datatable(head(iris), class = 'cell-border stripe')
DT:::DT2BSClass('display')
datatable(iris)
DT:::DT2BSClass(c('compact', 'cell-border'))
datatable(iris)
datatable(head(mtcars))
datatable(head(mtcars), rownames = FALSE)
datatable(head(mtcars), rownames = head(LETTERS))
datatable(head(mtcars), rownames = FALSE)
datatable(head(mtcars), rownames = head(LETTERS))
datatable(iris2, extensions = 'AutoFill')
datatable(iris2, extensions = 'AutoFill')
datatable(iris, extensions = 'AutoFill')
datatable(iris2, extensions = list(AutoFill = list(
columnDefs = list(
list(enable = FALSE, targets = c(0, -1)),
list(increment = FALSE, targets = c(1, 2))
)
)))
datatable(iris, extensions = list(AutoFill = list(
columnDefs = list(
list(enable = FALSE, targets = c(0, -1)),
list(increment = FALSE, targets = c(1, 2))
)
)))
datatable(iris2, extensions = 'ColReorder', options = list(dom = 'Rlfrtip'))
datatable(iris, extensions = 'ColReorder', options = list(dom = 'Rlfrtip'))
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(dataTableOutput('foo')),
server = function(input, output) {
output$foo = renderDataTable({
datatable(
iris, extensions = 'TableTools', options = list(
dom = 'T<"clear">lfrtip',
tableTools = list(sSwfPath = copySWF('www'))
)
)
})
}
)
shiny::runApp('Bureau/linux/dtable')
shiny::runApp('Bureau/linux/stable')
devtools::install_github('rich-iannone/DiagrammeR')
devtools::install_github("bwlewis/rthreejs")
library(DiagrammeR)
grViz("
digraph {
layout = twopi
node [shape = circle]
A -> {B C D}
}")
library(rthreejs)
N <- 100
i <- sample(3, N, replace=TRUE)
x <- matrix(rnorm(N*3),ncol=3)
lab <- c("small", "bigger", "biggest")
scatterplot3js(x, color=rainbow(N), labels=lab[i], size=i, renderer="canvas")
library(threejs)
N <- 100
i <- sample(3, N, replace=TRUE)
x <- matrix(rnorm(N*3),ncol=3)
lab <- c("small", "bigger", "biggest")
scatterplot3js(x, color=rainbow(N), labels=lab[i], size=i, renderer="canvas")
library(networkD3)
# Create fake data
src <- c("A", "A", "A", "A",
"B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J",
"E", "F", "G", "H", "I")
networkData <- data.frame(src, target)
# Plot
simpleNetwork(networkData)
# Load data
data(MisLinks)
data(MisNodes)
# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8)
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths)
dygraph(lungDeaths) %>% dyRangeSelector()
dygraph(lungDeaths) %>%
dySeries("mdeaths", label = "Male") %>%
dySeries("fdeaths", label = "Female") %>%
dyOptions(stackedGraph = TRUE) %>%
dyRangeSelector(height = 20)
hw <- HoltWinters(ldeaths)
predicted <- predict(hw, n.ahead = 72, prediction.interval = TRUE)
dygraph(predicted, main = "Predicted Lung Deaths (UK)") %>%
dyAxis("x", drawGrid = FALSE) %>%
dySeries(c("lwr", "fit", "upr"), label = "Deaths") %>%
dyOptions(colors = RColorBrewer::brewer.pal(3, "Set1"))
library(htmltools)
library(htmlwidgets)
library(metricsgraphics)
library(RColorBrewer)
tmp <- data.frame(year=seq(1790, 1970, 10), uspop=as.numeric(uspop))
tmp %>%
mjs_plot(x=year, y=uspop) %>%
mjs_line() %>%
mjs_add_marker(1850, "Something Wonderful") %>%
mjs_add_baseline(150, "Something Awful")
tmp %>%
mjs_plot(x=uspop, y=year, width=500, height=400) %>%
mjs_bar() %>%
mjs_axis_x(xax_format = 'plain')
mtcars %>%
mjs_plot(x=wt, y=mpg, width=600, height=500) %>%
mjs_point(color_accessor=carb, size_accessor=carb) %>%
mjs_labs(x="Weight of Car", y="Miles per Gallon")
mtcars %>%
mjs_plot(x=wt, y=mpg, width=600, height=500) %>%
mjs_point(color_accessor=cyl,
x_rug=TRUE, y_rug=TRUE,
size_accessor=carb,
size_range=c(5, 10),
color_type="category",
color_range=brewer.pal(n=11, name="RdBu")[c(1, 5, 11)]) %>%
mjs_labs(x="Weight of Car", y="Miles per Gallon") %>%
mjs_add_legend(legend="X")
mtcars %>%
mjs_plot(x=wt, y=mpg, width=600, height=500) %>%
mjs_point(least_squares=TRUE) %>%
mjs_labs(x="Weight of Car", y="Miles per Gallon")
mtcars %>%
mjs_plot(x=wt, y=mpg, width=600, height=500) %>%
mjs_point(least_squares=TRUE) %>%
mjs_labs(x="Weight of Car", y="Miles per Gallon")
set.seed(1492)
stocks <- data.frame(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4))
stocks %>%
mjs_plot(x=time, y=X) %>%
mjs_line() %>%
mjs_add_line(Y) %>%
mjs_add_line(Z) %>%
mjs_axis_x(xax_format="date") %>%
mjs_add_legend(legend=c("X", "Y", "Z"))
lapply(1:7, function(x) {
mjs_plot(rnorm(10000, mean=x/2, sd=x), width=300, height=300) %>%
mjs_histogram(bar_margin=2) %>%
mjs_labs(x_label=sprintf("Plot %d", x))
}) -> plots
mjs_grid(plots)
lapply(1:7, function(x) {
mjs_plot(rnorm(10000, mean=x/2, sd=x), width=300, height=300) %>%
mjs_histogram(bar_margin=2) %>%
mjs_labs(x_label=sprintf("Plot %d", x))
}) -> plots
mjs_grid(plots)
library(rCharts)
## {title: Scatter Chart}
p1 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart')
p1$xAxis(axisLabel = 'Weight')
p1
## {title: MultiBar Chart}
hair_eye = as.data.frame(HairEyeColor)
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart')
p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
p2
## {title: MultiBar Chart}
hair_eye = as.data.frame(HairEyeColor)
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart')
p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
p2
## {title: MultiBar Horizontal Chart}
p3 <- nPlot(~ cyl, group = 'gear', data = mtcars, type = 'multiBarHorizontalChart')
p3$chart(showControls = F)
p3
## {title: Pie Chart}
p4 <- nPlot(~ cyl, data = mtcars, type = 'pieChart')
p4
## {title: Donut Chart}
p5 <- nPlot(~ cyl, data = mtcars, type = 'pieChart')
p5$chart(donut = TRUE)
p5
## {title: Line Chart}
data(economics, package = 'ggplot2')
p6 <- nPlot(uempmed ~ date, data = economics, type = 'lineChart')
p6
## {title: Line with Focus Chart }
ecm <- reshape2::melt(economics[,c('date', 'uempmed', 'psavert')], id = 'date')
p7 <- nPlot(value ~ date, group = 'variable', data = ecm, type = 'lineWithFocusChart')
#test format dates on the xAxis
#also good test of javascript functions as parameters
#dates from R to JSON will come over as number of days since 1970-01-01
#so convert to milliseconds 86400000 in a day and then format with d3
#on lineWithFocusChart type xAxis will also set x2Axis unless it is specified
p7$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Date( d * 86400000 ));}!#" )
#test xAxis also sets x2Axis
p7
p7$x2Axis( tickFormat="#!function(d) {return d3.time.format('%Y')(new Date( d * 86400000 ));}!#" )
p7
#test set xAxis again to make sure it does not override set x2Axis
p7$xAxis( NULL, replace = T)
p7
dat <- data.frame(t=rep(0:23,each=4),var=rep(LETTERS[1:4],4),val=round(runif(4*24,0,50)))
p8 <- nPlot(val ~ t, group = 'var', data = dat, type = 'stackedAreaChart', id = 'chart')
p8
## {title: InteractiveGuidline(Multi-Tooltips) on Line}
p9 <- nPlot(value ~ date, group = 'variable', data = ecm, type = 'lineChart')
p9$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Date( d * 86400000 ));}!#" )
#try new interactive guidelines feature
p9$chart(useInteractiveGuideline=TRUE)
p9
p10 <- p8
p10$chart(useInteractiveGuideline=TRUE)
p10
p11 <- p1
p11$chart(showDistX = TRUE, showDistY = TRUE)
p11
## {title: multiChart}
p12 <- nPlot(value ~ date, group = 'variable', data = ecm, type = 'multiChart')
p12$params$multi = list(
uempmed = list(type="area",yAxis=1),
psavert = list(type="line",yAxis=2)
)
p12$setTemplate(script = system.file(
"/libraries/nvd3/layouts/multiChart.html",
package = "rCharts"
))
p12
p13 <- nPlot(mpg ~ wt, data = mtcars, group = "gear", type = "scatterChart")
p13$params$facet = "cyl"
p13$templates$script = system.file(
"/libraries/nvd3/layouts/nvd3FacetPlot.html",
package = "rCharts"
)
p13
p13 <- nPlot(mpg ~ wt, data = mtcars, group = "gear", type = "scatterChart")
p13$params$facet = "cyl"
p13$templates$script = system.file(
"/libraries/nvd3/layouts/nvd3FacetPlot.html",
package = "rCharts"
)
p13
hair_eye = as.data.frame(HairEyeColor)
p14 <- nPlot(Freq ~ Hair, group = 'Sex', data = hair_eye, type = 'multiBarChart')
p14$params$facet="Eye"
p14$templates$script = system.file(
"/libraries/nvd3/layouts/nvd3FacetPlot.html",
package = "rCharts"
)
p14
p15 <- nPlot(Freq ~ Hair, group = 'Eye', data = hair_eye, type = 'multiBarChart')
p15$params$facet="Sex"
p15$templates$script = system.file(
"/libraries/nvd3/layouts/nvd3FacetPlot.html",
package = "rCharts"
)
p15
p16 <- nPlot(uempmed ~ date, data = economics, type = 'sparklinePlus',height=100,width=500)
p16$chart(xTickFormat="#!function(d) {return d3.time.format('%b %Y')(new Date( d * 86400000 ));}!#")
p16
p17 <- nPlot(
x = "date",
y = "volume",
data = spy.df,
type = "multiBarChart",
height = 200)
p17$chart(showControls = FALSE, showLegend = FALSE, showXAxis = FALSE, showYAxis = FALSE)
p17$xAxis(tickFormat =
"#!function(d) {return d3.time.format('%Y-%m-%d')(new Date(d * 24 * 60 * 60 * 1000));}!#"
)
p17
require(quantmod)
spy <- getSymbols("SPY",auto.assign=FALSE,from="2013-01-01")
colnames(spy) <- c("open","high","low","close","volume","adjusted")
spy.df <- data.frame(index(spy),spy)
colnames(spy.df)[1] <- "date"
p18 <- nPlot(
x = "date",
y = "close",
data = spy.df,
type = "ohlcBar"
)
p18
install.packages(c("rasterVis","quantmod","pcaPP","ppr","robustbase","plsr","prm","robust","pscl","ZIGP","dse","fArma","MSBVAR","fma","expsmooth","Mcomp","KernSmooth","Rmpi","npRmpi","SparseM","kinship","Ecdat","maxLik","mvtnorm","e1071","fugeR","sets","fuzzyFDR","mra","RMark","Rcapture",""))
library(devtools)
install_github("amplab-extras/SparkR-pkg", subdir="pkg")
install.packages(c("corrplot","clusterGeneration","mnormt"))
install.packages(c("randomForest","rpart","ROCR"))
?sample()
?sample.int()
sample.int(1e10, 12, replace = TRUE)
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
library(shiny)
library(leaflet)
ui <- fluidPage(leafletOutput("map1"))
server <- function(input, output, session) {
output$map1 <- renderLeaflet({
leaflet() %>% addCircleMarkers(lng = runif(10), lat = runif(10),
layerId = paste0("marker", 1:10))
})
observeEvent(input$map1_marker_click, {
leafletProxy("map1", session) %>% removeMarker(input$map1_marker_click$id)
})
}
shinyApp(ui, server)
sessionInfo()
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
?leaflet()
shiny::runApp('Bureau/carte_scolaire')
?closure()
summary(jardin)
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Téléchargements/shiny-examples-master/010-download')
shiny::runApp('Téléchargements/shiny-examples-master/004-mpg')
shiny::runApp('Téléchargements/shiny-examples-master/063-superzip-example')
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
shiny::runApp('Bureau/carte_scolaire')
install.packages('extrafont')
library(extrafont)
font_import()
fonts()
fonttable()
pdf("font_plot.pdf", family="Impact", width=4, height=4)
plot(mtcars$mpg, mtcars$wt,
main = "Fuel Efficiency of 32 Cars",
xlab = "Weight (x1000 lb)",
ylab = "Miles per Gallon")
pdf("font_plot.pdf", family="gargi", width=4, height=4)
plot(mtcars$mpg, mtcars$wt,
main = "Fuel Efficiency of 32 Cars",
xlab = "Weight (x1000 lb)",
ylab = "Miles per Gallon")
devtools::install_github(c("tdhock/ggplot2", "tdhock/animint"), build_vignettes=FALSE)
devtools::install_github("hadley/readr")
install.packages('cairoDevice')
shiny::runApp('Bureau/bike')
shiny::runApp('Bureau/bike')
install.packages(c("RJSONIO","jsonlite"))
install.packages(c("RJSONIO", "jsonlite"))
install.packages(c("RJSONIO", "jsonlite"))
library(animint)
example(animint)
names(pdfFonts())
shiny::runApp('Bureau/carte_scolaire')
devtools::install_github('rstudio/leaflet')
library(leaflet)
shiny::runApp('Bureau/carte_scolaire')
devtools::install_github('rstudio/leaflet')
devtools::install_github('rstudio/leaflet')
shiny::runApp('Bureau/carte_scolaire')
remove.packages("leafletR")
library(leafletR)
devtools::install_github('rstudio/leaflet')
shiny::runApp('Bureau/carte_scolaire')
remove.packages("leaflet")
devtools::install_github('rstudio/leaflet')
library(leaflet)
remove.packages("leaflet")
library(leaflet)
devtools::install_github('rstudio/leaflet')
library(leaflet)
shiny::runApp('Bureau/carte_scolaire')
devtools::install_github("rstudio/shiny")
shiny::runApp('Bureau/carte_scolaire')
devtools::install_github("rstudio/shiny")
library(shiny)
shiny::runApp('Bureau/carte_scolaire')