[R] Fourier descriptors created in a loop

David Winsemius dwinsemius at comcast.net
Wed Jun 6 18:04:25 CEST 2012


On Jun 6, 2012, at 11:46 AM, David Winsemius wrote:

>
> On Jun 6, 2012, at 5:13 AM, 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")
>
> Have you considered how difficult it might be to extract any  
> information from a .png file that was constructed only one pixel wide?

Perhaps too cryptic and perhaps not exactly the reason the error was  
thrown. You called png() with three arguments when you were  
incorrectly expecting png() to read you mind and paste() them. The  
second argument, 1, was accepted as the width in pixels...  and did  
not throw the error, but the third argument ".png" created an error  
when it was matched to the height parameter of the png() function.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list