Re: [R] Is not really anybody answer me ????

2016-03-19 Thread Tsjerk Wassenaar
Hi Majid, Maybe no one knew the answer, or the question was not understood. There's no central board assigning questions to answerers, so sometimes questions do not find one. You don't have a right to get an answer, but you ask someone to invest time and do you a favor. Maybe this can be of some

Re: [R] Variance-covariance matrix

2015-05-10 Thread Tsjerk Wassenaar
) . . . Σ *x*n2 / (N-1) Reference: “Time series and its applications – with R examples”, Springer, $7.8 “Principal Components” pag. 468, 469 Cheers, Giorgio *From:* Tsjerk Wassenaar [mailto:tsje...@gmail.com] *Sent:* domenica 10 maggio 2015 22:11 *To:* Giorgio Garziano

Re: [R] Variance-covariance matrix

2015-05-10 Thread Tsjerk Wassenaar
Hi Giorgio, For a univariate time series? Seriously? data - rnorm(10,2,1) as.matrix(var(data)) Cheers, Tsjerk On Sun, May 10, 2015 at 9:54 PM, Giorgio Garziano giorgio.garzi...@ericsson.com wrote: Hi, Actually as variance-covariance matrix I mean:

Re: [R] DeSolver giving NA as output, but running fully.

2015-04-30 Thread Tsjerk Wassenaar
Hey :) W2MH = y[43]; #number of infected vaccinated males high risk infected with non-vaccine strain length(y0) [1] 42 As a sidenote, would you mind sharing the flow diagram with me, so I can show it to my students doing a practical with DeSolve, as example of a contemporary

Re: [R] Generating a polygon around points

2014-08-15 Thread Tsjerk Wassenaar
Hi Bob, You probably want to have a look at the package alphahull. Cheers, Tsjerk On Fri, Aug 15, 2014 at 5:25 PM, Clint Bowman cl...@ecy.wa.gov wrote: Your question seems to need an answer to, How do you find a convex hull on a sphere? Google has many references. Clint Bowman

Re: [R] squashed domains when doing PCA with bio3d

2014-01-13 Thread Tsjerk Wassenaar
Hi Bianca, If the domains are rotated between the trajectories, the motion cannot be captured by a single linear component. Think of projecting an arc on a straight line. You loose the (deflection) part on the second component. That looks like squashing. I've mentioned this in relation to MD

Re: [R] Adding up normally distributed numbers seems to not create a t-distribution

2013-10-26 Thread Tsjerk Wassenaar
Hi :) Try this with other distributions too... And then search for 'central limit theorem'. Cheers, Tsjerk On Fri, Oct 25, 2013 at 4:48 PM, Kramer, Christian christian.kra...@uibk.ac.at wrote: Hi there, I have found a strange behavior in R that puzzles me - maybe it is a bug or a basic

Re: [R] Adding up normally distributed numbers seems to not create a t-distribution

2013-10-26 Thread Tsjerk Wassenaar
,sigma^2/n). Exactly. No asymptotics, no approximations, no CLT. cheers, Rolf Turner On 10/26/13 20:17, Tsjerk Wassenaar wrote: Hi :) Try this with other distributions too... And then search for 'central limit theorem'. Cheers, Tsjerk On Fri, Oct 25, 2013 at 4:48 PM

Re: [R] Adding up normally distributed numbers seems to not create a t-distribution

2013-10-26 Thread Tsjerk Wassenaar
*sqrt(3))) Cheers, T. On Sat, Oct 26, 2013 at 10:26 AM, Rolf Turner r.tur...@auckland.ac.nzwrote: On 10/26/13 21:20, Tsjerk Wassenaar wrote: Of course. But the point is that this would happen with summing samples from any distribution. ***What*** would happen? You are confused about

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Tsjerk Wassenaar
Hi Michel, lines(xx,yy,col=zz-2,type=s) If you use a color vector, say cols, then you can also do lines(xx,yy,col=cols[zz-2],type=s) Hope it helps, Tsjerk On Mon, Sep 16, 2013 at 8:42 AM, Arnaud Michel michel.arn...@cirad.frwrote: Hi I have the following problem : I have 3 vectors xx,

