A Sample Session

This section is an introduction to the R programming language. It shows how to perform very simple tasks using R using the jupyter environment. There are many other software systems available for interacting with and running R, for example, RStudio. However, jupyter is not limited to running just R, and it provides a great way to produce formatted markup and interactive code examples, which is why it has been chosen for this course.

Getting Started

To use R in jupyter you can type R commands into a code cell and then run them by pressing crtl-return. For example -

2+3
5
log(3.14)
1.14422279992016

Notice that the output produced by the R code is displayed below the cell once the cell has been executed by pressing ctrl-return. A cell can contain more than one line of code, for example -

sin(4.2)^2/4
log(exp(5))
4*atan(1)
0.189911081764586
5
3.14159265358979

R is an object orientated programming language in which pretty much everything is an object with a particular type associated with it. An instance of an object can be referenced through a variable. For example

x<-3.14
message<-"hello world"
v<-c(1,2,3,4)

Notice that executing this cell does not produce any output. The following one will though.

x
message
v
3.14
'hello world'
  1. 1
  2. 2
  3. 3
  4. 4

In this case the variable x refers to an object of type double with value 3.14. Notice that the <- operator was used to associate a variable with an object. You can also use = to do this. To determine the type of an object referred to by a variable x you can use the type function.

Optional material 1 - Names and values

The relationship between variables and values is well explained by Hadley Wickham in his highly regarded book Advanced R. See section 2.2 in the chapter names and values.

typeof(x)
'double'

Exercise 1

Find out what R types message and v are ?

typeof(message)
typeof(v)
'character'
'double'

Many of the common mathematical functions available in R will work with vectors of values. For example

y<-sin(v)
cat(y)
0.841471 0.9092974 0.14112 -0.7568025

Exercise 2

You can get information about a function using the help function. Open up a new R notebook in jupyter and run the following command to see what happens.

help(cat)

Loading packages

There are many “add ons” for R. The add ons are contained in packages. A package can be loaded into an R session using the library function. For example, there is a package called MASS. It can be loaded as follows.

library(MASS)

You can also use the library function to obtain information about a library. Try loading the MASS package using the library function in your jupyter notebook and find out what it kind of things it offers.

library(help="MASS")

Try loading the MASS package using the library function in your jupyter notebook and find out what it kind of things it offers.

There are many many packages for R, and you can make your own (not covered in this course). Most of them do not come as part of a standard R installation, but they are typically available from various online repositories, for example, CRAN, or frequently from github repositories.

Before you can load a package it has to be installed on your system. If it is not yet installed you can install it using the install.packages function. Note that this is not the only way, but it works well for the large number of generally well maintained packages that are available from CRAN. For instance, the zoo package is not usually part of an R installation so might not be installed on your system.

Exercise 3

Try running the following code in your notebook.

library("zoo")
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

Using the install.packages function you can install zoo from CRAN.

install.packages("zoo")
Installing package into ‘/home/grosedj/R-packages’
(as ‘lib’ is unspecified)
Warning message in install.packages("zoo"):
“installation of package ‘zoo’ had non-zero exit status”

Note that, once a library has been installed, it can be loaded using the library function and does not need to be reinstalled each time you use it. Packages can also be uninstalled using the remove.packages function.

You should now be able to load the zoo package.

library(zoo)

Some packages (but not all) have a vignette associated with them. Once the package is installed and loaded these vignettes (if they exist) can be accessed using the vignette function.

vignette("zoo")

There are functions that help you search for functions. These include apropos and find.

apropos("mean")
  1. '.colMeans'
  2. '.rowMeans'
  3. 'colMeans'
  4. 'kmeans'
  5. 'mean'
  6. 'mean.Date'
  7. 'mean.default'
  8. 'mean.difftime'
  9. 'mean.POSIXct'
  10. 'mean.POSIXlt'
  11. 'rollmean'
  12. 'rollmean.default'
  13. 'rollmeanr'
  14. 'rowMeans'
  15. 'weighted.mean'
find("rollmean")
'package:zoo'

It is also possible to search across packages that are available from the main repositories using the RSiteSearch function.

