Re: [R] 1st script

2015-03-23 Thread William Dunlap
> # Import CSV file into a data frame. > case_weights <- read.csv(file = "case_weights.csv") > > # For each row, take the number in the Weight column and replicate it > # as many times as there are in each count column. > LC09 <- rep(case_weights$Weight, case_weights$LC09) > LC10 <- rep(case_weight

Re: [R] 1st script

2015-03-23 Thread PIKAL Petr
Hi > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > memilanuk > Sent: Monday, March 23, 2015 8:41 AM > To: r-h...@stat.math.ethz.ch > Subject: Re: [R] 1st script > > On 03/22/2015 10:58 PM, PIKAL Petr wrote: > > >

Re: [R] 1st script

2015-03-23 Thread memilanuk
On 03/22/2015 10:58 PM, PIKAL Petr wrote: use list and numeric indexing. As you did not provide reproducibe example here is possible way. dat <- data.frame(w=abs(rnorm(10)), LC09=round(runif(10)*10), LC10=round(runif(10)*10)) lll <- vector("list", 2) k=0 for(i in 2:3) { k=k+1 lll[[k]] <- rep(

Re: [R] 1st script

2015-03-22 Thread PIKAL Petr
Hi use list and numeric indexing. As you did not provide reproducibe example here is possible way. dat <- data.frame(w=abs(rnorm(10)), LC09=round(runif(10)*10), LC10=round(runif(10)*10)) lll <- vector("list", 2) k=0 for(i in 2:3) { k=k+1 lll[[k]] <- rep(dat$w, dat[,i]) } names(lll)<-names(dat[,