Re: [R] loops in R

2014-11-05 Thread Berend Hasselman
On 05-11-2014, at 14:41, Noha Osman wrote: > Hi Folks > > Iam a new user of R and I have a question . Hopefully anyone help me in that > issue > > > I have that dataset as following > > Sample Population Species Tissue R GB > 1 Bari1_062-1 Bari1 ret

Re: [R] loops in R

2014-11-05 Thread Steve Lianoglou
While you should definitely read the tutorial that Don is referring to, I'd recommend you take a different approach and use more R idiomatic code here. In base R, this could be addressed with few approaches. Look for help on the following functions: * tapply * by * aggregate I'd rather rec

Re: [R] loops in R

2014-11-05 Thread Daniel Nordlund
On 11/5/2014 5:41 AM, Noha Osman wrote: Hi Folks Iam a new user of R and I have a question . Hopefully anyone help me in that issue I have that dataset as following Sample Population Species Tissue R GB 1 Bari1_062-1 Bari1 ret seed 94.52303 80.7

Re: [R] loops in R

2014-11-05 Thread Don McKenzie
Have you read the tutorial that comes with the R distribution? This is a very basic database calculation that you will encounter (or some slight variation of it) over and over. The solution is a few lines of code, and someone may write it out for you, but if no one does You have 20 population

[R] loops in R

2014-11-05 Thread Noha Osman
Hi Folks Iam a new user of R and I have a question . Hopefully anyone help me in that issue I have that dataset as following Sample Population Species Tissue R GB 1 Bari1_062-1 Bari1 ret seed 94.52303 80.70346 67.91760 2 Bari1_062-2 Bari1

Re: [R] loops with assign() and get()

