Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Rasmus Liland
On 2020-04-03 07:39 +1100, Jim Lemon wrote: | | Hi Rasmus, | Very nice. The R help list is a bit like a | quiz show where the contestants must | balance the alacrity with which they press | their buttons with the confidence that they | have the correct answer. A slow motion game | of wits in

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Rasmus Liland
On 2020-04-01 15:33 +1100, Jim Lemon wrote: > Hi Nevil, > It's a nasty piece of work, but: Hi! How about this one: data <- c(rep(1:4, times=3), 2, 1, 3, 2) dimnames <- list(NULL, c("x", "y", "z", "k")) ncol <- length(data)/4 M <- matrix(data=data, nrow=ncol, ncol=ncol, dimnames=d

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Jim Lemon
Hi Rasmus, Very nice. The R help list is a bit like a quiz show where the contestants must balance the alacrity with which they press their buttons with the confidence that they have the correct answer. A slow motion game of wits in which the prizes are self-awarded. Jim On Fri, Apr 3, 2020 at 7:

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-03-31 Thread Jim Lemon
Hi Nevil, It's a nasty piece of work, but: M<-matrix(c(1,2,3,4,1,2,3,4,1,2,3,4,2,1,3,2),4,4, dimnames = list(NULL, c("x", "y", "z","k"))) M reprow<-function(x) return(matrix(rep(x,x[length(x)]),nrow=x[length(x)],byrow=TRUE)) toseq<-function(x) return(1:x) j<-unlist(sapply(M[,"k"],toseq)) Mlist<-a

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-03-31 Thread nevil amos
OK sorted - hope these postings might help someone else Any even faster options would be appreciated still #seq() does not work but sequence() does print("rep and sequence") print(system.time({ j<-NULL MOut<-NULL MOut<-M[rep(1:nrow(M), times = M[,4]), ] j<-sequence(M[,4]) MOut<-cbind(M

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-03-31 Thread nevil amos
Well, I found a way to do it partly using rep(), and one loop that makes it 10x or more faster however would still be good to do without the loop at all matrix made slightly beigger (1 rows): M<-matrix(c(1:3 ), 1,3) M<-cbind(M,sample(1:5,size = 1,replace = T)) #Print(M) #Create mat

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-03-31 Thread Jeff Newmiller
False premise: rep works fine Mout2 <- cbind(M[ rep(seq.int(nrow(M)),M[,"k"]), c("x","y","z")],unlist(lapply(M[,"k"],seq.int))) On March 31, 2020 6:18:37 PM PDT, nevil amos wrote: >Hi > >I can achieve this using two for loops but it is slow I need to do >this on >many matrices with tens of mil