Re: [R] Change the color of the line inside of the function lines

2013-09-16 Thread Tsjerk Wassenaar
Michel michel.arn...@cirad.frwrote: Hi Tsjerk Thank you but the color always remains black ! I would want that the color changes on the same graph (color = 3 on the 4 first steps, col = 4 on 5 following steps Michel Le 16/09/2013 09:01, Tsjerk Wassenaar a écrit : Hi Michel

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Tsjerk Wassenaar
t(apply(test,1,sample)) will also do. As the OP noted, the results are simply transposed. So if an operation is to be applied to rows, yielding modified rows, simply transpose the results. Cheers, Tsjerk On Tue, May 14, 2013 at 12:07 PM, Ted Harding ted.hard...@wlandres.netwrote: On

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Tsjerk Wassenaar
Hi Mark Na, Try: grepl(latitude\\^2,temp) ^ is a control character for negation, so you have to escape it. Cheers, Tsjerk On Mon, Jan 21, 2013 at 4:26 PM, mtb...@gmail.com wrote: Hello R-helpers, I am trying to search for string that includes the caret symbol, using the following code:

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Tsjerk Wassenaar
Oh, I'm jetlagged. ^ is a control character for 'start of string'. In the context of a character set it means negation: [^a-z]. Ciao, Tsjerk On Mon, Jan 21, 2013 at 4:33 PM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Mark Na, Try: grepl(latitude\\^2,temp) ^ is a control character

Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops

2012-03-14 Thread Tsjerk Wassenaar
Hi Lazarus, Checkout arrays (?array). You can cast your matrix to an array of submatrices, and calculate the means per block using apply. Cheers, Tsjerk On Mar 14, 2012 9:25 AM, Lazarus Mramba lmra...@gmail.com wrote: Dear all, I have a large matrix with about 2500 variables, and 100 rows.

Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops

2012-03-14 Thread Tsjerk Wassenaar
Hi Lazarus, Sorry for my brevity before. I sent it from a phone. # Generate dummy data matrix x - matrix(1:100,nrow=5) # Rearrange into array; ten groups of two columns y - array(x,c(5,2,10)) # Average columns for each submatrix apply(y,c(1,3),mean) # Average per submatrix apply(y,3,mean)

Re: [R] Creating 250 submatrices from a large single matrix with 2500 variables using loops

2012-03-14 Thread Tsjerk Wassenaar
Hi Lazarus, You should use apply, not sapply. a =matrix(1:12, nrow=2,ncol=6,byrow=TRUE) b = array(a,c(2,2,3));b colMeans(b) f1=function(x) sum(x)/length(row(a.df[,1:2])) y3 - apply(b, 1, f1) It only gives one matrix with only two values, I expected 3 values. To apply the function on

Re: [R] built a lower triangular matrix from dataframe

2012-02-16 Thread Tsjerk Wassenaar
Hey, You could also use (after initializing x): x[lower.tri(x)] - data$k x - t(x) Cheers, Tsjerk On Feb 16, 2012 6:59 PM, Rui Barradas rui1...@sapo.pt wrote: Hello, I'm glad it helped. The difference in the ordering is due to the fact that R defaults to column-first ordering. David's

Re: [R] built a lower triangular matrix from dataframe

2012-02-15 Thread Tsjerk Wassenaar
Hi Nymphita, ?upper.tri x - as.data.frame(matrix(1:6,6,6)) x[upper.tri(x,diag=TRUE)] - 0 x Cheers, Tsjerk On Wed, Feb 15, 2012 at 4:33 PM, nymphita nymph...@gmail.com wrote: Hello! I'm trying to build a lower triangular matrix (with zeros in the diagonal) from a particular dataframe.

Re: [R] model fitting

2012-02-15 Thread Tsjerk Wassenaar
Hi Tony, ?nls Cheers, Tsjerk On Feb 15, 2012 8:03 PM, Anthony Fristachi antak...@gmail.com wrote: Greetings, Any suggestions for approaching the fitting of the function y = b/exp(a*x) + c*x + y0 where a, b, c, and y0 are unknown constants and y and x are variables in a give dataset.

Re: [R] quadratic programming-maximization instead of minization

2012-01-03 Thread Tsjerk Wassenaar
Hi Riccardo, Would it be possible to use max(diag(D))*diag(ncol(D)) - D ? That also reverses the order of eigenvalues/-vectors. Cheers, Tsjerk On Jan 2, 2012 4:35 PM, riccardo24 riccardo.giacome...@gmail.com wrote: Hi, I need to maximize a quadratic function under constraints in R. For

Re: [R] quadratic programming-maximization instead of minization

2012-01-03 Thread Tsjerk Wassenaar
Sorry, that should've been sum(diag(D)) or max(eigen(D)$values) in stead of max(diag(D)). Tsjerk On Jan 3, 2012 4:52 PM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Riccardo, Would it be possible to use max(diag(D))*diag(ncol(D)) - D ? That also reverses the order of eigenvalues/-vectors

Re: [R] element-by-element comparison

2011-10-30 Thread Tsjerk Wassenaar
Hi Wendy, Most of the binary operators can deal with matrices and vectors natively: A-c(12,3,4) B-matrix(c(4,10,4,13,2,8),3,2) B [,1] [,2] [1,]4 13 [2,] 102 [3,]48 BA [,1] [,2] [1,] TRUE FALSE [2,] FALSE TRUE [3,] FALSE FALSE Cheers, Tsjerk On Sun, Oct 30,

Re: [R] element-by-element comparison

2011-10-30 Thread Tsjerk Wassenaar
Hi, To compare row wise is merely to compare column wise using the transpose matrix: t(B) A or t(t(B)A) if the result needs to be a matrix with dimensions equal to B. Cheers, Tsjerk On Sun, Oct 30, 2011 at 9:44 AM, Patrick Burns pbu...@pburns.seanet.com wrote: Given that you want to

Re: [R] How to cancel a R function in the command line?

2011-10-20 Thread Tsjerk Wassenaar
Hi Rui, In the R terminal ctrl-c cancels the function, not the session. Cheers, Tsjerk On Oct 20, 2011 7:16 PM, Rui Esteves ruimax...@gmail.com wrote: Hi, This question seems very basic but I cannot find an answer on google. I have a R session on a linux command line. I called a function

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Tsjerk Wassenaar
Hi Wei Wu, What about: x - matrix(rnorm(2*5),ncol=5) y - rnorm(5) distances - rowSums((x-y)**2) Cheers, Tsjerk On Wed, Aug 24, 2011 at 8:43 AM, Enrico Schumann enricoschum...@yahoo.de wrote: You could do something like this: # data nrows - 2L ncols - 5L myVec -

Re: [R] Efficient way to Calculate the squared distances for a set ofvectors to a fixed vector

2011-08-24 Thread Tsjerk Wassenaar
 [9,]   -4   -4   -4   -4   -4 [10,]   -5   -5   -5   -5   -5 -Ursprüngliche Nachricht- Von: Tsjerk Wassenaar [mailto:tsje...@gmail.com] Gesendet: Mittwoch, 24. August 2011 09:02 An: Enrico Schumann Cc: Wei Wu; r-help@r-project.org Betreff: Re: [R] Efficient way to Calculate

Re: [R] Sweave : allowing errors in R code?

2011-08-09 Thread Tsjerk Wassenaar
Hi Remko, You can modify the behaviour upon errors by setting the error option. Check ?option and ?stop Cheers, Tsjerk On Aug 9, 2011 8:35 AM, Duncan Mackay mac...@northnet.com.au wrote: Hi Remko After thinking about try and tryCatch the problem was catching the error what about

Re: [R] Sweave : allowing errors in R code?

2011-08-09 Thread Tsjerk Wassenaar
Hi Remko, The default behaviour of R upon encountering an error is to stop execution of whatever is happening. To circumvent that, you have to catch the error, using try, or you have to change the reaction of R to errors, using 'options'. The help page for ?stop gives an explicit example of the

Re: [R] cube root

2011-04-17 Thread Tsjerk Wassenaar
Hey :) In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A fractional power of a negative number is complex. And this can be obtained properly in R: (-8+0i)^(1/3) [1] 1+1.732051i Cheers, Tsjerk This is some interesting: -8^(1/3) [1] -2 x=(-8:8) y=x^(1/3) y  