RSiteSearch("runmed")
A search query has been submitted to http://search.r-project.org
The results page should open in your browser shortly

Managing an R session

There are some basic functions to help you manage the variables, data, packages in your R session. The three main ones are

  • ls lists the objects in your workspace.

  • list.files lists the files located in the folder’s workspace

  • rm removes objects from your workspace; rm(list = ls()) removes them all.

For example

ls()
  1. 'message'
  2. 'v'
  3. 'x'
  4. 'y'
rm(y)
ls()
  1. 'message'
  2. 'v'
  3. 'x'

Note that

rm(list=ls())

removes ALL of your data and variables !!

ls()

The sessionInfo gives information about your session, i.e., loaded packages, R version, etc.

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] zoo_1.8-9   MASS_7.3-53

loaded via a namespace (and not attached):
 [1] lattice_0.20-44 fansi_0.5.0     digest_0.6.28   utf8_1.2.2     
 [5] crayon_1.4.1    IRdisplay_1.0   grid_4.1.0      repr_1.1.3     
 [9] lifecycle_1.0.1 jsonlite_1.7.2  evaluate_0.14   pillar_1.6.3   
[13] rlang_0.4.11    uuid_0.1-4      vctrs_0.3.8     ellipsis_0.3.2 
[17] IRkernel_1.2    tools_4.1.0     fastmap_1.1.0   compiler_4.1.0 
[21] base64enc_0.1-3 pbdZMQ_0.3-5    htmltools_0.5.2

Loading and saving data

You can save objects to a file using the save function …

x<-seq(1,10,0.1)
ls()
'x'
save(x,file="some.data.Rda")
rm(x)
ls()

… and load it using load

load(file="some.data.Rda")
ls()
x
'x'
  1. 1
  2. 1.1
  3. 1.2
  4. 1.3
  5. 1.4
  6. 1.5
  7. 1.6
  8. 1.7
  9. 1.8
  10. 1.9
  11. 2
  12. 2.1
  13. 2.2
  14. 2.3
  15. 2.4
  16. 2.5
  17. 2.6
  18. 2.7
  19. 2.8
  20. 2.9
  21. 3
  22. 3.1
  23. 3.2
  24. 3.3
  25. 3.4
  26. 3.5
  27. 3.6
  28. 3.7
  29. 3.8
  30. 3.9
  31. 4
  32. 4.1
  33. 4.2
  34. 4.3
  35. 4.4
  36. 4.5
  37. 4.6
  38. 4.7
  39. 4.8
  40. 4.9
  41. 5
  42. 5.1
  43. 5.2
  44. 5.3
  45. 5.4
  46. 5.5
  47. 5.6
  48. 5.7
  49. 5.8
  50. 5.9
  51. 6
  52. 6.1
  53. 6.2
  54. 6.3
  55. 6.4
  56. 6.5
  57. 6.6
  58. 6.7
  59. 6.8
  60. 6.9
  61. 7
  62. 7.1
  63. 7.2
  64. 7.3
  65. 7.4
  66. 7.5
  67. 7.6
  68. 7.7
  69. 7.8
  70. 7.9
  71. 8
  72. 8.1
  73. 8.2
  74. 8.3
  75. 8.4
  76. 8.5
  77. 8.6
  78. 8.7
  79. 8.8
  80. 8.9
  81. 9
  82. 9.1
  83. 9.2
  84. 9.3
  85. 9.4
  86. 9.5
  87. 9.6
  88. 9.7
  89. 9.8
  90. 9.9
  91. 10

Extra exercises

Extra Exercise 1

Install and load the runner package from CRAN.

Extra Exercise 1 - solution

install.packages("runner")
library(runner)
Installing package into ‘/home/grosedj/R-packages’
(as ‘lib’ is unspecified)
Warning message in install.packages("runner"):
“installation of package ‘runner’ had non-zero exit status”

Extra Exercise 2

What does the runner package do ?

Extra Exercise 2 - solution

library(help="runner")

Extra Exercise 3

Does the runner package have a vignette ?

Extra Exercise 3 - solution

vignette("runner")
Warning message:
“vignette ‘runner’ not found”

Extra Exercise 4

