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

Re: [R] R for loop

2013-11-15 Thread Jeff Newmiller
You seem to have a problem with your Mindreader skills today, David! --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

Re: [R] R for loop

2013-11-15 Thread David Carlson
I would be easier to respond if we had some idea what Mindreader_2012_vars is, data.frame, list, matrix? Give us a small, reproducible version of what you are trying to accomplish. - David L Carlson Department of Anthropology Texas A&M University College Stati

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

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

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