Question on creating new values

2 views
Skip to first unread message

Bruce Miller

unread,
Jan 9, 2018, 9:58:15 AM1/9/18
to ded...@googlegroups.com
Hi all,

I need to create a new set of derived values from an exiting value.
This is working to create one variable but when I tried to derive exact multiples (harmonics) of the recorded value but is not working as expected.
What I am trying to accomplish is deriving harmonics for a basic value.
This should be a simple multiple of a basic value.  The Fc (characteristic frequency) is recorded but depending on atmospheric conditions only a harmonic may be recorded.  So I need to derive the H1 (first or fundamental harmonic) and H3 as generally the H2 - second harmonic is recorded in the field.

This is working for other aspects and I was assisted by Ian et al. to come up with the correct syntax for this.

Batdata[c("TBC")] <- recode.variables(Batdata[c("TBC")] , "0 -> NA;")

# Create new BW variable then change data file name

BW<-within(Batdata,BW<-Fmax-Fmin)

BatStats<-BW

BatStats<-Deducer::descriptive.table (vars = d (Dur,TBC,Fmin,Fmax,BW,Fmean,Fk,Fc,Sc,Pmc),data= BatStats,func.names =c("Valid N","Minimum","Maximum","Mean","St. Deviation"),func.additional= list(p10=function(x) quantile(x, c(0.10), na.rm=TRUE),p25=function(x) quantile(x, c(0.25), na.rm=TRUE),p75=function(x) quantile(x, c(0.75),na.rm=TRUE),p90=function(x) quantile(x, c(0.90),na.rm=TRUE)))

## Write the results Change output name and directory for stats.

write.csv(BatStats,file="C:\\=Bat data working\\Acoustic Parameters\\Batdata_Stats.csv")

So in order to create the new "harmonic" variables I thought I could simply use the following.


FcH1<-within(Batdata,FcH1<-Fc*.5)

FcH3<-within(Batdata,FcH3<-FcH1*3)

I assumed this should work.


Thanks all

Bruce


Reply all
Reply to author
Forward
0 new messages