2014-08-11 Thread William Dunlap
That code will not work. get() and assign() are troublesome for a variety of reasons. E.g., * adding made-up names to the current environment is dangerous. They may clobber fixed names in the environment. You may be confused about what the current environment is (especially when refactoring co

Re: [R] loops with assign() and get()

2014-08-11 Thread PO SU
It's a great method, but there is a memory problem, DFS would occupy a large memory. So from this point of view, i prefer the loop. >> for (i in 1 : nrow(unique)){ >> tmp=get(past0("DF",i))[1,] >> assign(paste0("df",i),tmp) >> dfi=dfi[,1:3] >> names(dfi)=names(tmp[c(1,4,5)]) >> dfi=rbind(dfi,tm

Re: [R] loops with assign() and get()

2014-08-09 Thread William Dunlap
> I was able to create 102 distinct dataframes (DFs1, DFs2, DFs3, etc) using > the assign() in a loop. The first step to making things easier to do is to put those data.frames into a list. I'll call it DFS and your data.frames will now be DFs[[1]], DFs[[2]], ..., DFs[[length(DFs)]]. DFs <- la

[R] loops with assign() and get()

2014-08-09 Thread Laura Villegas Ortiz
Dear all, I was able to create 102 distinct dataframes (DFs1, DFs2, DFs3, etc) using the assign() in a loop. Now, I would like to perform the following transformation for each one of these dataframes: df1=DFs1[1,] df1=df1[,1:3] names(df1)=names(DFs1[c(1,4,5)]) df1=rbind(df1,DFs1[c(1,4,5)]) names

Re: [R] Loops to produce plots and leyend

2014-06-20 Thread David Winsemius
On Jun 20, 2014, at 9:18 AM, Bea GD wrote: > I've tried several things but I don't manage to get this plot right. Any help > greatly appreciated! > I'm running a for loop to produce 4 plots at once. Each plot should only show > data points for a specific group (i.e. 4 plots for groups 1 to 4).

[R] Loops to produce plots and leyend

2014-06-20 Thread Bea GD
I've tried several things but I don't manage to get this plot right. Any help greatly appreciated! I'm running a for loop to produce 4 plots at once. Each plot should only show data points for a specific group (i.e. 4 plots for groups 1 to 4). The coordinates of the points should be petal length

Re: [R] Loops (run the same function per different columns)

2014-04-25 Thread CRoa
Hi Arun, Thanks a lot for your script. Ill work on it tomorrow. Cheers On 24/04/2014, at 11:54 AM, "arun kirshna [via R]" wrote: > HI, > I guess you got an output like this using my script: > ##Please use ?dput() to show the example data. > > FA <- structure(list(Sample = c("L1 Control",

Re: [R] Loops (run the same function per different columns)

2014-04-23 Thread CRoa
Hi Arun, Your script works but it does not do what I was after. To be a bit more specific, this the table FA in which Im working on ( but the original one has 34 fatty acids instead of 3: C14.0, C15.0, and C15.1). SampleC14:0C15:0C15:1 L1 Control0.4565091920.4695626870.774909216 L1 Control0.51398

Re: [R] Loops (run the same function per different columns)

2014-04-23 Thread arun
HI, I guess you got an output like this using my script: ##Please use ?dput() to show the example data. FA <- structure(list(Sample = c("L1 Control", "L1 Control", "L1 Control", "BBM Control", "BBM Control", "BBM Control", "L1 Ash", "L1 Ash", "L1 Ash", "BBM Ash", "BBM Ash", "BBM Ash"), C14.0 = c

Re: [R] Loops (run the same function per different columns)

2014-04-21 Thread CRoa
Thank you Arun for your quick answer. Ill try it and ill let you know. Cheers On 21/04/2014, at 11:30 PM, "arun kirshna [via R]" wrote: > Hi, > > Using the example data from library(gvlma) > > library(gvlma) > data(CarMileageData) > CarMileageNew <- CarMileageData[,c(5,6,3)] > lst1 <-

Re: [R] Loops (run the same function per different columns)

2014-04-21 Thread arun
Hi, Using the example data from library(gvlma) library(gvlma) data(CarMileageData) CarMileageNew <- CarMileageData[,c(5,6,3)]  lst1 <- list()  y <- c("NumGallons", "NumDaysBetw")  for(i in seq_along(y)){  lst1[[i]] <- gvlma(lm(get(y[i])~MilesLastFill,data=CarMileageNew))  lst1} pdf("gvlmaplot.pdf

Re: [R] Loops

2013-06-26 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of bett kimutai > Sent: Wednesday, June 26, 2013 3:17 AM > To: Law, Jason; r-help@r-project.org > Subject: Re: [R] Loops > > Thanks for you response.

Re: [R] Loops

2013-06-25 Thread bett kimutai
rectify my loop to run for all the pipes and then create a table to hold these values. Sorry for the syntax errors, I guess I will get them with time.  thanks again.. From: "Law, Jason" ect.org> Sent: Tuesday, June 25, 2013 3:32 PM Subject: RE: [R

Re: [R] Loops

2013-06-25 Thread Law, Jason
HTH, Jason Law -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of bett kimutai Sent: Tuesday, June 25, 2013 1:32 PM To: r-help@r-project.org Subject: [R] Loops Dear All, I  have spent most of my time trying to figure out how to simulat

[R] Loops

2013-06-25 Thread bett kimutai
Dear All, I  have spent most of my time trying to figure out how to simulate the number of breaks in a pipe using Monte Carlo simulation. i have 20,000 individual pipes that i have to run, and for each pipe i have to run 1000 times while checking some conditions and therefore, i have to use a

Re: [R] Loops

2013-06-25 Thread bett kimutai
Dear All, I  have spent most of my time trying to figure out how to simulate the number of breaks in a pipe using monte carlo simulation. i have 20,000 individual pipes that i have to run, and for each pipe i have to run 1000 times while checking some conditions and therefore, i have to use a

Re: [R] loops for matrices

2013-06-12 Thread Rainer Schuermann
The comments on StackOverflow are fair, I believe... Please dput() your matrices, so that your code becomes reproducible! On Wednesday 12 June 2013 11:14:35 maggy yan wrote: > I have to use a loop (while or for) to return the result of hadamard > product. now it returns a matrix, but when I use i

[R] loops for matrices

2013-06-12 Thread maggy yan
I have to use a loop (while or for) to return the result of hadamard product. now it returns a matrix, but when I use is.matrix() to check, it returns FALSE, whats wrong? Matrix.mul <- function(A, B) { while(is.matrix(A) == FALSE | is.matrix(B) == FALSE ) {print("error") bre

Re: [R] Loops

2013-01-28 Thread Francesca
gt; 25)+1),as.matrix),c(2,3),function(x) x)) > res<-rbind(t(pnew),colSums(p)) > row.names(res)<-1:nrow(res) > res<- 100-100*abs(res/rowSums(res)-(1/3)) > A.K. > > > - Original Message - > From: Rui Barradas > To: Francesca > Cc: r-help@r-project.org

