I uploaded onto R multiple csv files with 16 columns that have 100 data values, some NA which I learned need to be made into 0 in order for findpeaks to work. For each data frame within the list I want to find the peaks of each individual column. I am able to run the code on an individual data frame so I know there are no issues with the data entered (code below for single data frame extracted from list).
peak_info <- lapply(myfiles$dt1, findpeaks, npeaks=6, threshold=4, nups = 2, sortstr=FALSE)
But when I try to find peaks of all data frames saved in the list using the following code:
peaks <- lapply(myfiles, function(x) findpeaks(x, npeaks=6, threshold=4, nups = 2, sortstr=FALSE) )
I get the following error.
Error in findpeaks(y, npeaks = 6, threshold = 4, nups = 2, sortstr = FALSE) : is.vector(x, mode = "numeric") || length(is.na(x)) == 0 is not TRUE
There are a few more functions I want to use so that is why I opted for function(x). Basically once extracted I don't need to placed the data back in the list. I find the average of the peak and saved them in a new data frame.
Thanks again for your help.