Run some of the examples for the runner function in the runner package in your jupyter notebook.

Extra Exercise 4 - solution 1

You could use help(“runner”) to get the help page for the runner function and cut and paste some of the examples into your notebook.

Extra Exercise 4 - solution 2

Or you could use the example function to run an example. Use help(example) to find out how to use example.

help(example)
example(runner)
runner> # runner returns windows as is by default
runner> runner(1:10)
[[1]]
[1] 1

[[2]]
[1] 1 2

[[3]]
[1] 1 2 3

[[4]]
[1] 1 2 3 4

[[5]]
[1] 1 2 3 4 5

[[6]]
[1] 1 2 3 4 5 6

[[7]]
[1] 1 2 3 4 5 6 7

[[8]]
[1] 1 2 3 4 5 6 7 8

[[9]]
[1] 1 2 3 4 5 6 7 8 9

[[10]]
 [1]  1  2  3  4  5  6  7  8  9 10


runner> # mean on k = 3 elements windows
runner> runner(1:10, f = mean, k = 3)
 [1] 1.0 1.5 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

runner> # mean on k = 3 elements windows with different specification
runner> runner(1:10, k = 3, f = function(x) mean(x, na.rm = TRUE))
 [1] 1.0 1.5 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0

runner> # concatenate two columns
runner> runner(
runner+   data.frame(
runner+     a = letters[1:10],
runner+     b = 1:10
runner+   ),
runner+   f = function(x) paste(paste0(x$a, x$b), collapse = "+")
runner+ )
 [1] "a1"                             "a1+b2"                         
 [3] "a1+b2+c3"                       "a1+b2+c3+d4"                   
 [5] "a1+b2+c3+d4+e5"                 "a1+b2+c3+d4+e5+f6"             
 [7] "a1+b2+c3+d4+e5+f6+g7"           "a1+b2+c3+d4+e5+f6+g7+h8"       
 [9] "a1+b2+c3+d4+e5+f6+g7+h8+i9"     "a1+b2+c3+d4+e5+f6+g7+h8+i9+j10"

runner> # concatenate two columns with additional argument
runner> runner(
runner+   data.frame(
runner+     a = letters[1:10],
runner+     b = 1:10
runner+   ),
runner+   f = function(x, xxx) {
runner+     paste(paste0(x$a, xxx, x$b), collapse = " + ")
runner+   },
runner+   xxx = "..."
runner+ )
 [1] "a...1"                                                                         
 [2] "a...1 + b...2"                                                                 
 [3] "a...1 + b...2 + c...3"                                                         
 [4] "a...1 + b...2 + c...3 + d...4"                                                 
 [5] "a...1 + b...2 + c...3 + d...4 + e...5"                                         
 [6] "a...1 + b...2 + c...3 + d...4 + e...5 + f...6"                                 
 [7] "a...1 + b...2 + c...3 + d...4 + e...5 + f...6 + g...7"                         
 [8] "a...1 + b...2 + c...3 + d...4 + e...5 + f...6 + g...7 + h...8"                 
 [9] "a...1 + b...2 + c...3 + d...4 + e...5 + f...6 + g...7 + h...8 + i...9"         
[10] "a...1 + b...2 + c...3 + d...4 + e...5 + f...6 + g...7 + h...8 + i...9 + j...10"

runner> # number of unique values in each window (varying window size)
runner> runner(letters[1:10],
runner+        k = c(1, 2, 2, 4, 5, 5, 5, 5, 5, 5),
runner+        f = function(x) length(unique(x)))
 [1] 1 2 2 4 5 5 5 5 5 5

runner> # concatenate only on selected windows index
runner> runner(letters[1:10],
runner+        f = function(x) paste(x, collapse = "-"),
runner+        at = c(1, 5, 8))
[1] "a"               "a-b-c-d-e"       "a-b-c-d-e-f-g-h"

runner> # 5 days mean
runner> idx <- c(4, 6, 7, 13, 17, 18, 18, 21, 27, 31, 37, 42, 44, 47, 48)