[R] *Building* a covariance matrix efficiently

2011-03-14 Thread Tsjerk Wassenaar
deaRs, I want to build a covariance matrix out of the data from a binary file, that I can read in chunk by chunk, with each chunk containing a single observation vector X. I wonder how to do that most efficiently, avoiding the calculation of the full symmetric matrices XX'. The trivial

Re: [R] *Building* a covariance matrix efficiently

2011-03-14 Thread Tsjerk Wassenaar
this symmetry, so I’m not sure of the point of this exercise. PS: I actually know how to spell and pronounce Tsjerk, but Tsj is not a very familiar pattern for my fingers. *From:* Tsjerk Wassenaar [mailto:tsje...@gmail.com] *Sent:* Monday, March 14, 2011 1:41 PM *To:* Dwyer Rex USRE *Subject

Re: [R] The L Word

2011-02-23 Thread Tsjerk Wassenaar
Hi Gene, It means 'Literal integer'. So 1L is a proper integer 1, and 0L is a proper integer 0. Hope it helps, Tsjerk On Wed, Feb 23, 2011 at 5:08 PM, Gene Leynes gleyne...@gmail.com wrote: I've been wondering what L means in the R computing context, and was wondering if someone could point

Re: [R] A Math question

2011-02-14 Thread Tsjerk Wassenaar
Also, googling around one will find the question has been asked (and answered) already: http://ask.metafilter.com/25060/Whats-the-sum-of-all-integers Cheers, Tsjerk On Tue, Feb 15, 2011 at 1:33 AM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: or even better:

