Need to create a new variable using COUNT

4 views
Skip to first unread message

Bruce Miller

unread,
Mar 31, 2018, 6:02:34 PM3/31/18
to ded...@googlegroups.com
Hi all,

I have been struggling to create a new variable using a count command-  I have looked at a number of options none have worked.
add_count(TBC, wt = NULL, sort = FALSE
count(df, vars = TBC, wt_var = NULL

add_tally(x, TBC, sort = FALSE)...Etc. all fail.


It was straight forward to derive 2 new variables (but had to kludge it with two separate steps rather than one)

What I am after is the sum of time bats were recorded that is simply adding duration of call pulses [Dur] and the time between the calls [TBC]. This became TT (total time).  I also needed to create a variable for Bandwidth (BW) of signals and that was easy.


Could not seem to combine doing this in one step. Myopil is the CSV data file

# Create new BW & Total time TT variables then change data file name

TT_CR<-within(Myopil,TT<-Dur+TBC)

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


What I need now to create a new derived/calculated variable "Call rate".

This is a simple "rate per second" so the new variable CR is the number of call pulses divided by TT (measured in milliseconds) * .001.

So I will have N/TT, but can not seem to derive the count of the number of TBC variables in the data.  This will change with each data set.


As noted above I tried using some of the count etc. function ]s but none worked.


I would like to combine creating the 2 variable TT & BW in one step then also create the new CR (call rate).

Suggestions needed on how to derive the count of the values of TBCs.

Tnx,


Bruce

AKA the Bozo on the Bus LOL



Reply all
Reply to author
Forward
0 new messages