~ubuntu-branches/ubuntu/precise/r-cran-slam/precise

« back to all changes in this revision

Viewing changes to tests/stm_rollup.Rout.save

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2011-02-10 11:41:40 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20110210114140-juiktz2cqqhznpyn
Tags: 0.1-20-1
* New upstream release

* debian/control: Set (Build-)Depends: to current R version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
R version 2.11.1 Patched (2010-09-30 r53135)
3
 
Copyright (C) 2010 The R Foundation for Statistical Computing
 
2
R version 2.12.1 Patched (2011-01-04 r53915)
 
3
Copyright (C) 2011 The R Foundation for Statistical Computing
4
4
ISBN 3-900051-07-0
 
5
Platform: i486-pc-linux-gnu (32-bit)
5
6
 
6
7
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
8
You are welcome to redistribute it under certain conditions.
28
29
> s <- as.simple_triplet_matrix(x)
29
30
> z <- as.matrix(s)
30
31
31
 
> identical(rollup(z, 2L, INDEX, sum), 
32
 
+         as.matrix(rollup(s, 2L, INDEX, sum)))
 
32
> rollup(z, 2L, rep(1L, 20L), fivenum)
 
33
     1        
 
34
[1,] Numeric,5
 
35
[2,] Numeric,5
 
36
[3,] Numeric,5
 
37
[4,] Numeric,5
 
38
[5,] Numeric,5
 
39
 
40
> identical(rollup(z, 2L, INDEX), 
 
41
+         as.matrix(rollup(s, 2L, INDEX)))
33
42
[1] TRUE
34
 
> identical(rollup(t(z), 1L, INDEX, sum), 
35
 
+         as.matrix(rollup(t(s), 1L, INDEX, sum)))
 
43
> identical(rollup(t(z), 1L, INDEX), 
 
44
+         as.matrix(rollup(t(s), 1L, INDEX)))
36
45
[1] TRUE
37
46
38
47
> ## NA indexes
40
49
> is.na(k) <- k == 1L
41
50
> any(is.na(k))
42
51
[1] TRUE
43
 
> identical(as.matrix(rollup(s, 2L, k, sum)), 
44
 
+         rollup(z, 2L, k, sum))
 
52
> identical(as.matrix(rollup(s, 2L, k)), 
 
53
+         rollup(z, 2L, k))
45
54
[1] TRUE
46
55
Warning message:
47
56
NA(s) in 'index' 
49
58
> ## other data types
50
59
> s$v <- as.integer(s$v)
51
60
52
 
> identical(rollup(z, 2L, INDEX, sum), 
53
 
+         as.matrix(rollup(s, 2L, INDEX, sum)))
 
61
> identical(rollup(z, 2L, INDEX), 
 
62
+         as.matrix(rollup(s, 2L, INDEX)))
54
63
[1] TRUE
55
64
56
65
> ## NA values
58
67
> z   <- as.matrix(s)
59
68
> z[] <- as.double(z) # coerce
60
69
61
 
> identical(rollup(z, 2L, INDEX, sum), 
62
 
+         as.matrix(rollup(s, 2L, INDEX, sum)))
 
70
> identical(rollup(z, 2L, INDEX), 
 
71
+         as.matrix(rollup(s, 2L, INDEX)))
63
72
[1] TRUE
64
 
> identical(rollup(z, 2L, INDEX, sum, na.rm = TRUE), 
65
 
+         as.matrix(rollup(s, 2L, INDEX, sum, na.rm = TRUE)))
 
73
> identical(rollup(z, 2L, INDEX, na.rm = TRUE), 
 
74
+         as.matrix(rollup(s, 2L, INDEX, na.rm = TRUE)))
66
75
[1] TRUE
67
76
68
77
> ##
69
78
> s$v <- as.double(s$v)
70
79
71
 
> identical(rollup(z, 2L, INDEX, sum, na.rm = TRUE), 
72
 
+         as.matrix(rollup(s, 2L, INDEX, sum, na.rm = TRUE)))
 
80
> identical(rollup(z, 2L, INDEX, na.rm = TRUE), 
 
81
+         as.matrix(rollup(s, 2L, INDEX, na.rm = TRUE)))
73
82
[1] TRUE
74
83
75
84
77
86
> s <- as.simple_sparse_array(s)
78
87
> z <- as.array(z)
79
88
80
 
> identical(rollup(z, 2L, INDEX, sum, na.rm = TRUE),
81
 
+         as.array(rollup(s, 2L, INDEX, sum, na.rm = TRUE)))
 
89
> identical(rollup(z, 2L, INDEX, na.rm = TRUE),
 
90
+         as.array(rollup(s, 2L, INDEX, na.rm = TRUE)))
82
91
[1] TRUE
83
92
84
93
> ##
85
94
> INDEX <- rep(1, dim(x)[2L])
86
95
87
 
> identical(rollup(z, 2L, INDEX, sum, na.rm = TRUE),
88
 
+         as.array(rollup(s, 2L, INDEX, sum, na.rm = TRUE)))
 
96
> identical(rollup(z, 2L, INDEX, na.rm = TRUE),
 
97
+         as.array(rollup(s, 2L, INDEX, na.rm = TRUE)))
89
98
[1] TRUE
90
99
91
100
> s <- as.simple_triplet_matrix(s)
92
 
> identical(rollup(z, 2L, INDEX, sum, na.rm = TRUE),
93
 
+         as.array(rollup(s, 2L, INDEX, sum, na.rm = TRUE)))
 
101
> identical(rollup(z, 2L, INDEX, na.rm = TRUE),
 
102
+         as.array(rollup(s, 2L, INDEX, na.rm = TRUE)))
94
103
[1] TRUE
95
104
> ###
96
105