[R] Fourier descriptors created in a loop

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Jun 6 17:00:07 CEST 2012


It would help if you read the manual page for "png" and gave it arguments 
that matched what the function expects.  You probably also need to read 
?paste.

Also, based on what you have said so far, you do NOT need nested for 
loops. Just use the inner loop and when you need "i" use instead 
"count[s]".

On Wed, 6 Jun 2012, aledanda wrote:

> Hi David,
>
> Thank you for your reply.
>
> /Somehow I'm guessing that this will involve load an unnamed package. 
> Yep:
> > ?create.fourier.descriptor
> No documentation for ?create.fourier.descriptor? in specified packages 
> and libraries:
> you could try ???create.fourier.descriptor?/
>
> So I indeed forgot to mention in my post that my script starts with 
>
> *library('FourierDescriptors')*
>
>
> /> *count <- seq(1, 7, 0.06)
>>
>> for (i in 1:count){
>
> I was also  wondering what would happen when you passed a vector to 
> the ":" operator. A warning at the very least. What was the point of 
> this outer loop?/
>
> I need the outer loop for changing the amplitude of my shapes at every
> iteration.
> I specified the amplitudes I want in 
>
> count <- seq(1, 7, 0.06).
>
> This outer loop actually works (when I correct the  "for (i in 1:count){"
> into  "for (i in count){.")
> It generates in fact all the shapes I want. The problem is with the inner
> loop, it doesn't seem to save any png picture in my directory. The error is:
>
> *Error in switch(units, `in` = res, cm = res/2.54, mm = res/25.4, px = 1) * 
> :
>  non-numeric argument to binary operator*
>
> I report my all script here again:
>
> library('FourierDescriptors')
>
> count <- seq(1, 7, 1)
> # Controlled shapes
> for (i in count){
>  for (s in 1:length(count)){
>    png("~/Desktop/EMAS/FD_stimuli/s1_",s,".png")
>    plot(create.fourier.descriptor(amplitude = c(0, i)));
>    dev.off()
>  }
> }
>
> Thank you for your help
> Best
>
> Ale
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Fourier-descriptors-created-in-a-loop-tp4632414p4632505.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k



More information about the R-help mailing list