runner> runner::runner(
runner+   x = idx,
runner+   k = "5 days",
runner+   lag = 1,
runner+   idx = Sys.Date() + idx,
runner+   f = function(x) mean(x)
runner+ )
 [1]      NaN  4.00000  5.00000      NaN 13.00000 15.00000 15.00000 17.66667
 [9]      NaN 27.00000      NaN 37.00000 42.00000 43.00000 45.50000

runner> # 5 days mean at 4-indices
runner> runner::runner(
runner+   x = 1:15,
runner+   k = 5,
runner+   lag = 1,
runner+   idx = idx,
runner+   at = c(18, 27, 48, 31),
runner+   f = mean
runner+ )
[1]  4.5  NaN 13.5  9.0

runner> # runner with data.frame
runner> df <- data.frame(
runner+   a = 1:13,
runner+   b = 1:13 + rnorm(13, sd = 5),
runner+   idx = seq(Sys.Date(), Sys.Date() + 365, by = "1 month")
runner+ )

runner> runner(
runner+   x = df,
runner+   idx = "idx",
runner+   at = "6 months",
runner+   f = function(x) {
runner+     cor(x$a, x$b)
runner+   }
runner+ )
[1]        NA 0.3475841 0.6851250

runner> # parallel computing
runner> library(parallel)

runner> data <- data.frame(
runner+   a = runif(100),
runner+   b = runif(100),
runner+   idx = cumsum(sample(rpois(100, 5)))
runner+ )

runner> const <- 0

runner> cl <- makeCluster(1)

runner> clusterExport(cl, "const", envir = environment())

runner> runner(
runner+   x = data,
runner+   k = 10,
runner+   f = function(x) {
runner+     cor(x$a, x$b) + const
runner+   },
runner+   idx = "idx",
runner+   cl = cl
runner+ )
  [1]          NA          NA -1.00000000 -1.00000000 -1.00000000  1.00000000
  [7]  1.00000000 -0.02406551  0.57596631 -1.00000000 -0.19715196 -0.70792668
 [13] -0.97432698 -0.97839715 -0.69811314 -0.95690777 -0.80294208 -0.97518120
 [19] -0.80186770  0.86766778  0.69656681 -1.00000000 -1.00000000  1.00000000
 [25]  1.00000000 -1.00000000 -1.00000000 -0.98300268 -0.99964395 -0.67338813
 [31] -1.00000000  1.00000000  1.00000000 -0.47035257  1.00000000          NA
 [37]  1.00000000  0.13266426 -1.00000000 -0.84707762  0.17269759          NA
 [43]  1.00000000  1.00000000 -1.00000000 -1.00000000          NA -1.00000000
 [49] -1.00000000 -1.00000000  1.00000000  1.00000000 -1.00000000 -1.00000000
 [55] -0.95033099          NA -1.00000000 -1.00000000 -0.83734499 -0.97925953
 [61]  1.00000000  1.00000000  1.00000000  0.27582934          NA -1.00000000
 [67]  1.00000000 -0.07230298 -1.00000000 -1.00000000 -1.00000000  1.00000000
 [73]  0.95251177 -0.21675182  1.00000000  1.00000000 -1.00000000  1.00000000
 [79]  0.20456288  0.04501547  1.00000000  0.96364693  0.70777742  1.00000000
 [85]  0.94506532  0.65082627  0.70741548 -1.00000000  1.00000000  0.88537501
 [91] -0.91473386 -1.00000000 -0.47195878  1.00000000 -1.00000000  1.00000000
 [97]  1.00000000 -1.00000000 -0.84414934 -0.70172397

runner> stopCluster(cl)

runner> # runner with matrix
runner> data <- matrix(data = runif(100, 0, 1), nrow = 20, ncol = 5)

