Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dealing with infinite or missing values #21

Open
qmwnebrv opened this issue Aug 9, 2024 · 0 comments
Open

dealing with infinite or missing values #21

qmwnebrv opened this issue Aug 9, 2024 · 0 comments

Comments

@qmwnebrv
Copy link

qmwnebrv commented Aug 9, 2024

Hi Philipp, Just wondering if you could help me identify how to debug the following error:
Error in svd(x, nu = 0, nv = k) : infinite or missing values in 'x'
This is coming from the following:

spectra <- read_opus_univ(vial_paths)

test_table <- spectra %>%
  gather_spc() %>%
  resample_spc(x_unit = 'wavenumber',
               wn_interval=2) %>%
  average_spc() %>%
  preprocess_spc(select = 'sg_1_w21')

#### Read N ANalysis data ####

Nitrogen_Raw <- readxl::read_xlsx('Nitrogen_analysis.xlsx', skip = 5)[1:108,] %>%
  mutate(sample_id = paste('Harvest',H,'Row',Row,'Range',Range, sep = ' ')) %>% # Create a sampleID
  select(sample_id, H, Row, Range, `%C`, `%N`) %>% # Move sampleID to the front
  mutate(sample_id = as.factor(sample_id)) %>%
  rename(N = `%N`,
         C = `%C`)

#### Join N analysis dataset with Spectral data ####
spec_chem <- join_spc_chem(spc_tbl = test_table, chem_tbl = Nitrogen_Raw, by = "sample_id")

pls_mod <- fit_pls(
  spec_chem = spec_chem[!is.na(spec_chem$N),],
  response =
    N, 
  center = T,
  scale = T,
  print = T
)

I assume this is because there is missing data somewhere, but I don't know how exactly to clean it up. Any ideas would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant