Re: [R] R for-loop to add layer to lattice plot

2020-10-28 Thread Luigi Marongiu
Awesome, thanks! On Wed, Oct 28, 2020 at 7:00 AM Deepayan Sarkar wrote: > > On Tue, Oct 27, 2020 at 6:04 PM Luigi Marongiu > wrote: > > > > Hello, > > I am using e1071 to run support vector machine. I would like to plot > > the data with lattice and specifically show the hyperplanes created by

Re: [R] R for-loop to add layer to lattice plot

2020-10-27 Thread Deepayan Sarkar
On Tue, Oct 27, 2020 at 6:04 PM Luigi Marongiu wrote: > > Hello, > I am using e1071 to run support vector machine. I would like to plot > the data with lattice and specifically show the hyperplanes created by > the system. > I can store the hyperplane as a contour in an object, and I can plot > on

Re: [R] R for-loop to add layer to lattice plot

2020-10-27 Thread Mark Leeds
Hi: I think you're writing over the plots so only the last one exists. Maybe try P = P + whatever but I'm not sure if that's allowed with plots. On Tue, Oct 27, 2020 at 8:34 AM Luigi Marongiu wrote: > Hello, > I am using e1071 to run support vector machine. I would like to plot > the data with

[R] R for-loop to add layer to lattice plot

2020-10-27 Thread Luigi Marongiu
Hello, I am using e1071 to run support vector machine. I would like to plot the data with lattice and specifically show the hyperplanes created by the system. I can store the hyperplane as a contour in an object, and I can plot one object at a time. Since there will be thousands of elements to plot

Re: [R] R for loop

2013-11-15 Thread Jeff Newmiller
L Carlson >Department of Anthropology >Texas A&M University >College Station, TX 77840-4352 > >-Original Message- >From: r-help-boun...@r-project.org >[mailto:r-help-boun...@r-project.org] On Behalf Of matira >Sent: Friday, November 15, 2013 7:23 AM >To: r-help@

Re: [R] R for loop

2013-11-15 Thread David Carlson
lege Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of matira Sent: Friday, November 15, 2013 7:23 AM To: r-help@r-project.org Subject: [R] R for loop Hi I'm quite new to R and I am having trouble with this cod

[R] R for loop

2013-11-15 Thread matira
Hi I'm quite new to R and I am having trouble with this code: names(Mindreader_2012_vars) varlist<-names(Mindreader_2012_vars) for (i in 688:696) { for (j in 673:685) { assign(paste("Uk_Cluster_",i-687,sep=""),cbind(get(varlist[j],pos=Mindreader_2012_vars)[get(varlist[i], pos=Mindreader_2012_v

Re: [R] R for loop nested?

2011-10-25 Thread Kenn Konstabel
Hi there, I'm adding a very small bit of something utterly useless to Michael's response. When you start wondering why your code doesn't work the way you expect, making it as simple as possible might be the first step. For example, the following piece of code ... TRUE ... is simpler than ... !!

Re: [R] R for loop nested?

2011-10-25 Thread R. Michael Weylandt
In what way doesn't this work? You declare xx with one element and it prints. Then on the next loop, you add another element, and it prints them both. Then on the next loop, you add another element, and it prints all three. And so on... If you look at the output, you can see that it's a growin

[R] R for loop nested?

2011-10-25 Thread Delia Shelton
Hi, I'm trying to execute the same R code on multiple data frames listed in a single directory. The code works fine if I use the code (below) for each file. However, I have several files and it becomes tedious to run each one, name it and then aggregate into a single dataframe. Name 0.0  

Re: [R] R for loop stops after 4 iterations

2011-10-23 Thread Philip Robinson
elp@r-project.org Subject: Re: [R] R for loop stops after 4 iterations There's a seeming inconsistency in this question -- namely, you provide an example of a data frame with 4 columns but say it is 27x3 -- but I think your question comes from a misunderstanding of what length(e) calculates.

Re: [R] R for loop stops after 4 iterations

2011-10-22 Thread Dennis Murphy
Hi: Here are a couple of ways, using the data snippet you provided as the input data frame e. Start by defining the function, which outputs a percentage: f <- function(n, mean, sd) { s <- rnorm(n, mean = mean, s = sd) round(100 * sum(s > 0.42)/length(s), 4) } (1) Use the plyr packag

Re: [R] R for loop stops after 4 iterations

2011-10-22 Thread Duncan Murdoch
On 11-10-22 7:33 PM, Philip Robinson wrote: I have a data frame called e, dim is 27,3, the first 5 lines look like this: V1 V2 V3V4 1 1673 0.36 0.08 Smith 2 167 0.36 0.08 Allen 399 0.37 0.06 Allen 4 116 0.38 0.07 Allen 595 0.41 0.08 Allen

Re: [R] R for loop stops after 4 iterations

2011-10-22 Thread R. Michael Weylandt
Oops!! Meant pnorm(, lower.tail = FALSE) -- don't do qnorm or bad things will happen. Sorry, Michael On Sat, Oct 22, 2011 at 8:28 PM, R. Michael Weylandt wrote: > There's a seeming inconsistency in this question -- namely,  you > provide an example of a data frame with 4 columns but say it is

Re: [R] R for loop stops after 4 iterations

2011-10-22 Thread R. Michael Weylandt
There's a seeming inconsistency in this question -- namely, you provide an example of a data frame with 4 columns but say it is 27x3 -- but I think your question comes from a misunderstanding of what length(e) calculates. For a data frame it gives the number of columns back. Hence if you have a 27

[R] R for loop stops after 4 iterations

2011-10-22 Thread Philip Robinson
I have a data frame called e, dim is 27,3, the first 5 lines look like this: V1 V2 V3V4 1 1673 0.36 0.08 Smith 2 167 0.36 0.08 Allen 399 0.37 0.06 Allen 4 116 0.38 0.07 Allen 595 0.41 0.08 Allen I am trying to calculate the proportion/p

Re: [R] R for loop question

2008-05-20 Thread jim holtman
Consider using a 'list' instead of creating a lot of objects that you then have to manage: x <- lapply(1:length(stats$hour), function(.indx) dataset[.indx, 3:15]) You can then access the data as x[[1]], ... On Tue, May 20, 2008 at 12:58 PM, Douglas M. Hultstrand < [EMAIL PROTECTED]> wrote: > He

Re: [R] R for loop question

2008-05-20 Thread Erik Iverson
Take a look at ?assign Juan Manuel Barreneche wrote: I had to do the same thing many times, i usually use a combination of the functions "eval", "parse" and "sprinf", as below: k <- 1 for (i in 1:length(stats$hour)) { eval(parse(text=sprintf("x%s <- dataset[%s,(3:15)]", i, k))) k <- k+1

Re: [R] R for loop question

2008-05-20 Thread Juan Manuel Barreneche
I had to do the same thing many times, i usually use a combination of the functions "eval", "parse" and "sprinf", as below: k <- 1 for (i in 1:length(stats$hour)) { eval(parse(text=sprintf("x%s <- dataset[%s,(3:15)]", i, k))) k <- k+1 } what it does is: eval(parse(text=STRING)) is a way to

Re: [R] R for loop question

2008-05-20 Thread Erik Iverson
Douglas - To answer your question directly, use perhaps combination of ?assign and ?paste. In general, you usually do not have to do this sort of thing, but can use one of the apply family of functions (apply, sapply, lapply, mapply) to do whatever you want with shorter, cleaner code and few

[R] R for loop question

2008-05-20 Thread Douglas M. Hultstrand
Hello, I am trying to assign a variable name (x1,x2,x3...) in a loop statement that is based on a counter (counter is based on the number of hours within the datafile). The x1,x2 data will later be called for plotting the data. Below is a clip of the for loop I am using, any suggestions? k