Re: [R] leveneTest between 2-levels of 3-level factor in R?

2015-10-20 Thread Dr. Leigh S. Sutherland
Thanks Rolf, Sorry, I was trying to be coherent, but obviously failed abysmally! I am new to this list, I will give a reproducible example next time, and more of the relevant script. I managed to do what I wanted to with subset: leveneTest(subset(results,ADHES == 'Poly'|ADHES == 'Cryst')[,5],

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Thanks William. I've tried the first code, ( with f0() ), but still for n=25, m=15 , I got this: > s<-f0(25,15) Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : invalid 'times' value In addition: Warning message: In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread PIKAL Petr
Hi What about using the second function f1 which William suggested? Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maram > SAlem > Sent: Tuesday, October 20, 2015 11:06 AM > To: William Dunlap; r-help@r-project.org > Subject: Re: [R] E

[R] seq POSIXct and fill in data by Tagmarie

2015-10-20 Thread Dagmar
Hello, This must be a bloody R-beginner question but I just can't find an answer in my beginner books: I have a dataframe like this: myframe <- data.frame (Timestamp=c("24.09.2012 09:00:00", "24.09.2012 10:00:00", "24.09.2012 11:00:00"), Event=c("0.1","0.5","1.2") ) myframe$Timestamp <- as.POS

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Thanks for the hint Petr. I'm just a little bit confused with the function f1(). could you please help me and insert comments within f1() to be able to relate it with f0()? Thanks a lot. Maram Salem On 20 October 2015 at 11:29, PIKAL Petr wrote: > Hi > > What about using the second function f

Re: [R] warning on generic function when building R package

2015-10-20 Thread carol white via R-help
Jim's solution works. Thank you Carol On Monday, October 19, 2015 11:53 PM, Jim Lemon wrote: I think what you may have done is simply changed x.init= to x=x.init. x.init may or may not be there when the function is called, and that is what the warning is saying. While you have sa

[R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Andy Yuan
Hello Please could you help me to select the most appropriate/fastest function to use for the following constraint optimisation issue? Objective function: Min: Sum( (X[i] - S[i] )^2) Subject to constraint : Sum (B[i] x X[i]) =0 where i=1��n and S[i] and B[i] are real numbers Need to

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread PIKAL Petr
Hi Why are you confused? > f0(5,3) [,1] [,2] [1,]00 [2,]10 [3,]20 [4,]01 [5,]11 [6,]02 > f1(5,3) [,1] [,2] [1,]00 [2,]10 [3,]20 [4,]01 [5,]11 [6,]02 > seems to give the same result. > res0<

Re: [R] seq POSIXct and fill in data by Tagmarie

2015-10-20 Thread PIKAL Petr
Hi Thanks for the data. There is function na.locf in zoo package. > library(zoo) Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric new$Event <- na.locf(new$Event) [1] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0

Re: [R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Duncan Murdoch
On 20/10/2015 6:58 AM, Andy Yuan wrote: > Hello > > Please could you help me to select the most appropriate/fastest function to > use for the following constraint optimisation issue? Just project S into the space orthogonal to B, i.e. compute the residuals when you regress S on B (with no inter

Re: [R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Berend Hasselman
> On 20 Oct 2015, at 15:35, Duncan Murdoch wrote: > > On 20/10/2015 6:58 AM, Andy Yuan wrote: >> Hello >> >> Please could you help me to select the most appropriate/fastest function to >> use for the following constraint optimisation issue? > > Just project S into the space orthogonal to B, i

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Thanks a lot Petr. I did exactly what you did and found that f1() works for n=25 and m=15. But I just wanted to figure out how f1() works, as I used its output for this larger code and It has been running for almost 5 hours now. s<-f1(25,15) simpfun<- function (x,n,m,p,alpha,beta) { a<-fac

[R] Creating S4 class with a slot as an array

2015-10-20 Thread Glenn Schultz
Hello All, I am trying to create an S4 class with a slot that is an array.  Below is the code I tried but I have missed something.  Any suggestions are appreciated. setClass("CashFlow", representation( CashFlowArray = "array")) setMethod("initialize", signature = "CashFlow", function(.Object,

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread William Dunlap
f0 is essentially your original code put into a function, so expect it to fail in the same way your original code did. f1 should give the same answer as f0, but it should use less memory and time. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Oct 20, 2015 at 2:05 AM, Maram SAlem wrote: >

[R] r-markdown - keeping figures

2015-10-20 Thread Witold E Wolski
I am running r-markdown from r-studio and can't work out how to keep the figures. I mean I have a few figures in the document and would like to have them as separate pdf's too as I have been used to have them when using Sweave. best regards Witold -- Witold Eryk Wolski __

[R] Scope of Axes

2015-10-20 Thread bgnumis bgnum
Hi all, I want to plot two graphs and I use this : par(mar=c(10,6,6,6)) matplot(Simulation,type="l") abline(h = 0, lwd = 2, col = "black") fhist<-hist(Simulation,plot=FALSE) par(mar=c(6,0,6,6)) barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray") The question is, that the legt

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Yes Indeed William. f1() works perfectly well and took only 30 secs to execute f1(25,15), but I wonder if there is anyway to speed up the execution of the rest of my code (almost seven hours now) ? Thanks for helping. Maram Salem On 20 October 2015 at 18:11, William Dunlap wrote: > f0 is essen

Re: [R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Paul Smith
On Tue, Oct 20, 2015 at 11:58 AM, Andy Yuan wrote: > > Please could you help me to select the most appropriate/fastest function to > use for the following constraint optimisation issue? > > Objective function: > > Min: Sum( (X[i] - S[i] )^2) > > Subject to constraint : > > Sum (B[i] x X[i]) =0 >

Re: [R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Gabor Grothendieck
Yes, it's the projection of S onto the subspace orthogonal to B which is: X <- S - B%*%B / sum(B*B) and is also implied by Duncan's solution since that is what the residuals of linear regression are. On Tue, Oct 20, 2015 at 1:00 PM, Paul Smith wrote: > On Tue, Oct 20, 2015 at 11:58 AM, Andy Yu

Re: [R] Most appropriate function for the following optimisation issue?

2015-10-20 Thread Gabor Grothendieck
Correction. Yes, it's the projection of S onto the subspace orthogonal to B which is: X <- S - (B%o%B) %*% S/ sum(B*B) and is also implied by Duncan's solution since that is what the residuals of linear regression are. On Tue, Oct 20, 2015 at 1:11 PM, Gabor Grothendieck wrote: > Yes, it's the

[R] Transfer a 3-dimensional array to a matrix in R

2015-10-20 Thread Chunyu Dong
Hello! Recently I am trying to transfer a large 3-dimensional array to a matrix. For example, a array like: , , 1 [,1] [,2] [1,]14 [2,]25 [3,]36 , , 2 [,1] [,2] [1,]7 10 [2,]8 11 [3,]9 12 , , 3 [,1] [,2] [1,] 13 16 [2,] 14 17 [3,]

Re: [R] Transfer a 3-dimensional array to a matrix in R

2015-10-20 Thread John Laing
> x <- array(1:18, dim=c(3, 2, 3)) > x , , 1 [,1] [,2] [1,]14 [2,]25 [3,]36 , , 2 [,1] [,2] [1,]7 10 [2,]8 11 [3,]9 12 , , 3 [,1] [,2] [1,] 13 16 [2,] 14 17 [3,] 15 18 > apply(x, 3, t) [,1] [,2] [,3] [1,]17 13

Re: [R] Creating S4 class with a slot as an array

2015-10-20 Thread Morgan, Martin
> -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Glenn > Schultz > Sent: Tuesday, October 20, 2015 10:36 AM > To: R Help R > Subject: [R] Creating S4 class with a slot as an array > > Hello All, > > I am trying to create an S4 class with a slot that

Re: [R] Transfer a 3-dimensional array to a matrix in R

2015-10-20 Thread William Dunlap
Or use aperm() (array index permuation): > array(aperm(x, c(2,1,3)), c(6,3)) [,1] [,2] [,3] [1,]17 13 [2,]4 10 16 [3,]28 14 [4,]5 11 17 [5,]39 15 [6,]6 12 18 Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Oct 20, 20

Re: [R] Transfer a 3-dimensional array to a matrix in R

2015-10-20 Thread Dénes Tóth
Hi, Bill was faster than me in suggesting aperm() instead of apply(), however, his solution is still suboptimal. Try to avoid array(), and set the dimensions directly if possible. fn1 <- function(x) { apply(x, 3, t) } fn2 <- function(x) { array(aperm(x, c(2, 1, 3)), c(prod(dim(

Re: [R] Scope of Axes

2015-10-20 Thread Jim Lemon
Hi bgnumis, I'm too lazy to try to work out what "Simulation" contains, but try this: Simulation<-sin(seq(0,6*pi,length.out=144))*5000+ 2000*runif(144)+seq(8000,5000,length.out=144) png("bb.png",width=800,height=400) par(mfrow=c(1,2)) plot(Simulation,type="l",ylim=c(0,2)) abline(h = 0, lwd =

Re: [R] by group

2015-10-20 Thread Val
Hi All, Thank you very much for your suggestion to use ddply function for my data set. I used the function like the following mydata <- read.table(header=TRUE, text=' cntry state city gender 1 1 1 1 1 1