You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow this project's Contributing Guidelines.
Description
I know we had this chat a while back but I was thinking it could be good to revisit it. I am running into some challenges implementing the Open Specy package because sometimes it is easiest to just implement the functions on the spectra vectors individually. At the core, I think many of the functions already operate on vectors, and we are currently hiding that capability from the user.
Problem
Sometimes it is easiest to run function on intensity vectors rather than Open Specy objects.
Proposed Solution
Can be implemented as default function in s3 for most of the spectral intensity functions. Could also be implemented as .Vector functions in S3.
Alternatives Considered
Disallow vector operations for function consistency, require users to create their own routines.
The text was updated successfully, but these errors were encountered:
Another useful thing to add to this update would be too allow ignoring NA values in spectral intensities. I got this function for it:
# Define the function to apply, ignoring NA valuesapply_function_ignoring_na<-function(x, fun) {
# Identify NA positionsna_positions<- is.na(x)
# Apply the function only to non-NA elementsresult<-numeric(length(x))
result[!na_positions] <- fun(x[!na_positions])
# Reinsert NA values in their original positionsresult[na_positions] <-NAreturn(result)
}
# Example vector with NA valuesexample_vector<- c(1, NA, 3, NA, 5)
# Example function to apply (e.g., multiply by 2)example_function<-function(x) {
x*2
}
# Apply the function to the vector, ignoring NA valuesresult_vector<- apply_function_ignoring_na(example_vector, example_function)
# Print the result
print(result_vector)
Guidelines
Description
I know we had this chat a while back but I was thinking it could be good to revisit it. I am running into some challenges implementing the Open Specy package because sometimes it is easiest to just implement the functions on the spectra vectors individually. At the core, I think many of the functions already operate on vectors, and we are currently hiding that capability from the user.
Problem
Sometimes it is easiest to run function on intensity vectors rather than Open Specy objects.
Proposed Solution
Can be implemented as default function in s3 for most of the spectral intensity functions. Could also be implemented as .Vector functions in S3.
Alternatives Considered
Disallow vector operations for function consistency, require users to create their own routines.
The text was updated successfully, but these errors were encountered: