[R] Fourier descriptors created in a loop

David Winsemius dwinsemius at comcast.net
Tue Jun 5 21:34:58 CEST 2012


On Jun 5, 2012, at 11:50 AM, aledanda wrote:

> Hi All,
>
> Here is the problem: I'm trying to generate a number of Fourier  
> Descriptors
> figures for an experiment.

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’


> All I need is that they are created within a  loop and saved with  
> sequential
> names (e.g., s1_1.png, s1_2.png etc..) in my directory.
>
> I created a nested loop with a counter for the different amplitudes  
> for the
> actual shapes and a counter for the file names.
>
> This script:
>
>
> *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?


>  for (s in 1:length(count)){
>
>    png("~/Desktop/EMAS/FD_stimuli/s1_",s,".png")
>
>    plot(create.fourier.descriptor(amplitude = c(0, i, 0, 0)));
>
>    dev.off()
>
>  }
> }*
>
> .... gives me the following error:
>
> /Error in switch(units, `in` = res, cm = res/2.54, mm = res/25.4, px  
> = 1) *
> :
>  non-numeric argument to binary operator

Makes me wonder if this package's code has caused the interpreter to  
attempt something illegal with the 'in' control construct.

 > in<-5
Error: unexpected 'in' in "in"

 > `in` <-5
 > in
Error: unexpected 'in' in "in"
 > rm(`in`)

> In addition: Warning message:
> In 1:count : numerical expression has 101 elements: only the first  
> used/

Oh... there it is.

>
> it seems to be a problem with the resolution of each picture which is
> different one form the other. In principle this shouldn't be a  
> problem if
> every time a new png is created.
>
> could you help me with this?
> Thank you very much
> Best,
>
> Ale
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Fourier-descriptors-created-in-a-loop-tp4632414.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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list