Re: [R] Loops

2013-01-27 Thread arun
)-(1/3)) A.K. - Original Message - From: Rui Barradas To: Francesca Cc: r-help@r-project.org Sent: Sunday, January 27, 2013 6:17 AM Subject: Re: [R] Loops Hello, I think there is an error in the expression 100-(100*abs(fa1[i]/sum(fa1[i])-(1/3))) Note that fa1[i]/sum(fa1[i]) is always 1. If it&

Re: [R] Loops

2013-01-27 Thread Uwe Ligges
On 27.01.2013 12:50, Richard D. Morey wrote: Dear Contributors, I am asking help on the way how to solve a problem related to loops for that I always get confused with. I would like to perform the following procedure in a compact way. Consider that p is a matrix composed of 100 rows and three

Re: [R] Loops

2013-01-27 Thread Richard D. Morey
> Dear Contributors, > I am asking help on the way how to solve a problem related to loops for > that I always get confused with. > I would like to perform the following procedure in a compact way. > > Consider that p is a matrix composed of 100 rows and three columns. I need > to calculate the su

Re: [R] Loops

2013-01-27 Thread Rui Barradas
Hello, I think there is an error in the expression 100-(100*abs(fa1[i]/sum(fa1[i])-(1/3))) Note that fa1[i]/sum(fa1[i]) is always 1. If it's fa1[i]/sum(fa1), try the following, using lists to hold the results. # Make up some data set.seed(6628) p <- matrix(runif(300), nrow = 100) idx <- se

[R] Loops

2013-01-27 Thread Francesca
Dear Contributors, I am asking help on the way how to solve a problem related to loops for that I always get confused with. I would like to perform the following procedure in a compact way. Consider that p is a matrix composed of 100 rows and three columns. I need to calculate the sum over some ro

[R] loops

2012-03-23 Thread Brockagh
Hi I'm running QDA on some data and calculating the discriminant function. qda.res <- qda(type ~ npreg + glu + bp + skin + bmi + ped + age) ind_yes <- c(1:N)[type == "Yes"] > ind_no <- c(1:N)[type == "No"] > cov_yes <- cov(table[ind_yes, 1:7] ) > cov_no <- cov(table[ind_no, 1:7] ) > covar<-l

Re: [R] loops

2012-01-24 Thread R. Michael Weylandt
You can use the assign() function. E.g., assign("a", 3,) But the more R thing to do is to create a list of your results (which you can name) and to handle that whole object. Then if you want to do things to each object you create, it's as simple as lapply Michael On Tue, Jan 24, 2012 at 7:27 PM,

[R] loops

2012-01-24 Thread Philip Shirk
I've been struggling to get a loop to work. I want to create a new variable in each loop with data from some function. for example: # part of the names for the variables to be created Frags <- c("F04", "F05", "F07", "F09", "F11", "F13", "F14", "F17", "F18", "F19", "P20", "Main") for(obs in Frags

Re: [R] loops over regression models

2012-01-13 Thread Petr PIKAL
Hi > > Dear R help listers, > > I am trying to replicate results in Gelman and Hill's book (Chapter 3 > in regressions and multilevel models). Below I estimated two models > (chp3.1 and chp3.3 in R codes) with the same data and dependent > variable but different independent variables. I have been

[R] loops over regression models

2012-01-13 Thread Xu Jun
Dear R help listers, I am trying to replicate results in Gelman and Hill's book (Chapter 3 in regressions and multilevel models). Below I estimated two models (chp3.1 and chp3.3 in R codes) with the same data and dependent variable but different independent variables. I have been using Stata for q

Re: [R] Loops and vector operations

2011-12-30 Thread Mago84
Thanks a lot, it was very helpful, I did something like that: EV <- ifelse(sprd > mediaSDP & sprd_d <= mediaSDP_d, -1, 0) SV <- ifelse(sprd > media & sprd_d <= media_d, -17, 0) EC <- ifelse(sprd < mediaSDN & sprd_d >= mediaSDN_d,1,0) SC <- ifelse(sprd < media & sprd_d >= media_d,17,0) in order t

Re: [R] Loops and vector operations

