perf<-function(x0, xT){xT/x0}
rend<-function(x0, xT){xT/x0-1}
logret<-function(x){log(tail(x,-1)/head(x,-1))}
basket<-function(x,dim=c(1,3), f, ...){apply(x, dim, f, ...)}
# Fanno perdere 10% tempo (usare direttamente head(x,1) è come usare first e last )
#first<-function(x) head(x, 1)
#last<-function(x) tail(x, 1)
# Questo è come usare direttamente x[1]...
first<-function(x) x[1]
last<-function(x) x[length(x)]
# tail e' piu' generico, funziona con array e matrici
at <- function (x, pos) {
UseMethod("at", x)
}
at.numeric<-function(x,pos){x[pos]}
at.matrix<-function(x,pos){x[pos,]}
#runApp('inst/shiny-examples/HelloShiny/')
runExample <- function(example) {
# locate all the shiny app examples that exist
validExamples <- list.files(system.file("shiny-examples", package = "DeR"))
validExamplesMsg <-
paste0(
"Valid examples are: '",
paste(validExamples, collapse = "', '"),
"'")
# if an invalid example is given, throw an error
if (missing(example) || !nzchar(example) ||
!example %in% validExamples) {
stop(
'Please run `runExample()` with a valid example app as an argument.n',
validExamplesMsg,
call. = FALSE)
}
# find and launch the app
appDir <- system.file("shiny-examples", example, package = "mypackage")
shiny::runApp(appDir, display.mode = "normal")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.