Dear R project team I used the function of "matrix" as follows: matrix(c(1:3030), 10.1/0.1) However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. Therefore, a warning message appeared. On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was OK. Of course, simply, 10.1/0.1 was successfully calculated. However, In the "matrix" environment, 10.1/0.1 was calculated as 100. Would you give me some answers? Sincerely Kazuki Sakura [[alternative HTML version deleted]]
1. Answers on this list are from volunteers who are not part of any R project team. We have no official status and what we say comes with no guarantees. 2. There is no such thing as a "matrix 'environment' ". 3. The answer to your question is "computer arithmetic." See FAQ 7.31. Someone may follow up with a more specific answer for your particular calculation, however. Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Oct 22, 2020 at 11:41 AM ?????? <jaajikan at gmail.com> wrote:> Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
(Neglected to cc the list--please reply-all to this version) What was the warning? I hazard a guess you've run into precision issues for binary representation, and the result of your division is not *exactly* 101. Pat On Thu, Oct 22, 2020 at 2:42 PM ?????? <jaajikan at gmail.com> wrote:> > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Patrick S. Malone, Ph.D., Malone Quantitative NEW Service Models: http://malonequantitative.com He/Him/His
FAQ 7.31> 10.1/.1[1] 101> print(10.1/.1, digits=17)[1] 100.99999999999999> floor(10.1/.1)[1] 100> floor(10.1*10)[1] 101> matrix(0, 2.9, 3.9)[,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0>note that the dimension arguments are passed through floor() before they are used. On Thu, Oct 22, 2020 at 2:42 PM ?????? <jaajikan at gmail.com> wrote:> > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
> 10.1/0.1 was successfully calculatedNote that 'computed as' is not the same as 'printed as'. Computations are done with 52 binary digits of precision and printing is, by default, done with 7 decimal digits of precision. See FAQ 7.31.> 101 - 10.1/0.1[1] 1.421085e-14> options(digits=17) > 10.1/0.1[1] 100.99999999999999> trunc(10.1/0.1)[1] 100 On Thu, Oct 22, 2020 at 11:42 AM ?????? <jaajikan at gmail.com> wrote:> Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]