runner> runner(
runner+   x = data,
runner+   f = function(x) {
runner+     tryCatch(
runner+       cor(x),
runner+       error = function(e) NA
runner+     )
runner+  })
      [,1] [,2]       [,3]       [,4]        [,5]         [,6]        [,7]
 [1,]   NA    1  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000
 [2,]   NA   -1 -0.9460579 -0.7155315 -0.65260273 -0.682754094 -0.58816547
 [3,]   NA   -1 -0.9544188 -0.8970056 -0.51081380 -0.410016672 -0.06613770
 [4,]   NA    1  0.9902986 -0.1032737 -0.09359698  0.124248989  0.07287985
 [5,]   NA   -1 -0.9942494 -0.9970648 -0.35787071 -0.483273889 -0.36024564
 [6,]   NA   -1 -0.9460579 -0.7155315 -0.65260273 -0.682754094 -0.58816547
 [7,]   NA    1  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000
 [8,]   NA    1  0.8062316  0.7880606  0.69992732  0.670946922  0.59255895
 [9,]   NA   -1 -0.8918586 -0.5093974 -0.50377103 -0.552130550 -0.56198411
[10,]   NA    1  0.9059207  0.6634747  0.47694044  0.537280515  0.55392941
[11,]   NA   -1 -0.9544188 -0.8970056 -0.51081380 -0.410016672 -0.06613770
[12,]   NA    1  0.8062316  0.7880606  0.69992732  0.670946922  0.59255895
[13,]   NA    1  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000
[14,]   NA   -1 -0.9866338 -0.2925693 -0.28147417 -0.277692922 -0.29517448
[15,]   NA    1  0.9808934  0.8900514  0.87941698  0.833423645  0.76425294
[16,]   NA    1  0.9902986 -0.1032737 -0.09359698  0.124248989  0.07287985
[17,]   NA   -1 -0.8918586 -0.5093974 -0.50377103 -0.552130550 -0.56198411
[18,]   NA   -1 -0.9866338 -0.2925693 -0.28147417 -0.277692922 -0.29517448
[19,]   NA    1  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000
[20,]   NA   -1 -0.9994845  0.1478981  0.11371393 -0.003648223 -0.03953874
[21,]   NA   -1 -0.9942494 -0.9970648 -0.35787071 -0.483273889 -0.36024564
[22,]   NA    1  0.9059207  0.6634747  0.47694044  0.537280515  0.55392941
[23,]   NA    1  0.9808934  0.8900514  0.87941698  0.833423645  0.76425294
[24,]   NA   -1 -0.9994845  0.1478981  0.11371393 -0.003648223 -0.03953874
[25,]   NA    1  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000
            [,8]       [,9]       [,10]        [,11]       [,12]        [,13]
 [1,]  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000  1.000000000
 [2,] -0.2993501 -0.2835753 -0.44918920 -0.458074708 -0.53665127 -0.432624050
 [3,] -0.2450048 -0.1968667 -0.38032097 -0.353794956 -0.45325057 -0.238829326
 [4,] -0.1933915 -0.1854937 -0.37896108 -0.448556063 -0.59551218 -0.626958037
 [5,] -0.2272557 -0.2956422 -0.01435647  0.006934196 -0.08996282  0.054087299
 [6,] -0.2993501 -0.2835753 -0.44918920 -0.458074708 -0.53665127 -0.432624050
 [7,]  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000  1.000000000
 [8,]  0.2098978  0.2098939  0.44950267  0.442262427  0.50364337  0.538750985
 [9,] -0.6838302 -0.6760901 -0.14584835 -0.083189717  0.12129149 -0.052798966
