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] 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],

[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 <-

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]

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

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

Re: [R-es] Error con tabla

2015-10-20 Thread Valentina Aguilera
Hola, En orden de lo anterior y en tratar de convertir los datos a númericos para poder sacar los estadísticos he hecho lo siguiente generando error: library(xtable) variables <- read.csv("C:/Users/usuario/Documents/Investigacion.csv", header=TRUE, sep=";", comment.char=""

Re: [R-es] Error con tabla

2015-10-20 Thread Rubén Gómez Antolí
El 20/10/15 a las 14:11, Valentina Aguilera escribió: > Hola, > En orden de lo anterior y en tratar de convertir los datos a númericos para > poder sacar > los estadísticos he hecho lo siguiente generando error: > library(xtable) ¿Esta utilizando LaTeX para necesitar este paquete? >

Re: [R-es] integración de gráficos R en aplicaciones de visual studio

2015-10-20 Thread Carlos Ortega
Hola, En la última reunión del grupo de R de Madrid (Raúl Vaquerizo) nos mostró como incluir mapas de municipios generados en R en Excel. No entró en muchos detalles de cómo era la macro en Excel, pero sí que te puede dar una idea de por dónde empezar. La documentación de la charla y el video

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

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,

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)),

[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

[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

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

[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

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) {

[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] 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

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

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

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

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

Re: [R-es] R en CAELinux

2015-10-20 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal? No conocía CAELinux, pero he visto que está basado (o sea, que "es") un Ubuntu 12.04. Edita el fichero /etc/apt/sources.list para incluir las URLs de CRAN como se indica en http://cran.es.r-project.org/bin/linux/ubuntu/ Un saludo, Carlos J. Gil Bellosta

[R-es] R en CAELinux

2015-10-20 Thread Albert
Hola a tod@s, He instalado R en ubuntu relativamente fácil. Solo me daba problemas el servidor de downloads, q tenía puesto el alemán, he puesto el general y ya funciona. Sin embargo no hay manera de instalar R en CAELinux. Sabéis si se puede? Alguna ayuda? Muchas gracias. Albert Montolio

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

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 =

[R-es] Crear variable con condiciones

2015-10-20 Thread Jorge I Velez
Buenas tardes a todos, Quisiera crear una variable de acuerdo a ciertas condiciones. Me gustaria llegar de "datain" a "dataout". ## entrada datain <- structure(list(REF = c("999", "999", "999", "1099", "731", "731", "731", "731", "1442", "1442", "1442", "1442"), TIMEREF = c(120, 240, 360, 30,

Re: [R-es] Crear variable con condiciones

2015-10-20 Thread Javier Rubén Marcuzzi
Estimado Jorge I Velez Yo hace unos años tuve un problema parecido y creo que había dos posibles soluciones y una era aportada por usted. No alcanzo a entender correctamente, al procesar el ejemplo hay números que no me coinciden con lo que comenta, le sugiero lo siguiente, cree nuevamente el

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. >

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

Re: [R-es] Error con tabla

2015-10-20 Thread Carlos Ortega
Hola Valentina, Como te están diciendo, el problema que tienes es de carga de datos de tu fichero al entorno de "R", antes de pasar a cosas más complicadas. Para no dar tantas vueltas, si nos envías un trozo del fichero (las primeras 10-15 líneas) es suficiente para decirte qué opciones tienes

[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

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

Re: [R-es] Error con tabla

2015-10-20 Thread Bartolomé Marcos , José Antonio
Creo que el problema lo tienes con el fichero, por el error : scan() expected 'a real', got '107188778,5' Prueba a incluir en read.csv la opción dec = "," (la separación decimal es una coma y no un punto) Así tu comando de lectura sería, variables <-