Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread JRG via R-help
On Saturday, May 31st, 2025 at 7:44 PM, Bert Gunter wrote: > JRG: > > I don't think your specification is correct -- perhaps just a thinko. I think > a 10-tuple of "reals" (scare quotes because of computer precision) with your > specifications is what is wanted. > > Bert > > "An educated perso

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Bert Gunter
JRG: I don't think your specification is correct -- perhaps just a thinko. I think a 10-tuple of "reals" (scare quotes because of computer precision) with your specifications is what is wanted. Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself."

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread JRG via R-help
I'll second Bert's comments, also assuming this is not homework. In addition: Your use of "mid-point" is not a standard one (in my world), nor perhaps is that of "simulate". Let me attempt to re-state your problem: You wish to choose 10-tuples of integers 0 <= k <= 100 satisfying 1) 0 <= k_i

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Bert Gunter
If this is a real problem and not homework, can you tell us the context? It is not at all clear (to me) what you mean by "simulate", i.e. what your target distribution is, which may depend on/be defined by the context. Bert "An educated person is one who can entertain new ideas, entertain others,

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Jeff Newmiller via R-help
Your description is not clear at the point where you "project it to the original space." Anyway, this sounds like homework, as the solution to this particular example is trivial when considered from the right point of view. On May 31, 2025 12:06:49 PM PDT, Sergei Ko wrote: >Hi! >Just an idea.

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Sergei Ko
Hi! Just an idea. You randomly select the first point. Cut +/- 5 from the original space [0;100]. Select second point. Project it to the original space. Cut again. Repeat. Simplified method without cutting: every time mark +/- 5 as a bad space and select point again if it is in forbidden area. Hope

[R] Simulating mid-points from a defined range

2025-05-31 Thread Brian Smith
Hi, Let say I have a range [0, 100] Now I need to simulate 1000 10 mid-points within the range with accuracy upto second decimal number. Let say, one simulated set is X1, X2, ..., X10 Ofcourrse X1 < X2 < ... https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https:/

[R] Failed to convert text to date

2025-05-31 Thread Christofer Bogaso
Hi, I tried to convert a date-like string to date as below as.Date("202012", format = "%y%m") This gives NA Could you please help why I am getting NA value? __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mai

Re: [R] Failed to convert text to date

2025-05-31 Thread Rui Barradas
Hello, Inline. Às 17:56 de 31/05/2025, Dirk Eddelbuettel escreveu: On 31 May 2025 at 22:02, Christofer Bogaso wrote: | I tried to convert a date-like string to date as below | | as.Date("202012", format = "%y%m") | | This gives NA | | Could you please help why I am getting NA value? A _Date_

Re: [R] constructing a matrix for rgl plots

2025-05-31 Thread Duncan Murdoch
The akima package has a somewhat problematic license (the ACM license, which doesn't allow commercial use). The interp package provides some of the same functionality but is free open source. rgl has some support for output from interp. I forget if it would also work with akima. Duncan On

Re: [R] Failed to convert text to date

2025-05-31 Thread Dirk Eddelbuettel
On 31 May 2025 at 22:02, Christofer Bogaso wrote: | I tried to convert a date-like string to date as below | | as.Date("202012", format = "%y%m") | | This gives NA | | Could you please help why I am getting NA value? A _Date_ is comprised of three values for _year_, _month_ and _day_. What y

Re: [R] Failed to convert text to date

2025-05-31 Thread Jeff Newmiller via R-help
Read ?strptime. %y is not the same thing as %Y. On May 31, 2025 9:32:26 AM PDT, Christofer Bogaso wrote: >Hi, > >I tried to convert a date-like string to date as below > >as.Date("202012", format = "%y%m") > >This gives NA > >Could you please help why I am getting NA value? > >_

Re: [R] Failed to convert text to date

2025-05-31 Thread Iris Simmons
If I remember correctly, %y is the last 2 digits of the year, so 90 would be 1990 and 15 would be 2015. I think you meant %Y I think you can find this in ?Date, or maybe ?strptime, I can't remember exactly. On Sat, May 31, 2025, 12:38 Christofer Bogaso wrote: > Hi, > > I tried to convert a date

Re: [R] constructing a matrix for rgl plots

2025-05-31 Thread Ben Bolker
I'll mention that the 'akima' package is also handy for this kind of interpolation. On 5/31/25 11:18, Duncan Murdoch wrote: On 2025-05-31 7:04 a.m., ravi via R-help wrote: Hi, rgl plots seem to require the z object in the form of a matrix. I would like some help in constructing this matrix

Re: [R] constructing a matrix for rgl plots

2025-05-31 Thread Duncan Murdoch
On 2025-05-31 7:04 a.m., ravi via R-help wrote: Hi, rgl plots seem to require the z object in the form of a matrix. I would like some help in constructing this matrix when I cannot use the outer function. Let me explain. library(rgl) library(plot3D) x <- 1:10 y <- 1:20 fun1 <- function (x,y) {x

Re: [R] constructing a matrix for rgl plots

2025-05-31 Thread Jeff Newmiller via R-help
In the general case you cannot do that... you have to choose a way to interpolate your data points from a known x,y partition like your first example (your interpolation gets used as "f"). In the special case where your points in the data frame were generated as a grid, then you should still ha

[R] constructing a matrix for rgl plots

2025-05-31 Thread ravi via R-help
Hi, rgl plots seem to require the z object in the form of a matrix. I would like some help in constructing this matrix when I cannot use the outer function. Let me explain. library(rgl) library(plot3D) x <- 1:10 y <- 1:20 fun1 <- function (x,y) {x^2+y^2} z <- outer(x,y, fun1) open3d() surface3d(x