File: runit1A.R

package info (click to toggle)
fbasics 240.10067-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,676 kB
  • ctags: 760
  • sloc: fortran: 5,589; sh: 22; makefile: 1
file content (178 lines) | stat: -rw-r--r-- 6,393 bytes parent folder | download
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

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
# GNU Library General Public License for more details.
#
# You should have received A copy of the GNU Library General 
# Public License along with this library; if not, write to the 
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
# MA  02111-1307  USA

# Copyrights (C)
# for this R-port: 
#   1999 - 2004, Diethelm Wuertz, GPL
#   Diethelm Wuertz <wuertz@itp.phys.ethz.ch>
#   info@rmetrics.org
#   www.rmetrics.org
# for the code accessed (or partly included) from other R-ports:
#   see R's copyright and license files
# for the code accessed (or partly included) from contributed R-ports
# and other sources
#   see Rmetrics's copyright file


################################################################################
# FUNCTION:                 INTERNAL TWO-DIMENSIONAL PLOT UTILITIES:    
#  .tsPlot                   Returns a time series plot
#  .responsesPlot            Returns a response series plot
#  .residualsPlot            Returns a residual series plot
#  histPlot                 Returns a histogram plot
#  densityPlot              Returns a kernel density estimate plot
#  .firePlot                 Returns a fitted values vs.residuals plot
#  qqbayesPlot              Returns a quantile-quantile plot
#  .acfPlot                  Returns a autocorrelation function plot
#  .pacfPlot                 Returns a partial ACF plot
#  .mrlPlot                  Returns a mean residual life plot
# FUNCTION:                 INTERNAL THREE-DIMENSIONAL PLOT UTILITIES:
#  .circlesPlot              Returns a circles plot indexing 3rd variable
#  .perspPlot                Returns a perspective plot in 2 dimensions
#  .contourPlot              Returns a contour plot in 2 dimensions
# FUNCTION:                 CHARACTER, SYMBOL AND COLOR TABLES:
#  characterTable            Shows a table of character's codes 
#  symbolTable               Shows a table of plot symbols
#  colorTable                Shows a table of plot color codes
# FUNCTION:                 COLOR PALETTES:
#  greyPalette               Creates a grey palette
#  .chcode                   Changes from one to another number system
#  .hex.to.dec               Converts heximal numbers do decimal numbers
#  .dec.to.hex               Converts decimal numbers do heximal numbers
# FUNCTION:                 SLIDER MENU:
#  .sliderMenu               Starts a slider menu
# FUNCTION:                 AKIMA SPLINE INTERPOLATION:
#  .akimaInterpolation       Does Akima Spline Interpolation
#  .interp                   Does Akima Spline Interpolation
# FUNCTION:                 JARQUE-BERA DATA TABLES:
# .jbLM                      Jarque-Bera Lagrange Multiplier Test Data
# .jbALM                     JB Augmented Lagrange Multiplier Test Data
################################################################################


test.helpFile = 
function()
{
    # Help File:
    helpFile = function() { 
        example(fBasicsUtilities); return() }
    checkIdentical(
        target = class(try(helpFile())),
        current = "NULL")

    # Return Value:
    return()    
}


# ------------------------------------------------------------------------------
# CHARACTER, SYMBOL AND COLOR TABLES:


test.tables = 
function()
{
    #  characterTable            Shows a table of character's codes 
    #  symbolTable               Shows a table of plot symbols
    #  colorTable                Shows a table of plot color codes
    
    # Shows a table of character's codes
    characterTable()
    
    # Shows a table of plot symbols
    symbolTable()
    
    # Shows a table of plot color codes
    colorTable()   
    
    # Return Value:
    return()    
}


# ------------------------------------------------------------------------------
# COLOR PALETTES:


test.palette = 
function()
{
    #  Creates a grey palette 
    greyPalette()   
    
    # Return Value:
    return()    
}


# ------------------------------------------------------------------------------
# AKIMA SPLINE INTERPOLATION:


test.interp = 
function()
{
    # Data:
    akima = list(
    x = c(
    11.16, 24.20, 12.85, 19.85, 10.35, 24.65, 19.72, 15.91,  0.00, 20.87, 
     6.71,  3.45, 19.99, 14.26, 10.28,  4.51, 17.43, 22.80,  0.00,  7.58, 
    16.70,  6.08,  1.99, 25.00, 14.90,  3.22,  0.00,  9.66,  2.56,  5.22, 
    11.77, 17.25, 15.10, 25.00, 12.13, 25.00, 22.33, 11.52, 14.59, 15.20,  
     7.54,  5.23, 17.32,  2.14,  0.51, 22.69, 25.00,  5.47, 21.67,  3.31),
    y = c(
     1.24, 16.23,  3.06, 10.72,  4.11,  2.40,  1.39,  7.74, 20.00, 20.00, 
     6.26, 12.78,  4.62, 17.87, 15.16, 20.00,  3.46, 12.39,  4.48,  1.98, 
    19.65,  4.58,  5.60, 11.87,  3.12, 16.78,  0.00, 20.00,  3.02, 14.66, 
    10.47, 19.57, 17.19,  3.87, 10.79,  0.00,  6.21,  8.53,  8.71,  0.00, 
    10.69, 10.72, 13.78, 15.03,  8.37, 19.63, 20.00, 17.13, 14.36,  0.13),
    z = c(
    22.15,  2.83, 22.11,  7.97, 22.33, 10.25, 16.83, 15.30, 34.60,  7.54,
    30.97, 41.24, 14.72, 10.74, 21.59, 15.61, 18.60,  5.47, 61.77, 29.87,  
     6.31, 35.74, 51.81,  4.40, 21.70, 39.93, 58.20,  4.73, 50.55, 40.36, 
    13.62,  6.43, 12.57,  8.74, 13.71, 12.00, 10.25, 15.74, 14.81, 21.60, 
    19.31, 26.50, 12.11, 53.10, 49.43,  3.25,  0.60, 28.63,  5.52, 44.08))

    # Interpolation:
    akima.lin = .interp(akima$x, akima$y, akima$z)
    Z = mean(akima.lin$z)
    checkSum = 21.70316
    checkEquals(target = Z, current = checkSum, tolerance = 0.00001)
    
    # Plots:
    par(ask = FALSE)
    par(mfrow = c(1, 1))
    image  (akima.lin, add = FALSE)
    contour(akima.lin, add = TRUE)
    points (akima, pch = 19)
    
    # Return Value:
    return()    
}


# ------------------------------------------------------------------------------


if (FALSE) {
    require(RUnit)
    testResult <- runTestFile("C:/Rmetrics/SVN/trunk/fBasics/test/runit1A.R")
    printTextProtocol(testResult)
}


# ------------------------------------------------------------------------------