Variable number of decimal places
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -9,7 +9,7 @@ file_name <- commandArgs(trailingOnly = TRUE)[1]
 | 
				
			|||||||
file_path <- paste(path, file_name, sep = "")
 | 
					file_path <- paste(path, file_name, sep = "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Convert opus binary file into dataframe
 | 
					# Convert opus binary file into dataframe
 | 
				
			||||||
data <- read_opus_univ(file_path)
 | 
					data <- read_opus_univ(file_path, 5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set working directory to path where the result file should appear
 | 
					# Set working directory to path where the result file should appear
 | 
				
			||||||
setwd(paste(path, "../DPT", sep = ""))
 | 
					setwd(paste(path, "../DPT", sep = ""))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
#Code adapted from github.com/philipp-baumann/simplerspec
 | 
					#Code adapted from github.com/philipp-baumann/simplerspec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
read_opus_univ <- function(file_path){
 | 
					read_opus_univ <- function(file_path, limit){
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
   `%do%` <- foreach::`%do%`
 | 
					   `%do%` <- foreach::`%do%`
 | 
				
			||||||
   extract <- 'spc'
 | 
					   extract <- 'spc'
 | 
				
			||||||
@@ -13,7 +13,6 @@ read_opus_univ <- function(file_path){
 | 
				
			|||||||
   
 | 
					   
 | 
				
			||||||
   try({
 | 
					   try({
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      # file_path <- "data/soilspec_background/yamsys_bg_gold/BF_lo_15_soil_cal.0"
 | 
					 | 
				
			||||||
      # Read entire content of file as bytes
 | 
					      # Read entire content of file as bytes
 | 
				
			||||||
      pa <- hexView::readRaw(file_path, offset = 0,
 | 
					      pa <- hexView::readRaw(file_path, offset = 0,
 | 
				
			||||||
                             nbytes = file.info(file_path)$size, human = "char",
 | 
					                             nbytes = file.info(file_path)$size, human = "char",
 | 
				
			||||||
@@ -409,8 +408,9 @@ read_opus_univ <- function(file_path){
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      ## Allocate and return data from spectra in output list (out) ==============
 | 
					      ## Allocate and return data from spectra in output list (out) ==============
 | 
				
			||||||
      out <- data.frame(wavenumbers[["spc"]], spc[['spc']], row.names = NULL)
 | 
					      out <- data.frame(round(wavenumbers[['spc']], limit), round(spc[['spc']], limit), row.names = NULL)
 | 
				
			||||||
      # Return spectra data and metadata contained as elements in list out
 | 
					      # Return spectra data and metadata contained as elements in list out
 | 
				
			||||||
      out
 | 
					      out
 | 
				
			||||||
   }) # closes try() function
 | 
					   }) # closes try() function
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user