Re: [R] Nested for loop

2017-08-08 Thread S Ellison
> The code I've attached works for a population of 400 and samples 100 times. > I'd like to extend this to 300 samples and 3 populations. So, the x-axis would > range from 0-300 samples. > > What I'm having trouble with is finding a way to change the population mid- > way through the function. I w

Re: [R] Nested for loop

2017-08-07 Thread Kirsten Morehouse
Hi Caitlin and Ben, Thanks for your responses! My issue is that I'd like to create one continuous line, rather than 3 lines overlayed. The code I've attached works for a population of 400 and samples 100 times. I'd like to extend this to 300 samples and 3 populations. So, the x-axis would range f

Re: [R] Nested for loop

2017-08-07 Thread Ben Tupper
Hmmm. If I understand you correctly, your question has to do with adding lines to your graph? If so, my ggplot2 skills are sort of floppy, but you could append your sampling results to your data frame (one for each sample set) and then simply add layers. Sort of like this. N <- 10 x <- 1:N d

Re: [R] Nested for loop

2017-08-06 Thread Kirsten Morehouse
Hi Ben, That's exactly right! Except for each set it's the sample population that is 400, 800 or 300. I want to take 3 samples, each of 100, where only the population differs. I can do this separately, but I'm having trouble putting them all on the same graph. I'd like to have sample on the x axi

Re: [R] Nested for loop

2017-08-06 Thread Ben Tupper
Hi Kirsten, I can run your example code but I can't quite follow your division of sampling. Can you restate the the task? Below is what I think you are asking for, but I have the feeling I may be off the mark. Set A: 400 samples, draw 100 in range of 5 to 15 Set B: 800 samples, draw 100 in

[R] Nested for loop

2017-08-05 Thread Kirsten Morehouse
Hi! Thanks for taking the time to read this. The code below creates a graph that takes 100 samples that are between 5% and 15% of the population (400). What I'd like to do, however, is add two other sections to the graph. It would look something like this: from 1-100 samples take 100 samples tha

Re: [R] nested for loop with data table

2017-05-06 Thread Ek Esawi
Thank you Jeff. Your idea, as i mentioned on my previous posting, did indeed work. I read somewhere that both data table dplyr do great many things and i plan to learn both as much as i can. Suggestions on this list either get you the answer you are looking for or give you lead to an answer. Thank

Re: [R] nested for loop with data table

2017-05-03 Thread PIKAL Petr
) A B C D E F 3 1 1 0 1 1 It is probably preferable to obtain logical vectors for Num and Day before starting tabulation. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ek Esawi > Sent: Wednesday, May 3, 2017 5:17 PM > To: r-help

Re: [R] nested for loop with data table

2017-05-03 Thread Jeff Newmiller
You seem to be unaware of the "aggregate" data processing concept. There are many ways to accomplish aggregation, but I am not fluent in data.table methods but knowing the concept is the first step. Perhaps look closely at [1], or Google for data table aggregation yourself? [1] https://www.r-

Re: [R] nested for loop with data table

2017-05-03 Thread Ek Esawi
Thank you both Boris and Jim. Thank you, Boris, for advising to read the posting guide; I had and I just did. Jim’s idea is exactly what I want; however, I could not pass sset1, sset2, etc. to the j nested loop and collect the results in an vector. Here attached my code, file, and my question whi

Re: [R] nested for loop with data table

2017-05-02 Thread Jim Lemon
Hi Ek, I think you want your example to look like this: Sample<-read.table(text= "Num Color Grade Value Month Day 1 yellow A 20 May 1 2 green B 25 June 2 3 green A 10 April 3 4 black A 17 August 3 5 red C 5 December 5 6 orange D 0 January 13 7 orange E 12 January 5 8 orange F 11 February 8 9 orang

Re: [R] nested for loop with data table

2017-05-02 Thread Boris Steipe
There's a lot that doesn't make sense here. I think what you need to do is produce a small, reproducible example, post that with dput() and state your question more clearly - including what you have tried and what didn't work. You'll probably be amazed how quickly you will get good advice if _y

[R] nested for loop with data table

2017-05-02 Thread Ek Esawi
I have a huge data file; a sample is listed below. I am using the package data table to process the file and I am stuck on one issue and need some feedback. I used fread to create a data table. Then I divided the data table (named File1) into 10 general subsets using common table commands such as:

Re: [R] Nested for loop help please.

2014-01-12 Thread arun
pick.a[count],pick.d[count1]))         tc1=sum(t.control(m.control,pick.a[count]))         output=c(output,ts1/tc1)     } } m1=matrix(output,200,100) print(m1) From: arun Sent: Saturday, January 11, 2014 6:00 PM To: Mathew Nagendran Subject: Re: [R] Nested for loo