[R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-03-31 Thread nevil amos
Hi I can achieve this using two for loops but it is slow I need to do this on many matrices with tens of millions of rows of x,y,z and k What is a faster method to achieve this, I cannot use rep as j changes in each row of the new matrix ### M<-matrix(

Re: [R] repeat a function

2017-11-03 Thread Eric.Pueyo
Thanks Petr. Really appreciated! Many thanks, Eric -Original Message- From: PIKAL Petr [mailto:petr.pi...@precheza.cz] Sent: 03 November 2017 07:54 To: Eric Pueyo; r-help@r-project.org Subject: RE: [R] repeat a function Hi Well, I am not an expert in this field so I cannot comment

Re: [R] repeat a function

2017-11-03 Thread PIKAL Petr
om: eric.pu...@avivainvestors.com [mailto:eric.pu...@avivainvestors.com] > Sent: Thursday, November 2, 2017 5:54 PM > To: PIKAL Petr ; r-help@r-project.org > Subject: RE: [R] repeat a function > > Hi Petr, > > Many thanks for your response. > > Basically I want to create a pr

Re: [R] repeat a function

2017-11-02 Thread Eric.Pueyo
j,sep = ""),"1"] <<- ProbUP(a,j,dt) prb[paste(j,sep = ""),"0"] <<- ProbMID(a,j,dt) prb[paste(j,sep = ""),"-1"] <<- ProbDWN(a,j,dt) prb[paste(-j,sep = ""),"1"] <<- ProbUP(a,-j,d

Re: [R] repeat a function

2017-11-02 Thread Bert Gunter
easily transform it to > matrix by setting dim argument to it. > > Cheers > Petr > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > > eric.pu...@avivainvestors.com > > Sent: Wednesday, November 1, 2017 1:31

Re: [R] repeat a function

2017-11-02 Thread PIKAL Petr
s Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > eric.pu...@avivainvestors.com > Sent: Wednesday, November 1, 2017 1:31 PM > To: r-help@r-project.org > Subject: [R] repeat a function > > I want to populate the matrix prb t

[R] repeat a function

2017-11-01 Thread Eric.Pueyo
I want to populate the matrix prb through the function HWMProb <- function (a,j,dt) that encapsulates different functions (please see code below), using j= 0:2 for each j. It only populates prb if I specify each function independently in the global environment and then run the loop with the iF

Re: [R] Repeat

2017-02-25 Thread David Winsemius
> On Feb 25, 2017, at 4:36 PM, Ashta wrote: > > Thank you so much David! > > But if all element of a group has '-' did not work. In this case year > 2006 an example > If all values of flag are '-' within year then I wan to set as N I don't see the difficulty (and your example did not provi

Re: [R] Repeat

2017-02-25 Thread Ashta
Thank you so much David! But if all element of a group has '-' did not work. In this case year 2006 an example If all values of flag are '-' within year then I wan to set as N dat=read.table(text = "Year month flag 2001 1 Z 2001 2 - 2001 4 X 2002 1 Z 2002 2 - 2003 1 - 2003 2 Z

Re: [R] Repeat

2017-02-25 Thread David Winsemius
> On Feb 25, 2017, at 10:45 AM, Ashta wrote: > > Thank you David. > is it not possible to sort it by year and flag so that we can make '-' > in the second row ? like this for that particular year. > > 2003 2 Z > 2003 1 - > I was a bit surprised by the results of htis since I had

Re: [R] Repeat

2017-02-25 Thread Ashta
Thank you David. is it not possible to sort it by year and flag so that we can make '-' in the second row ? like this for that particular year. 2003 2 Z 2003 1 - On Sat, Feb 25, 2017 at 12:14 PM, David Winsemius wrote: > >> On Feb 25, 2017, at 8:09 AM, Ashta wrote: >> >> I ha

Re: [R] Repeat

2017-02-25 Thread David Winsemius
> On Feb 25, 2017, at 8:09 AM, Ashta wrote: > > I have a data set and I want to repeat a column value based on other > column value, > > my data look like > > read.table(text = "Year month flag > 2001 1 Z > 2001 2 - > 2001 4 X > 2002 1 Z > 2002 2 - > 2003 1 - > 2003 2 Z > 2004 2

[R] Repeat

2017-02-25 Thread Ashta
I have a data set and I want to repeat a column value based on other column value, my data look like read.table(text = "Year month flag 2001 1 Z 2001 2 - 2001 4 X 2002 1 Z 2002 2 - 2003 1 - 2003 2 Z 2004 2 Z 2005 3 Z 2005 2 - 2005 3 -", header = TRUE) Within year If flag

Re: [R] Repeat matrices

2016-08-01 Thread Ivan Calandra
Not sure it would be any smarter, but what about: a <- c(5.78, 5.79,5.86) n <- 10 matrix(rep(a,each=n), nrow=n) That way, it would be easy to build a function with 'a' and 'n' as arguments. HTH, Ivan -- Ivan Calandra, PhD Scientific Mediator University of Reims Champagne-Ardenne GEGENAA - EA

[R] Repeat matrices

2016-08-01 Thread roslinazairimah zakaria
Dear r-users, I have a set of numbers that I would like to repeat for let say 10 times and each number is repeated by vertically. I tried this: a <- c(5.78, 5.79,5.86) tran_a <- t(matrix(rep.int(a, 10),3)) dput(tran_a) structure(c(5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.7

Re: [R] Repeat elements of character vector

2015-02-01 Thread PIKAL Petr
2015 2:34 PM > To: r-help@r-project.org > Subject: [R] Repeat elements of character vector > > I have a vector of several character elements: > v1 <- c("a", "b", "c") > > I want each of these elements to be repeated n times and the number of &g

Re: [R] Repeat elements of character vector

2015-01-30 Thread Ivan Calandra
Hi, Take a look at the argument "each" from rep(). You could do that (there might be something shorter): paste(rep(v1,each=3), 1:3, sep="_") HTH, Ivan -- Ivan Calandra, ATER University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26

Re: [R] Repeat elements of character vector

2015-01-30 Thread Chel Hee Lee
> paste(rep(v1, each=3), 1:3, sep="_") [1] "a_1" "a_2" "a_3" "b_1" "b_2" "b_3" "c_1" "c_2" "c_3" > Is this what you are looking for? I hope this helps. Chel Hee Lee On 1/30/2015 7:34 AM, Knut Hansen wrote: I have a vector of several character elements: v1 <- c("a", "b", "c") I want each of t

[R] Repeat elements of character vector

2015-01-30 Thread Knut Hansen
I have a vector of several character elements: v1 <- c("a", "b", "c") I want each of these elements to be repeated n times and the number of the repetition added as part of the element text, hence rep() will not work. For n=3 the result would be: v2 <- c("a_1", "a_2", "a_3", "b_1", "b_2", "b_3",

Re: [R] repeat a linear regression model

2013-10-14 Thread arun
Hi, Try: Please use ?dput() to show the example dataset: dat <- structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Y = c(555L, 345L, 456L, 552L, 342L, 452L, 555L, 345L, 456L, 552L, 342L, 452L, 562L, 352L, 463L, 582L, 342L, 483

Re: [R] repeat a linear regression model

2013-10-14 Thread Doran, Harold
, October 14, 2013 7:47 AM To: r-help@r-project.org Subject: [R] repeat a linear regression model Hello, I'd like to repeat a linear regression model for groups of rows that are identified by an ID number. My table is like this: ID Y X1 X2 X3 X4 1 555 111

[R] repeat a linear regression model

2013-10-14 Thread Valeria Muzzolini
Hello, I'd like to repeat a linear regression model for groups of rows that are identified by an ID number. My table is like this: ID Y X1 X2 X3 X4 1 555 111 222 333 456 1 345 234 445 543 33 1 456 353 453 456

[R] repeat resampling with different subsample sizes

2013-01-18 Thread wfinsinger
Hi, I'm trying to write a code (see below) to randomly resample measurements of one variable (say here the variable "counts" in the data frame "dat") with different resampled subsample sizes. The code works fine for a single resampled subsample size (in the code below = 10). I then tried to genera

Re: [R] Repeat elements of matrix based on vector counts

2012-12-13 Thread arun
- Original Message - From: Sarah Haas To: r-help@r-project.org Cc: Sent: Thursday, December 13, 2012 9:15 AM Subject: [R] Repeat elements of matrix based on vector counts I have two dataframes (df) that share a column header ("plot.id").  In the 1st df, "plot.id" recor

Re: [R] Repeat elements of matrix based on vector counts

2012-12-13 Thread Rui Barradas
Hello, Something like this? rep(df2$load, table(df1$plot.id)) Hope this helps, Rui Barradas Em 13-12-2012 14:15, Sarah Haas escreveu: I have two dataframes (df) that share a column header ("plot.id"). In the 1st df, "plot.id" records are repeated a variable number of times based on the numb

Re: [R] Repeat elements of matrix based on vector counts

2012-12-13 Thread Sarah Goslee
Hi Sarah, If I understand your requirements correctly, the easiest thing to do is approach it from a different direction: df3a <- merge(df1, df2) But you can also use rep for this simple example because plot.id in df2 is sorted: nindex <- table(df1$plot.id) df3b <- df2[rep(1:length(nindex), times

[R] Repeat elements of matrix based on vector counts

2012-12-13 Thread Sarah Haas
I have two dataframes (df) that share a column header ("plot.id"). In the 1st df, "plot.id" records are repeated a variable number of times based on the number of trees monitored within each plot. The 2nd df only has a single record for each "plot.id", and contains a variable named "load" that is

Re: [R] repeat takes along time

2012-10-24 Thread JPM
Hi Petr Thanks for reply. On 24 October 2012 07:26, PIKAL Petr [via R] < ml-node+s789695n464726...@n4.nabble.com> wrote: > Hi > > It is a piece of my code. At this, i create a matrix(deltab) with each column is a binomial, but in there are several NAs, and i must restart the cycle the number o

Re: [R] repeat takes along time

2012-10-23 Thread PIKAL Petr
Hi > > Hi > > I want help for "repeat" because it takes a long time > > repeat{ > for (i in 1:n){ > probb[i]=sum(Wc[z[,j]>=yb[i]]) > } > deltab[,b]=rbinom(n,1,probb) > if(length(which(is.na(deltab[,b])==T))==0){break} > } > > This code works but takes much computation time. What is this code

[R] repeat takes along time

2012-10-23 Thread JPM
Hi I want help for "repeat" because it takes a long time repeat{ for (i in 1:n){ probb[i]=sum(Wc[z[,j]>=yb[i]]) } deltab[,b]=rbinom(n,1,probb) if(length(which(is.na(deltab[,b])==T))==0){break} } This code works but takes much computation time. Anyone could help me to find a solution to take a

Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Jessica Streicher
a <- matrix(1:8, 2, 4, byrow=TRUE) b<-t(a) r<-rep(b,5) # can insert anything for 5 matrix(r,ncol=dim(a)[2],byrow=T) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 [5,]1234 [6,]5678

Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Petr PIKAL
Hi what about rbind(a,a) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 Regards Petr > > > a <- matrix(1:8, 2, 4, byrow=TRUE) > > a > [,1] [,2] [,3] [,4] > [1,]1234 > [2,]5678 >

Re: [R] repeat matrix rows as a whole

2012-04-25 Thread Jeff Newmiller
Yes, integer vector indexing. You haven't provided R code to work with so I will just refer you to read the pdf "An Introduction to R" included with most R installations for more details. --- Jeff Newmiller

Re: [R] repeat matrix rows as a whole

2012-04-25 Thread Richard M. Heiberger
> a <- matrix(1:8, 2, 4, byrow=TRUE) > a [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 > a[c(1,2,1,2),] [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 > On Wed, Apr 25, 2012 at 8:32 PM, Rebec

[R] repeat matrix rows as a whole

2012-04-25 Thread Rebecca
Hi, If I have a matrix like 1  2  3  4 5  6  7  8, how can I repeat two rows as whole, to be like 1  2  3  4 5  6  7  8 1  2  3  4 5  6  7  8?   Since I have more two rows in a matrix and I need to repeat many times, I wonder whether there is a convenient command to do so.   Thanks! [[alte

Re: [R] repeat function for entire list of matrices

2012-01-30 Thread R. Michael Weylandt
No problem. Glad it worked for you. Michael On Mon, Jan 30, 2012 at 12:05 PM, pabears wrote: > michael, > > i don't know what happened, i was reading up on ?lapply(), i was up really > late, and somehow it didn't seem to take, but i tried it again this morning > and it worked like a charm...

Re: [R] repeat function for entire list of matrices

2012-01-30 Thread pabears
michael, i don't know what happened, i was reading up on ?lapply(), i was up really late, and somehow it didn't seem to take, but i tried it again this morning and it worked like a charm.(sorry about the ellipses, i was just being lazy/unclear). that's great, thanks, this is a great h

Re: [R] repeat function for entire list of matrices

2012-01-30 Thread R. Michael Weylandt
lapply() takes a function in its second argument, but that is not what you passed it. Also, there's no such construct in R as "." What happens with the code I gave you? Michael On Sun, Jan 29, 2012 at 4:28 PM, pabears wrote: > didn't seem to quite work: > > i tried different subsetting.

Re: [R] repeat function for entire list of matrices

2012-01-30 Thread pabears
didn't seem to quite work: i tried different subsetting. lapply(nestedseasonlower, nested(nestedseason,.) are there any functions that can repeat a function while "counting" each iteration of the repeated function? (n=1, n=2, n=3) thanks -- View this message in context: http://r.7

Re: [R] repeat function for entire list of matrices

2012-01-27 Thread R. Michael Weylandt
?lapply Perhaps (untested): lapply(listofmatrices, nested, method="binmatnest2") Michael On Fri, Jan 27, 2012 at 3:19 PM, pabears wrote: > hi all. > > perhaps someone can help me with subsetting here > > i'm trying to use the nested() function in the bipartite package.  my > proble

[R] repeat function for entire list of matrices

2012-01-27 Thread pabears
hi all. perhaps someone can help me with subsetting here i'm trying to use the nested() function in the bipartite package. my problem is that i have a list of 10,000 matrices and i want the output to be a vector of the nested() function on each of the 10,000 matrices (so i can use th

Re: [R] Repeat a loop until...

2011-10-19 Thread Dénes TÓTH
If you want to generate truncated distributions, package 'tmvtnorm' can help you out. Regards, Denes >> >> Dear all, >> >> I know there have been various questions posted over the years about > loops >> but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2. >> I am generati

Re: [R] Repeat a loop until...

2011-10-19 Thread Petr PIKAL
Hi I may be completely off track without knowing mnormt package but what about using while loop for counting rows in "correct" datamat. #first set your matrix datamat <- rmnorm(n=1500,mean=c(mean(sanad[,1]),mean(sanad[,2]),mean(sanad[,3])),varcov=covmat) #get rid of out of spec values datamat

[R] Repeat a loop until...

2011-10-18 Thread Bonnett, Laura
Dear all, I know there have been various questions posted over the years about loops but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2. I am generating some data using the multivariate normal distribution (within the 'mnormt' package). [The numerical values of sanad and cov

Re: [R] repeat a sequence - but not for a full number of times

2011-07-20 Thread Sarah Goslee
Or you could take advantage of R's automatic recycling: > x$b <- rep(1:3, length=nrow(x)) > x a b 1 1 1 2 2 2 3 3 3 4 4 1 5 5 2 6 6 3 7 7 1 8 8 2 9 9 3 10 10 1 Thanks for providing a simple reproducible example. Sarah On Wed, Jul 20, 2011 at 6:20 PM, Dimitri Liakhovitski

Re: [R] repeat a sequence - but not for a full number of times

2011-07-20 Thread Dimitri Liakhovitski
Never mind - found it: x<-data.frame(a=1:10) x$b<-rep(1:3,nrow(x)%/%3,len=nrow(x)) Dimitri On Wed, Jul 20, 2011 at 6:15 PM, Dimitri Liakhovitski wrote: > Apologies, for a very simple question. I forgot how to do it - > although I remember reading about getting a warning in such a > situation. >

[R] repeat a sequence - but not for a full number of times

2011-07-20 Thread Dimitri Liakhovitski
Apologies, for a very simple question. I forgot how to do it - although I remember reading about getting a warning in such a situation. I have a data frame. It happens to be 10 rows but it could be 11 or 3 or 13... x<-data.frame(a=1:10) I need to add variable "b" that is a sequence of 1:3 - repeat

Re: [R] repeat matrix column within each array third dimension

2011-03-09 Thread Uwe Ligges
See ?aperm for changing the dimensions afterwards. Uwe Ligges On 08.03.2011 10:14, Folkes, Michael wrote: Hello all, I'm working with a matrix that will have varying dimensions. It will populate an array such that the number of matrix columns will determine the number of 3rd dimension level

[R] repeat matrix column within each array third dimension

2011-03-08 Thread Folkes, Michael
Hello all, I'm working with a matrix that will have varying dimensions. It will populate an array such that the number of matrix columns will determine the number of 3rd dimension levels of the array. Rows will be the same for both. For this example lets say the array will have 2 columns, but

Re: [R] repeat write.table with the same code many times

2010-11-30 Thread Joshua Wiley
Hi Laura, I'm a little weak on my use of connections, but I wonder if something like this would not be a better option. As I understand it, using write.table() with append = TRUE is a slow way to many lines to a file. ## create a writable connection to a file gt <- file("bootstrap_results.txt",

Re: [R] repeat write.table with the same code many times

2010-11-30 Thread James W. MacDonald
Hi Laura, On 11/30/2010 9:57 AM, Laura Bonnett wrote: Dear all, I am using R version 2.9.2 in Windows. I would like to output the results of a function I have written to a .txt file. I know that I can do this by using the code write.table(boothd(10),"boothd10.txt",sep="\t",append=TRUE) etc.

Re: [R] repeat write.table with the same code many times

2010-11-30 Thread jim holtman
Try using a connection: output <- file('boothd10.txt", 'w') write.table(boothd(10), output, sep = '\t', col.names = FALSE) close(output) On Tue, Nov 30, 2010 at 9:57 AM, Laura Bonnett wrote: > Dear all, > > I am using R version 2.9.2 in Windows. > > I would like to output the results of a

[R] repeat write.table with the same code many times

2010-11-30 Thread Laura Bonnett
Dear all, I am using R version 2.9.2 in Windows. I would like to output the results of a function I have written to a .txt file. I know that I can do this by using the code write.table(boothd(10),"boothd10.txt",sep="\t",append=TRUE) etc. However, I would like to bootstrap my function 'boothd' s

Re: [R] repeat a function

2010-09-29 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Michael Bedward > Sent: Wednesday, September 29, 2010 5:34 PM > To: Michael Larkin; Rhelp > Subject: Re: [R] repeat a function > > On 30 September 20

Re: [R] repeat a function

2010-09-29 Thread Michael Bedward
On 30 September 2010 02:48, Michael Larkin wrote: > > > > testdat <- replicate( 50, growth[ sample(nrow(growth), 8, rep=TRUE) ] ) > > I can't seem to get it to work.  I keep getting the error message of > "undefined columns selected" > > Any advice? I'd need to know the dimensions of your matrix

Re: [R] repeat a function

2010-09-28 Thread Michael Bedward
Hi Michael testdat <- replicate( 50, growth[ sample(nrow(growth), 8, rep=TRUE) ] ) testdat will then be a matrix of 8 x 50 = 400 rows where each lot of 8 is a sample. Alternatively you can do... testdat <- replicate( 50, growth[ sample(nrow(growth), 8, rep=TRUE) ], simplify=FALSE ) Now testdat

[R] repeat a function

2010-09-28 Thread Michael Larkin
I have R randomly sampling my array made up of 2 columns of data. Here is my code randomly sampling 5 different rows from my dataset to create a new dataset of 8 rows of data: testdat<-growth[sample(5,8,replace=T),] Now I want to tell R to repeat this function 50 times and give me the

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread Gabor Grothendieck
On Wed, Aug 25, 2010 at 11:18 AM, skan wrote: > > # duplicated / na.locf   doesn't work > it says Error in fix.by(by.x, x) : 'by' must specify valid column(s) > > if I use ifelse instead of ifelse.zoo it works but it gives me a non zoo > vector. > Myabe is because my zoo version is older. > They

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread skan
# duplicated / na.locf doesn't work it says Error in fix.by(by.x, x) : 'by' must specify valid column(s) if I use ifelse instead of ifelse.zoo it works but it gives me a non zoo vector. Myabe is because my zoo version is older. cheers -- View this message in context: http://r.789695.n4.nabbl

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread Gabor Grothendieck
On Wed, Aug 25, 2010 at 9:48 AM, skan wrote: > > thanks > I'll try them, > > Why do you use the brackets in zz[]  ? So it stays a zoo object with the same index. We are only replacing the data part. __ R-help@r-project.org mailing list https://stat.et

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread skan
thanks I'll try them, Why do you use the brackets in zz[] ? -- View this message in context: http://r.789695.n4.nabble.com/Repeat-the-first-day-data-through-all-the-day-Zoo-tp2338069p2338266.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread Gabor Grothendieck
On Wed, Aug 25, 2010 at 7:43 AM, skan wrote: > >  down vote  favorite > > > Hello > > I have a zoo series. It lasts 10 years and its frequency is 15min. > > I'd like to get a new zoo series (or vector) with the same number of > elements, whith each element equal to the first element of the day. Th

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread Gabor Grothendieck
On Wed, Aug 25, 2010 at 7:56 AM, Gabor Grothendieck wrote: > On Wed, Aug 25, 2010 at 7:43 AM, skan wrote: >> I have a zoo series. It lasts 10 years and its frequency is 15min. >> >> I'd like to get a new zoo series (or vector) with the same number of >> elements, whith each element equal to the f

Re: [R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread Gabor Grothendieck
On Wed, Aug 25, 2010 at 7:43 AM, skan wrote: > I have a zoo series. It lasts 10 years and its frequency is 15min. > > I'd like to get a new zoo series (or vector) with the same number of > elements, whith each element equal to the first element of the day. That's, > The first element everyday is r

[R] Repeat the first day data through all the day. Zoo

2010-08-25 Thread skan
down vote favorite Hello I have a zoo series. It lasts 10 years and its frequency is 15min. I'd like to get a new zoo series (or vector) with the same number of elements, whith each element equal to the first element of the day. That's, The first element everyday is repeated througho

[R] repeat(?) measurement ANOVA or (general? mixed?) linear model?

2009-10-07 Thread Wolfgang Waser
Hi all, after browsing the archives for hours I'm still not sure about the proper analysis for my dataset. I subjected each of about 50 critters (about 10 each in 5 distinct populations) to 4 consecutive treatments (exposure to increasing concentrations), with one measurement per treatment and

[R] repeat series of commands for each variable

2009-04-15 Thread Peter Kraglund Jacobsen
For each variable x, y and z I would like to run the same set of commands. I have tried for (n in FICB[,"calct30"], FICB[, "calct60]") { FICB[,"temp"] <- format([n],digits=2) etc } How do I do this correctly? __ R-help@r-project.org mailing list https:

Re: [R] How to let R repeat computations over a number of variables

2008-03-14 Thread David Winsemius
Uli Kleinwechter <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hello, > > I have written a small script to read a dataset, compute some basic > descriptives and write them to a file (see below). The variable > "maizeseedcash" of which the statistics are calculated is contained > in th

[R] How to let R repeat computations over a number of variables

2008-03-14 Thread Uli Kleinwechter
Hello, I have written a small script to read a dataset, compute some basic descriptives and write them to a file (see below). The variable "maizeseedcash" of which the statistics are calculated is contained in the data frame agr_inputs. My question is whether there is a way to make R compute t