Help:Demonstrations

From Stikir

(Redirected from Help:Tutorials)
Jump to: navigation, search

This page contains some simple analyses that demonstrate key functionality of Stikir

Some analyses may depend on uploaded data (see - Special:upload), and on data previously loaded and saved in an R workspace. Refer to Help:Saving R Workspaces (Warning: more than 3 min load time) and Help:Loading a Workspace for more information on Loading and Saving datasets.

Contents

Reading in a data file and running an R command that returns text

Summary Statistics of foreign exchange rates (and gold)

This code executes to produce the following table.

 FX_Data<-readdataSK(name="FX_Data.csv",format="csv",na.strings="#N/A")
 summary(FX_Data)

#
       Date           CAD             EUR                 GBP        
1-Apr-02:   1   Min.   :1.099   Min.   :   0.7341   Min.   :0.4990  
1-Apr-03:   1   1st Qu.:1.197   1st Qu.:   0.8088   1st Qu.:0.5695  
1-Apr-04:   1   Median :1.347   Median :   0.8652   Median :0.6138  
1-Apr-05:   1   Mean   :1.335   Mean   :   0.8973   Mean   :0.6100  
1-Apr-88:   1   3rd Qu.:1.453   3rd Qu.:   0.9488   3rd Qu.:0.6453  
1-Apr-91:   1   Max.   :1.613   Max.   :   1.2087   Max.   :0.7283  
(Other) :4752                   NA's   :1281.0000                   
     JPY              AUD               CNY                DKK         
Min.   : 81.07   Min.   :  1.221   Min.   :   5.705   Min.   :  5.353  
1st Qu.:108.28   1st Qu.:  1.320   1st Qu.:   8.276   1st Qu.:  5.995  
Median :118.25   Median :  1.395   Median :   8.278   Median :  6.410  
Mean   :118.88   Mean   :  1.479   Mean   :   8.125   Mean   :  6.618  
3rd Qu.:127.82   3rd Qu.:  1.579   3rd Qu.:   8.292   3rd Qu.:  6.949  
Max.   :159.91   Max.   :  2.070   Max.   :   8.740   Max.   :  8.999  
                 NA's   :770.000   NA's   :1306.000   NA's   :766.000  
     NLG               XAU                 MXN                NZD         
Min.   :  1.518   Min.   :1.379e-03   Min.   :   3.092   Min.   :  1.343  
1st Qu.:  1.747   1st Qu.:2.573e-03   1st Qu.:   7.757   1st Qu.:  1.526  
Median :  1.877   Median :2.829e-03   Median :   9.365   Median :  1.741  
Mean   :  1.942   Mean   :2.892e-03   Mean   :   8.718   Mean   :  1.772  
3rd Qu.:  2.055   3rd Qu.:3.376e-03   3rd Qu.:  10.583   3rd Qu.:  1.912  
Max.   :  2.664   Max.   :3.966e-03   Max.   :  11.632   Max.   :  2.551  
NA's   :770.000   NA's   :1.024e+03   NA's   :1423.000   NA's   :788.000  
     PLN                RUB                ZAR                KRW        
Min.   :   2.459   Min.   :   4.528   Min.   :   3.625   Min.   : 667.2  
1st Qu.:   3.220   1st Qu.:   6.875   1st Qu.:   5.732   1st Qu.: 774.3  
Median :   3.664   Median :  27.904   Median :   6.365   Median : 890.8  
Mean   :   3.618   Mean   :  22.423   Mean   :   6.674   Mean   : 967.6  
3rd Qu.:   4.035   3rd Qu.:  29.101   3rd Qu.:   7.554   3rd Qu.:1177.7  
Max.   :   4.706   Max.   :  31.950   Max.   :  13.471   Max.   :1952.7  
NA's   :2041.000   NA's   :2034.000   NA's   :2020.000   NA's   :  64.0  
     CHF             TWD              THB               TRY           
Min.   :1.117   Min.   : 24.50   Min.   :  22.59   Min.   :2.892e-03  
1st Qu.:1.286   1st Qu.: 26.93   1st Qu.:  25.43   1st Qu.:3.649e-02  
Median :1.429   Median : 28.98   Median :  38.56   Median :2.908e-01  
Mean   :1.423   Mean   : 29.93   Mean   :  35.60   Mean   :6.178e-01  
3rd Qu.:1.519   3rd Qu.: 32.99   3rd Qu.:  41.47   3rd Qu.:1.351e+00  
Max.   :1.821   Max.   : 35.11   Max.   :  55.80   Max.   :1.764e+00  
                NA's   :208.00   NA's   :1292.00   NA's   :7.540e+02  
     SEK               USD   
Min.   :  5.086   Min.   :1  
1st Qu.:  6.844   1st Qu.:1  
Median :  7.647   Median :1  
Mean   :  7.681   Mean   :1  
3rd Qu.:  8.220   3rd Qu.:1  
Max.   : 11.019   Max.   :1  
NA's   :505.000              

Loading a Library and running an R command that plots an image

This code produces the following "dendogram" illustrating the degree of similarity in currency's historical rates

dates<-FX_Data[,1]
FX_Rates<- as.ts(FX_Data[,3:ncol(FX_Data)-1])
FX_Rates.Correlation<- cor(FX_Rates, use="pairwise.complete.obs")
FX_Rates.DistanceMeasure <- as.dist(1-FX_Rates.Correlation)
library(cluster)
FX_Rates.Clusters <- hclust(FX_Rates.DistanceMeasure, method="ward", members=NULL)
pdf(rpdf, width=7, height=5)
plot(FX_Rates.Clusters)

#

Loading a previously saved workspace

This code:

<R output="display" workspace="FX">
pdf(rpdf, width=5, height=4)
plot(FX_Rates[,c("GBP","CAD","XAU")], main="GBP, EUR, and Gold time series plots")
</R>

does this:

Creating a "Rform" using html controls

This code:

<Rform name="binom">
n: <input name="n" type="text" size="5" maxlength="5" value="12"> 
prob: <input name="prob" type="text" size="5" maxlength="5" value="0.2"> 
<input type="submit" value=" Submit ">
</Rform>

does this:

Enter the parameters of a Binomial distribution

n: prob:

Passing user input from the Rform to an R analysis

And you will get the probability mass function plotted here

This code:

<R output="display" name="binom" iframe="height:400px;">
if (exists("prob")) prob <- as.numeric(prob) else prob <- 0.2
if (exists("n")) n <- as.numeric(n) else n <- 12
x <- seq(0, n, 1)
p <- dbinom(x, n, prob)
param <- list(n, prob)
main <- c("Binomial Distribution P.M.F.", paste (c("Trials n", "Probability p"), param, sep="="))
pdf(rpdf, width=4, height=4)
plot(x,p, type="h", main=main)
</R>

does this:

--WikiSysop 12:00, 25 April 2007 (EDT)

Personal tools
Registration
Contact