Re: [R] Nested for loop help please.

2014-01-11 Thread arun
Hi, I guess you need to replace t() with t.control() or t.sham() output <-vector() for(count in 1:length(pick.a)){  for(count1 in 1:length(pick.d)){  ts1 = sum(t.sham(m.sham,pick.a[count],pick.d[count1])) tc1 <- sum(t.control(m.control,pick.a[count])) output= c(output,ts1/tc1)  }  } m1 <- matri

Re: [R] Nested for loop help please.

2014-01-11 Thread William Dunlap
r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Mathew Nagendran > Sent: Saturday, January 11, 2014 10:46 AM > To: r-help@r-project.org > Subject: [R] Nested for loop help please. > > Hi all I am relatively new to R. I am trying to crea

Re: [R] Nested for loop help please.

2014-01-11 Thread Rui Barradas
Hello, You are using the function ?t(), matrix transpose, with more than one argument. What is that supposed to do? The error message says that the other two arguments are not used (because they are illegal). And you don't need to transpose a vector to sum its components. Hope this helps, R

[R] Nested for loop help please.

2014-01-11 Thread Mathew Nagendran
Hi all I am relatively new to R. I am trying to create a nested for loop but i keep getting an error message (unused argument). Can someone help me find out where I am goign wrong? > m.control=c(1.45,9.40,9.96,4.2,1.86,0.2) > m.sham=c(3.39,23.94,23.62,10.08,2.99,1.09) > > t.control=function(m, a

Re: [R] Nested For Loop

2012-06-29 Thread R. Michael Weylandt
> - Original Message - > From: arun.gurubaramurugeshan > To: r-help@r-project.org > Cc: > Sent: Thursday, June 28, 2012 5:03 PM > Subject: [R] Nested For Loop > > I am creating a nested for loop and following are the codes I'm using, but I > am not

Re: [R] Nested For Loop

2012-06-29 Thread arun
s one line is the shortest A.K. - Original Message - From: arun.gurubaramurugeshan To: r-help@r-project.org Cc: Sent: Thursday, June 28, 2012 5:03 PM Subject: [R] Nested For Loop I am creating a nested for loop and following are the codes I'm using, but I am not acheiving wh

Re: [R] Nested For Loop

2012-06-29 Thread David Winsemius
On Jun 28, 2012, at 5:03 PM, arun.gurubaramurugeshan wrote: I am creating a nested for loop and following are the codes I'm using, but I am not acheiving what I want. I have a vector d<-151:159 I have another vector e<-e<-c("apple", "orange", "banana") I need to create f as 151apple 1

Re: [R] Nested For Loop

2012-06-29 Thread Bert Gunter
reversed them, Should be: levels(interaction(d,e,sep="") > > of course. -- Bert On Fri, Jun 29, 2012 at 2:46 AM, Bert Gunter wrote: > ... or even simpler: > > levels(interaction(e,d,sep="")) > > ... and PLEASE read "An Introduction to R" before further posting to learn > how to program in R r

Re: [R] Nested For Loop

2012-06-29 Thread Bert Gunter
... or even simpler: levels(interaction(e,d,sep="")) ... and PLEASE read "An Introduction to R" before further posting to learn how to program in R rather than trying to fit what you do in other languages to R. Cheers, Bert On Fri, Jun 29, 2012 at 12:48 AM, Rui Barradas wrote: > Hello, > > Tr

Re: [R] Nested For Loop

2012-06-29 Thread Rui Barradas
Hello, Try, in one line and no loops, surely not nested, apply(rev(expand.grid(e, d, stringsAsFactors = FALSE)), 1, paste, collapse="") Hope this helps, Rui Barradas Em 28-06-2012 22:03, arun.gurubaramurugeshan escreveu: I am creating a nested for loop and following are the codes I'm using

[R] Nested For Loop

2012-06-28 Thread arun.gurubaramurugeshan
I am creating a nested for loop and following are the codes I'm using, but I am not acheiving what I want. I have a vector d<-151:159 I have another vector e<-e<-c("apple", "orange", "banana") I need to create f as 151apple 151orange 151banana . . 159apple 159orange 159banana Here is how I w