Re: [R] Plot colour according to column

2011-02-09 Thread Tsjerk Wassenaar
Hi Anoop, Not sure whether it's too late for you, but is this along the lines of what you want?: x-0:1000 y-sin(x/500)+rnorm(1001)/10 z-cos(x/500)+rnorm(1001)/100 plot(x,y,col=rgb(1,(z-min(z))/(max(z)-min(z)),0)) Or possibly like: plot(x,y,col=rainbow(256)[255*(z-min(z))/(max(z)-min(z))])

Re: [R] Iterate over a list of input files?

2011-02-08 Thread Tsjerk Wassenaar
Hi Mark, If you have a function that, for a given file name, returns the data in the way you want, then you can use 'dir' or 'paste' to generate a list of names, which you can read in in one go with apply: my_read - function(filename) { ... } filenames - dir(directory,pattern) filenames -

Re: [R] Fortran and long integers

2011-02-06 Thread Tsjerk Wassenaar
Hi, Does it alleviate things if you rewrite the sums to avoid large products? For I even: J+I*(N-I/2)-(N-I/2) For I odd: J+I*(N-(I+1)/2)-(N-(I+1)/2)+(I+1)/2 Hope it helps, Tsjerk On Mon, Feb 7, 2011 at 7:21 AM, Berend Hasselman b...@xs4all.nl wrote: Earl F Glynn wrote: 2-byte (16 bit)

Re: [R] Fortran and long integers

2011-02-06 Thread Tsjerk Wassenaar
Yes, thnx... Typo :$ On Mon, Feb 7, 2011 at 8:23 AM, Berend Hasselman b...@xs4all.nl wrote: Tsjerk Wassenaar wrote: Hi, Does it alleviate things if you rewrite the sums to avoid large products? For I even: J+I*(N-I/2)-(N-I/2) Shouldn't that be J+I*(N-I/2)-(N+I/2)  ? Berend