2011-12-28 Thread R. Michael Weylandt
Look at ?ifelse. You'll need to nest them however. If you are feeling a little more ambitious this can be done with ?switch, but for clarity, I'd rather see pre-allocation followed by assignments Something along this pattern: out <- numeric(50) x <- sample(3, 50, TRUE) out[x==3] <- "A" out[x==2

[R] Loops and vector operations

2011-12-28 Thread Mago84
Dear all, this is my first post and I´m very new at R, I don´t know if somebody can help with an issue. I´m doing some exercices and I don´t know if for example I can convert this for in an operation with vectors: for (i in 2:n){ if (ES[i-1]==0 && sprd[i-1]>mediaSDP[i-1] && sprd[i]<=medi

Re: [R] Loops

2011-09-15 Thread Fred
Thank you so much! foreL<-8 b0f<-matrix(nrow=9, ncol=foreL) ct<-1 ### use this as the index of b0f for(ar.ord in 1:3){ for(ma.ord in 1:3){ b0f[ct,]<-c(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)), n.ahead=foreL)$pred) ct<-ct+1 ### increment the counter } } this one works! Best rega

Re: [R] Loops

2011-09-14 Thread R. Michael Weylandt
Look at the combinations function in gtools and index by the rows of that output for a single loop. Pass values as the three parameters. Sorry for being terse - writing on my phone. Michael On Sep 14, 2011, at 5:36 PM, Fred wrote: > Dear forum, > > I would like to forecast e.g. with the ar

Re: [R] Loops

2011-09-14 Thread Weidong Gu
A little bit change of your code may do the work foreL<-8 b0f<-matrix(nrow=9, ncol=foreL) ct<-1 ### use this as the index of b0f for(ar.ord in 1:3){ for(ma.ord in 1:3){ b0f[ct,]<-c(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)), n.ahead=foreL)$pred) ct<-ct+1 ### increment the counter

[R] Loops

2011-09-14 Thread Fred
Dear forum, I would like to forecast e.g. with the arima-model. To figure out which model works best I am going to predict with this models. my first code: for(ar.ord in 1:3){ for(ma.ord in 1:3){ print(predict(arima(para_qtr[1:(n-8),1],order=c(ar.ord,1,ma.ord)), n.ahead=8)$pred) } } this one wo

Re: [R] Loops on data˜1

2011-09-14 Thread R. Michael Weylandt
The first thing I'd mention is that *apply are really just well implemented loops themselves so you can't expect true magic from them. However, if you really want to use them rather than just a regular loop (which seems more intuitive for a request like this), this might do what you are looking for

Re: [R] Loops on data˜1

2011-09-13 Thread Trying To learn again
Hi Michael, First of all thanks for your response. I do know that if I make my stimation on a single data the regression has no sense but it will be getting sense in the growing next estimations. I change my asking doubt. I want to use this regressions as a first filter. Only this. Can anyone

Re: [R] Loops on data˜1

2011-09-12 Thread R. Michael Weylandt
I may be totally off base with this, but I'm wondering what exactly this would suggest or why you want to do it. Specifically "multiple regression with only intercept" -- how is it multiple if you don't have any regressors? Furthermore, you want to run a "regression" on a single data point -- reall

[R] Loops on data˜1

2011-09-12 Thread Trying To learn again
Hi all, I have a time series a column vector with the ordered data so that the first column is the first observation and so on. The fact is that I want to run a multiple regression with only intercept. My first task is to run the regression on the first observation (1 from 276) and at the same t

Re: [R] Loops for repetitive task

2011-08-10 Thread Dennis Murphy
Hi: Try this: ## Function that takes a data frame as input and outputs a data frame: chrSumm <- function(d) { # d is a data frame colnames(d) <- c("chr","start","end","base1","base2", "totalreads","methylation","strand") TR <- nrow(d) RG1 <- sum(d['totalreads']

Re: [R] Loops for repetitive task

2011-08-09 Thread Peter Alspach
, header=F) ... } HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of a217 > Sent: Wednesday, 10 August 2011 4:32 p.m. > To: r-help@r-project.org > Subject: [R] Loops for repetitive

[R] Loops for repetitive task

2011-08-09 Thread a217
Hello, I have an R script that I use as a template to perform a task for multiple files (in this case, multiple chromosomes). What I would like to do is to utilize a simple loop to parse through each chromosome number so that I don't have to type the same code over and over again in the R console

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread Bert Gunter
2/10/2010      A  1 > 2 12/10/2010      B  2 > 3 12/10/2010      B  2 > 4 13/10/2010      A  3 > 5 13/10/2010      B  4 > 6 13/10/2010      C  5 > > -- > David L Carlson > Associate Professor of Anthropology > Texas A&M University

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread David L Carlson
iginal Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Chandra Salgado Kent Sent: Tuesday, August 02, 2011 2:12 AM To: r-help@r-project.org Subject: [R] Loops to assign a unique ID to a column Dear R help, I am fairly new in data manageme

Re: [R] Loops to assign a unique ID to a column

2011-08-02 Thread ONKELINX, Thierry
..@r-project.org] > Namens Chandra Salgado Kent > Verzonden: dinsdag 2 augustus 2011 9:12 > Aan: r-help@r-project.org > Onderwerp: [R] Loops to assign a unique ID to a column > > Dear R help, > > > > I am fairly new in data management and programming in R, and am tr

