I need to run an awk script to detect local maxima(peaks) in a spectrum. This spectrum is in the form of two columns in a text file.
This is part of a larger project
If you have reasonably smooth spectral data, there are several functions available which do a good job of locating local maxima and minima (aka "peaks"). I like the tools in pastecs
, but take a look at the following packages (in my rough order of choice) :
pastecs,
Peaks,
seewave,
ppc
Update for Windows 10 users now able to use AWK natively:
To Windows 10 users with WSL (windows subsystem for linux) installed, you can run AWK in windows from an R console with:
> system( 'wsl awk \'BEGIN { print "Hello, world" }\' ')
Hello, world
you should be able to do
system('your awk command here')
If you have single quotes in your awk
command, either do as Hong Ooi suggests and put your awk
command in a separate file and then just run that from the system
command or escape the single quotes:
> system('echo \'hello guy!\' ')
hello guy!