[10,]  0.5911913  0.5936944  0.14037286  0.131380716  0.18741995  0.263524453
[11,] -0.2450048 -0.1968667 -0.38032097 -0.353794956 -0.45325057 -0.238829326
[12,]  0.2098978  0.2098939  0.44950267  0.442262427  0.50364337  0.538750985
[13,]  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000  1.000000000
[14,]  0.1324235  0.1326876  0.40115303  0.339143078  0.45379797  0.002233075
[15,]  0.5105684  0.5024432  0.08456699  0.087468538  0.14825120  0.328297335
[16,] -0.1933915 -0.1854937 -0.37896108 -0.448556063 -0.59551218 -0.626958037
[17,] -0.6838302 -0.6760901 -0.14584835 -0.083189717  0.12129149 -0.052798966
[18,]  0.1324235  0.1326876  0.40115303  0.339143078  0.45379797  0.002233075
[19,]  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000  1.000000000
[20,] -0.1913440 -0.1766178 -0.41479895 -0.403604362 -0.21129970 -0.428357780
[21,] -0.2272557 -0.2956422 -0.01435647  0.006934196 -0.08996282  0.054087299
[22,]  0.5911913  0.5936944  0.14037286  0.131380716  0.18741995  0.263524453
[23,]  0.5105684  0.5024432  0.08456699  0.087468538  0.14825120  0.328297335
[24,] -0.1913440 -0.1766178 -0.41479895 -0.403604362 -0.21129970 -0.428357780
[25,]  1.0000000  1.0000000  1.00000000  1.000000000  1.00000000  1.000000000
             [,14]         [,15]       [,16]       [,17]        [,18]
 [1,]  1.000000000  1.0000000000  1.00000000  1.00000000  1.000000000
 [2,] -0.377020604 -0.3133838426 -0.31931366 -0.32929549 -0.249278966
 [3,] -0.248737572 -0.2522187453 -0.23329102 -0.25684371 -0.206847612
 [4,] -0.613867060 -0.5528029329 -0.47063270 -0.37134813 -0.394298485
 [5,]  0.017488675  0.0004203491  0.04435108  0.03769265 -0.008733826
 [6,] -0.377020604 -0.3133838426 -0.31931366 -0.32929549 -0.249278966
 [7,]  1.000000000  1.0000000000  1.00000000  1.00000000  1.000000000
 [8,]  0.461681331  0.3086958912  0.29914558  0.32212498  0.387266897
 [9,] -0.023362695  0.1538156529  0.12275294  0.05455857 -0.097965745
[10,]  0.125136088 -0.0653681116 -0.08314120 -0.07539216 -0.181319987
[11,] -0.248737572 -0.2522187453 -0.23329102 -0.25684371 -0.206847612
[12,]  0.461681331  0.3086958912  0.29914558  0.32212498  0.387266897
[13,]  1.000000000  1.0000000000  1.00000000  1.00000000  1.000000000
[14,] -0.009162908 -0.0823253379 -0.04377865 -0.18032443 -0.263744740
[15,]  0.352535106  0.3940233799  0.40486141  0.39959298  0.284129618
[16,] -0.613867060 -0.5528029329 -0.47063270 -0.37134813 -0.394298485
[17,] -0.023362695  0.1538156529  0.12275294  0.05455857 -0.097965745
[18,] -0.009162908 -0.0823253379 -0.04377865 -0.18032443 -0.263744740
[19,]  1.000000000  1.0000000000  1.00000000  1.00000000  1.000000000
[20,] -0.429450829 -0.5067133447 -0.35743905 -0.34531300 -0.182515975
[21,]  0.017488675  0.0004203491  0.04435108  0.03769265 -0.008733826
[22,]  0.125136088 -0.0653681116 -0.08314120 -0.07539216 -0.181319987
[23,]  0.352535106  0.3940233799  0.40486141  0.39959298  0.284129618
[24,] -0.429450829 -0.5067133447 -0.35743905 -0.34531300 -0.182515975
[25,]  1.000000000  1.0000000000  1.00000000  1.00000000  1.000000000
            [,19]       [,20]
 [1,]  1.00000000  1.00000000
 [2,] -0.25041112 -0.31801140
 [3,] -0.15838836 -0.03608227
 [4,] -0.39010355 -0.43867377
 [5,] -0.01345702 -0.08996812
 [6,] -0.25041112 -0.31801140
 [7,]  1.00000000  1.00000000
 [8,]  0.28867545  0.16508364
 [9,] -0.10314804 -0.02227722
[10,] -0.16647701 -0.08434418
[11,] -0.15838836 -0.03608227
[12,]  0.28867545  0.16508364
[13,]  1.00000000  1.00000000
[14,] -0.17071813 -0.24113294
[15,]  0.13589086  0.04202992
[16,] -0.39010355 -0.43867377
[17,] -0.10314804 -0.02227722
[18,] -0.17071813 -0.24113294
[19,]  1.00000000  1.00000000
[20,] -0.19502713 -0.11982366
[21,] -0.01345702 -0.08996812
[22,] -0.16647701 -0.08434418
[23,]  0.13589086  0.04202992
[24,] -0.19502713 -0.11982366
[25,]  1.00000000  1.00000000