[R] image plot with multiple x values

2007-08-17 Thread baptiste Auguié
Hi, New to R, I don't find a way to plot the following data with image(): x is a N * M matrix y is a vector of length M z is a N*M matrix I wish to plot z as a greyscale image, but my x axis is different for every row of the z data. Here is a minimal example, > theta<-c(3:6) # N > y<-c(1:5)

Re: [R] code optimization tips

2007-07-23 Thread baptiste Auguié
Thanks for your reply, On 23 Jul 2007, at 15:19, jim holtman wrote: > First question is why are you defining the functions within the main > function each time? Why don't you define them once outside? > Fair enough! As said, I'm new to R and don't know whether it is best to define functions

[R] code optimization tips

2007-07-23 Thread baptiste Auguié
Hi, Being new to R I'm asking for some advice on how to optimize the performance of the following piece of code: > alpha_c <- function(lambda=600e-9,alpha_s=1e-14,N=400,spacing=1e-7){ > > k<-2*pi/lambda > ri<-c(0,0) # particle at the origin > x<-c(-N:N) > positions <- function(N) { >reps <

Re: [R] create an array with rep

2007-07-22 Thread baptiste Auguié
Thank you all! This looks like the fastest solution, N being big and my machine slow I'll go for this one. Thanks, baptiste On 22 Jul 2007, at 12:54, Gavin Simpson wrote: >> >> I want to make the following array of numbers: >> >> -3 -3 -3 -3 -3 -3 -3 -2 -2 -2 -2 -2 -2 -2 ... 3 3 3 3 3

[R] create an array with rep

2007-07-22 Thread baptiste Auguié
Hi, I want to make the following array of numbers: -3 -3 -3 -3 -3 -3 -3 -2 -2 -2 -2 -2 -2 -2 ... 3 3 3 3 3 3 3 -3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3 ... -3 -2 -1 0 1 2 3 (3 would be N, a painful example to type number). Here is my dirty attempt to do it, > N<-3 > > x<-c(-N:N)

[R] custom point shapes

2007-07-20 Thread baptiste Auguié
Hi, I'm new to R, but a search through the list didn't quite solve this problem: I want to draw a few ellipses (or any custom shape for that matter) at given locations in a graph. I know how to plot points from my data, set the point type "pch" to any built in value, but I do not know how