Re: [R] Need help with my homework

2011-01-27 Thread Tsjerk Wassenaar
Hey, To the best of my knowledge, this forum is not for help with homeworks. Probably it is, but it only works for those who can disguise their homework as Real Problems :) It might be good excercise to have a read of http://www.catb.org/~esr/faqs/smart-questions.html though. Cheers, Tsjerk

Re: [R] 3dimensional array in r

2010-06-02 Thread Tsjerk Wassenaar
Hi Suman, Try: array(1:24,c(4,3,2)) Cheers, Tsjerk On Thu, Jun 3, 2010 at 6:52 AM, suman dhara suman.dhar...@gmail.com wrote: Sir, I want to use a 3-dimensional array in R. How can I initialize the array? Can you give me a eaxmple? Thanks Regards, Suman Dhara        [[alternative

Re: [R] one way to write scripts in R

2010-03-29 Thread Tsjerk Wassenaar
Hi, That seems quite neat. To make it a bit more flexible, and maybe do some argument acrobatics with bash, you could change the first few lines to something like #!/bin/bash exec R --vanilla -q --slave -e source(file=pipe(\sed -n /^##RSTART/,\$p $0\)) --args $@ ##RSTART # Script here

Re: [R] R and Wordpress

2010-02-26 Thread Tsjerk Wassenaar
Hi, The visual editor should take HTML code, shouldn't it? - would then be written lt;- Haven't tried it though. Cheers, Tsjerk On Fri, Feb 26, 2010 at 10:19 AM, Tal Galili tal.gal...@gmail.com wrote: Hi CH, My solution for this is to work only on the code editor, and never to move to the

Re: [R] color vectors other than gray()

2009-03-27 Thread Tsjerk Wassenaar
Hi, Have a look at: ?rainbow ?rgb ?heatmap In my opinion this would've likely popped up with just a little effort of searching. In fact, the help of grey() (?grey) already gives pointers to the other color functions. Please show that you at least have tried to find answers before posting

Re: [R] find the index of the smallest or biggest number in a vetor or data.frame

2009-03-19 Thread Tsjerk Wassenaar
?which On Thu, Mar 19, 2009 at 2:15 PM, tedzzx zengzhenx...@gmail.com wrote: Dear R experts, How to find out the index of minimum or maxmum number in a vetor or data.frame? For example, a= n   price 1     50 -2    100 0    200 -1   300 .. I want to find out the row which

Re: [R] 2D plot with colors from 3rd variable?

2009-03-18 Thread Tsjerk Wassenaar
Hi Jo, To have some more flexibility with coloring I use the following, e.g. with rainbow colors: col- rainbow(255,end=5/6) colid - function( x, range=NULL, depth=255 ) { if ( is.null( range ) ) y - as.integer(x-min(x))/(max(x)-min(x))*depth+1 else { y -

Re: [R] R on netbooks et al?

2009-03-10 Thread Tsjerk Wassenaar
Hi, For what it's worth, it's a trivial operation to replace the on-board 1Gb with a 2Gb module, which doesn't cost too much. Okay, being a bit demanding I also replaced the hard-disk with a 320 Gb one to harbour a dual boot ubuntu-eee / windows XP. But that does give a machine which is a worthy

Re: [R] Weibull Verteilung

2008-09-30 Thread Tsjerk Wassenaar
Beste Luis, Ten eerste wil ik graag meedelen dat het aanbeveling verdient als iedereen zich bedient van een gezamenlijke taal (Gesamtsprache) wanneer het internationale communicatie betreft. Hoewel de taal van voorkeur uiteraard discutabel is, schijnt er toch redelijke consensus te zijn dat heden

Re: [R] matrix multiplication question

2008-07-18 Thread Tsjerk Wassenaar
Hi Murali, So, the solution to your problem will be to explicitly convert your matrix to a numeric matrix. Maybe matrix (?matrix) will do, or you'll also have to use as.numeric (?as.numeric). The strings on the left seem to me to be the row labels, right..?, not elements in the matrix/table. As