[R] Loops to assign a unique ID to a column

2011-08-02 Thread Chandra Salgado Kent
Dear R help, I am fairly new in data management and programming in R, and am trying to write what is probably a simple loop, but am not having any luck. I have a dataframe with something like the following (but much bigger): Dates<-c("12/10/2010","12/10/2010","12/10/2010","13/10/2010", "1

Re: [R] loops and simulation

2011-07-22 Thread Dylan Beaudette
On Wed, Jul 20, 2011 at 10:43 PM, David Winsemius wrote: > > On Jul 21, 2011, at 1:04 AM, Daniel Malter wrote: > >> http://mlg.eng.cam.ac.uk/dave/rmbenchmark.php >> >> I haven't ever tried it myself, but online sources suggest that Matlab >> possibly gains speed by internally avoiding loops rather

Re: [R] loops and simulation

2011-07-20 Thread David Winsemius
rent. -- David. Daniel From: David Winsemius [dwinsem...@comcast.net] Sent: Wednesday, July 20, 2011 9:01 AM To: Daniel Malter Cc: r-help@r-project.org Subject: Re: [R] loops and simulation On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote: snipped requests,

Re: [R] loops and simulation

2011-07-20 Thread Daniel Malter
aniel From: David Winsemius [dwinsem...@comcast.net] Sent: Wednesday, July 20, 2011 9:01 AM To: Daniel Malter Cc: r-help@r-project.org Subject: Re: [R] loops and simulation On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote: snipped > requests, except that

Re: [R] loops and simulation

2011-07-20 Thread David Winsemius
On Jul 20, 2011, at 1:34 AM, Daniel Malter wrote: snipped requests, except that you were referring to SAS and had heard that R "does not like loops." (This is factually wrong. But R can be slow looping). Where did you hear this? Can you cites any references? -- David Winsemius, MD West Ha

Re: [R] loops and simulation

2011-07-19 Thread Daniel Malter
Yes, there are in Europe. And there are summer classes in the US, as well. And no, this list is not so much about helping beginners to learn R. For that, there is a myriad of online sources. Rather, this list is for people who have exhausted their ability to (elegantly) solve a problem. Also, it s

Re: [R] loops and simulation

2011-07-19 Thread Daniel Malter
I dare the conjecture that if you had written the code, you would know how to do this. This suggests that you are asking us to do your homework, which is not the purpose of this list. A simple inclusion of the code in a for or while loop and storing the estimated parameters with the index of the it

[R] Loops, Paste, Apply? What is the best way to set up a list of many equations?

2011-06-23 Thread Rita Carreira
Is there a way to apply paste to list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = EQ4) such that I don't have to write form1=EQ1 for all my models (I might have a list of 20 or more)? I also need the EQs to read the formulas associated with them. For example, below, I was able to automate

Re: [R] loops and if statements

2010-04-18 Thread Erich Neuwirth
I would prefer version 1. Version to creates a global variable R which you do not really need since it contains the same values as d$r. In option 2, you should probably remove the variable r itself after it has been appended to d. On 4/18/2010 5:23 PM, Laura Ferrero-Miliani wrote: > Thanks for co

Re: [R] loops and if statements

