Hello r-help,
why call:
#----------
outer(1:1000, 1:2, function(r,c) ifelse(m[r,c]<=0,.0001,m[r,c]) )
#----------
for matrix m with only 1000 rows and 2 columns forces my PC to use
more than 250Mb(!) of virtual memory? strange...
Best regards,
Valery A.Khamenya mailto:news_vkhamenya at chat.ru
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 22 Mar 2001 news_vkhamenya at chat.ru wrote:
Hello r-help,
why call:
#----------
outer(1:1000, 1:2, function(r,c) ifelse(m[r,c]<=0,.0001,m[r,c]) )
#----------
for matrix m with only 1000 rows and 2 columns forces my PC to use
more than 250Mb(!) of virtual memory? strange...
Um, a strange use of outer. Try
m[m <= 0] <- 0.0001
for an efficient solution.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
PBDR> Um, a strange use of outer. Try
PBDR> m[m <= 0] <- 0.0001
PBDR> for an efficient solution.
thank you for a good solution, it helps. but what if I need
#--------
outer(1:1000, 1:2, function(r,c) ifelse(m[r,c]<=0, some_f(m[r,c]), m[r,c]) )
#-------
?
P.S. however, "out of virtual memory" stil there... and is not
motivated yet. Maybe it is some kind of bug
Best regards,
Valery A.Khamenya mailto:news_vkhamenya at chat.ru
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
PBDR> Um, a strange use of outer. Try
PBDR> m[m <= 0] <- 0.0001
PBDR> for an efficient solution.
thank you for a good solution, it helps. but what if I need
#--------
outer(1:1000, 1:2, function(r,c) ifelse(m[r,c]<=0, some_f(m[r,c]), m[r,c]) )
#-------
?
m[m <= 0] <- some_f(m[m <= 0])
*provided* that some_f vectorizes properly. You may need
m[m <= 0] <- sapply(m[m <= 0], some_f)
P.S. however, "out of virtual memory" stil there... and is not
motivated yet. Maybe it is some kind of bug
Experiment with a smaller matrix, and you'll see the error of your ways:
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
At 08:49 22/03/01 +0000, Prof Brian D Ripley wrote:
On Thu, 22 Mar 2001 news_vkhamenya at chat.ru wrote:
Hello r-help,
why call:
#----------
outer(1:1000, 1:2, function(r,c) ifelse(m[r,c]<=0,.0001,m[r,c]) )
#----------
for matrix m with only 1000 rows and 2 columns forces my PC to use
more than 250Mb(!) of virtual memory? strange...
Um, a strange use of outer. Try
m[m <= 0] <- 0.0001
for an efficient solution.
--
[,1] [,2]
[1,] -0.4678067 -0.4678067
[2,] 1.3981146 1.3981146
[3,] -0.3987765 -0.3987765
I should get m here, but I get first column twice.
(R 1.2.2, w95)
---------------------------------------------------
Javier Mu?oz Criado
Delegado Provincial
Instituto Nacional de Estad?stica
C/ Cura 7 - 02071 Albacete - Espa?a
Tel 967 219 230 - Fax 967 216 649
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
PDB> (If there is a bug, it is in array() not complaining when its data=
PDB> argument is getting truncated).
did you refered to following bug:
#-----------------
"+"(1:3,10:11)
[1] 11 13 13
Warning message:
longer object length
is not a multiple of shorter object length in: 1:3 + 10:11
log(1:3,10:11)
[1] 0.0000000 0.2890648 0.4771213
#-----------------
which plays its role in
#...
robj <- array(FUN(X, Y, ...), c(dX, dY))
#...
of outer source?
Best regards,
Valery A.Khamenya mailto:news_vkhamenya at chat.ru
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Valery A.Khamenya" <news_vkhamenya at chat.ru> writes:
Hello Peter,
Thursday, March 22, 2001, 2:38:48 PM, you wrote:
PDB> (If there is a bug, it is in array() not complaining when its data=
PDB> argument is getting truncated).
did you refered to following bug:
#-----------------
"+"(1:3,10:11)
[1] 11 13 13
Warning message:
longer object length
is not a multiple of shorter object length in: 1:3 + 10:11
log(1:3,10:11)
[1] 0.0000000 0.2890648 0.4771213
#-----------------
which plays its role in
#...
robj <- array(FUN(X, Y, ...), c(dX, dY))
#...
of outer source?
No, this one
array(1:12,c(2,3))
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
One might have expected a warning that the array isn't big enough to
hold the data, but the behaviour *is* compatible with Splus 3.4....
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>> Thursday, March 22, 2001, 2:38:48 PM, you wrote:
>>
>>
PDB> (If there is a bug, it is in array() not complaining when its
PDB> data= argument is getting truncated).
>> did you refered to following bug:
>>
>> #-----------------
>> > "+"(1:3,10:11)
>> [1] 11 13 13
>> Warning message:
>> longer object length
>> is not a multiple of shorter object length in: 1:3 + 10:11
>> > log(1:3,10:11)
>> [1] 0.0000000 0.2890648 0.4771213
>> >
>> #-----------------
>>
>> which plays its role in
>>
>> #...
>> robj <- array(FUN(X, Y, ...), c(dX, dY))
>> #...
>>
>> of outer source?
PD> No, this one
PD> > array(1:12,c(2,3))
PD> [,1] [,2] [,3]
PD> [1,] 1 3 5
PD> [2,] 2 4 6
PD> >
PD> One might have expected a warning that the array isn't big enough
PD> to hold the data, but the behaviour *is* compatible with Splus
PD> 3.4....
and Splus 5.1, and in S+ its even a documented feature...
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._