Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread MacQueen, Don
Here is a simplified example: dat <- data.frame(x=1:4, y1=runif(4), y2=runif(4), y3=4:1) for (icol in 2:4) plot(dat[,1] , dat[,icol] ) (not tested, so hopefully all my parentheses are balanced, no typos, etc.) This shows the basic principle. An alternative is to construct each column name as a

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread John Kane via R-help
As Jim says, "No data". R-help is very fussy about what files it will accept.  You might try changing the extention to txt.  However the preferred way here is to use the dput() command and paste the results into the post.  See ?dput for details. On Monday, May 21, 2018, 1:40:59 a.m. EDT

Re: [R] Loop Function to Create Multiple Scatterplots

2018-05-21 Thread Jim Lemon
Hi Steven, Sad to say that your CSV file didn't make it to the list and I can't access the data via your Dropbox account. Therefore we don't know the structure of "mydata". If you are able to plot the data as in your example, this might help: genexp<-matrix(runif(360,1,2),ncol=18) colnames(genexp)

Re: [R] loop function

2016-08-18 Thread Adams, Jean
You seemed to have re-written over the "b" object in your code. This might work for you. library(MASS) for (i in 58:1){ for(j in 58:i){ str.temp <- paste("y1 ~ x", i, "* x", j, sep = "") univar <- glm.nb(as.formula(str.temp), data=df) b <- summary(univar)$coeffients[4, 4] if(b <

Re: [R] loop function and integrate?

2012-11-30 Thread faeriewhisper
hello guys! thank u for the help, but u didnt understood what i need. 1st, it is a[i] cuz i want to sum 1 + x[i], for all i's not j. but i've solved it! :) like i said, my code is more complex, but, if you need to integrate several functions in a loop, thats what you should do: w2 = seq(-1,-1/3,l

Re: [R] loop function and integrate?

2012-11-30 Thread Berend Hasselman
On 30-11-2012, at 19:34, Berend Hasselman wrote: > > On 30-11-2012, at 16:08, faeriewhisper wrote: > >> Hi guys! >> I have to compute something and i don't know what i'm doing wrong. my code >> is a bit complex, but imagine that is something like this: >> >> a = c(1,2,3,4) >> ia = length(a)

Re: [R] loop function and integrate?

2012-11-30 Thread Berend Hasselman
On 30-11-2012, at 16:08, faeriewhisper wrote: > Hi guys! > I have to compute something and i don't know what i'm doing wrong. my code > is a bit complex, but imagine that is something like this: > > a = c(1,2,3,4) > ia = length(a) > > x = seq(1,100,length=0.1) > ib = length(x) > > int1 =

Re: [R] loop function and integrate?

2012-11-30 Thread Rui Barradas
Hello, Your code doesn't run without initializing 'ss' to something. And I've made some changes, but I don't understand what you are trying to do. See comments inline. a = c(1,2,3,4) ia = length(a) x = seq(1, 100, by=0.1) # It was 'length = 0.1' (!) ib = length(x) ss <- numeric(ia) # Ne

Re: [R] loop function and integrate?

2012-11-30 Thread faeriewhisper
Now i've managed to do this: funcs <- list() funcs[] # loop through to define functions for(i in 1:ib-1){ # Make function name funcName <- paste( 'func', i, sep = '' ) # make function func = paste('function(x){sin(x + a[', i,'])))}',sep = '') funcs[[funcName]] = eval(parse(

Re: [R] loop function within a loop

2011-10-12 Thread William Dunlap
Is this the result you are after, where the event number (within a group) are sorted according to the event/prev_event pairs (prev_event in a row matches event of the previous row)? > ave(d, d$group, FUN=function(z) z[ match(tsort(z$prev_event, z$event)[-1], > z$event), ]) event prev_event gr

Re: [R] loop function within a loop

2011-10-12 Thread David Winsemius
On Oct 12, 2011, at 10:55 AM, Sally Zhen wrote: Hi all, I'm working on a loop function for a large dataset which contains 1000 different groups. I would like to reconstruct the order of events within each group by using a loop function in R. Not generally a good first strategy in R. (Cu

Re: [R] loop function within a loop

2011-10-12 Thread Weidong Gu
It's better to avoid loop in this situation. If you want to reorder subsets of the data based on event, the follow works df<-read.table('clipboard',header=TRUE) sp.or<-lapply(split(df,df$group),function(ldf) ldf[order(ldf$event),]) new.df<-do.call('rbind',sp.or) Weidong Gu On Wed, Oct 12, 2011 a

Re: [R] Loop function/comparison operator problem

2009-10-05 Thread David Winsemius
On Oct 5, 2009, at 7:56 PM, Duncan Murdoch wrote: On 05/10/2009 7:47 PM, jimdare wrote: Hi There, I have created the following function format<- function(){ repeat { form<-readline(paste("\nIn what format do you want to save these plots?\nChoose from: wmf, emf, png, jpg, jpeg, bmp, tif, tiff,

Re: [R] Loop function/comparison operator problem

2009-10-05 Thread Duncan Murdoch
On 05/10/2009 7:47 PM, jimdare wrote: Hi There, I have created the following function format<- function(){ repeat { form<-readline(paste("\nIn what format do you want to save these plots?\nChoose from: wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps, eps, or pdf.\nNote: eps is the suggested format

Re: [R] Loop function/comparison operator problem

2009-10-05 Thread jim holtman
use %in% instead of '==' On Mon, Oct 5, 2009 at 7:47 PM, jimdare wrote: > > Hi There, > > I have created the following function > > format<- function(){ > repeat { > form<-readline(paste("\nIn what format do you want to save these > plots?\nChoose from: wmf, emf, png, jpg, jpeg, bmp, tif, tiff, p

Re: [R] loop function

2007-09-13 Thread Peter Dalgaard
Alfredo Alessandrini wrote: > Hi, > > If I have this values: > > 21 > 23 > 14 > 58 > 26 > > > How can I sum the values by a progression like this: > > (21) > (21 + 23) > (21 + 23 + 14) > (21 + 23 + 14 + 58) > (21 + 23 + 14 + 58 + 26) > (21 + 23 + 14 + 58 + 26) > > I've try with the functio

Re: [R] loop function

2007-09-13 Thread jim holtman
Is this what you want: > x [1] 21 23 14 58 26 > cumsum(x) [1] 21 44 58 116 142 On 9/13/07, Alfredo Alessandrini <[EMAIL PROTECTED]> wrote: > Hi, > > If I have this values: > > 21 > 23 > 14 > 58 > 26 > > > How can I sum the values by a progression like this: > > (21) > (21 + 23) > (21 + 2