2010-04-18 Thread Laura Ferrero-Miliani
Thank you so much all! How a simple problem can get complicated by not having enough knowledge, but hopefully I am learning Have a great Sunday! L On Sun, Apr 18, 2010 at 4:56 PM, jim holtman wrote: > You are working with a matrix, so the "$" operator is not allowed (e.g., > d$c). > > Also in

Re: [R] loops and if statements

2010-04-18 Thread Joshua Wiley
Hey Laura, Just to add a cautionary note, in > a <- c(1:4) > b <- c("meep", "foo", "meep", "foo") > d <- cbind(a, b) d is a matrix and will only be one type of matrix.  Since you have both integer (a) and character (b) data, it has to be at the character level.  From the help for cbind: "The t

Re: [R] loops and if statements

2010-04-18 Thread jim holtman
You are working with a matrix, so the "$" operator is not allowed (e.g., d$c). Also in your test, you have to test against the second column (e.g., d[i, 2]) try this: > a <- c(1:4) > b <- c("meep", "foo", "meep", "foo") > d <- cbind(a, b) > > > for(i in seq(along=d[,2])) {if (d[i,2]=="meep") { p

[R] loops and if statements

2010-04-18 Thread Laura Ferrero-Miliani
Hello, I am very new to R and data analysis in general. I am trying to generate values to append to my data frame using conditional statements. I am playing with this simple example: a <- c(1:4) b <- c("meep", "foo", "meep", "foo") d <- cbind(a, b) now what I want to do is , each time there is a

[R] Antwort: FW: R loops

2008-10-10 Thread assa . yeroslaviz
it did help to create the separate vectors. The problem is, I would like to continue working with each vector on its own and make some further analysis. For that i need to allocate each vector in the filePatterns a unique name, which I just can't do. I'm not so great in R loops an

Re: [R] R loops

2008-10-09 Thread Wacek Kusnierczyk
[EMAIL PROTECTED] wrote: > hello everybody, > > I have a directory with over 3000 files with different names. I would like > to make some vectors with the file names which are belong together. > > I'm trying to do it with a for loop in R: > > SF <- c("ad", "cd", "cer", "stress", "salty", "PC", "hi

[R] R loops

2008-10-09 Thread assa . yeroslaviz
hello everybody, I have a directory with over 3000 files with different names. I would like to make some vectors with the file names which are belong together. I'm trying to do it with a for loop in R: SF <- c("ad", "cd", "cer", "stress", "salty", "PC", "high", "transfer", "cold", "heat") # th

[R] loops

2008-02-05 Thread mohamed nur anisah
hi!! Below I have 4 columns vector of c and d which are unequal in length.These c and d have 2 columns each where these 2 columns represent an interval values. I easily get these overlapping interval values by using these code: s<-apply(c,1,rev) aa<-apply(d,1,function(x)apply(s<=x,2,a

[R] LOOPS - GIS

2008-01-28 Thread Johan Lassen
Dear R-user community, I need to solve a problem related to river management. The task is to calculate the distance from specified points in a river to the outlet of the river. The river is defined by a database (here called "M"): LinkID |NodeID1 | NodeID2 |Distout |Length

Re: [R] R loops

2008-01-28 Thread Duncan Murdoch
On 1/28/2008 8:48 AM, cvandy wrote: > I'm a new user and am having trouble with loops. > In the following, I'm trying to add the results of "test" and the loops are > not working. > I've simplified the loop. What am I doing wrong? > Thanks! >> test<-numeric(20) >> tot<-numeric(20) >> for(i in 1:20

[R] R loops

2008-01-28 Thread cvandy
i]<-1} > for (i in 1:20){tot[i]<-(test[i]+tot[i])} > tot [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -- View this message in context: http://www.nabble.com/R-loops-tp15135671p15135671.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] loops & sampling

2007-11-01 Thread Julian Burgos
Hi Garth, Your code is really confusing! You should start by reading the help file on the for() function and understanding what it does: ?"for" Your line for(i in 1:nboot){ } is simply starting a loop around the variable 'i', which will change values following the sequence 1:nboot. It seems

[R] loops & sampling

2007-10-31 Thread Garth.Warren
Hi, I'm new to R (and statistics) and my boss has thrown me in the deep-end with the following task: We want to evaluate the impact that sampling size has on our ability to create a robust model, or evaluate how robust the model is to sample size for the purpose of cross-validation i.e.