# NOT RUN {
# }
# NOT RUN {
vignette ("file-io")
# }
# NOT RUN {
## export & import matlab files
if (require (R.matlab)){
# export to matlab file
writeMat ("test.mat", x = flu[[]], wavelength = flu@wavelength,
label = lapply (flu@label, as.character))
# reading a matlab file
data <- readMat ("test.mat")
print (data)
mat <- new ("hyperSpec", spc = data$x,
wavelength = as.numeric(data$wavelength),
label = data$label[,,1])
}
## ascii export & import
write.txt.long (flu, file = "flu.txt", cols = c(".wavelength", "spc", "c"),
order = c("c", ".wavelength"),
decreasing = c(FALSE, TRUE))
read.txt.long (file = "flu.txt", cols = list (.wavelength = expression (lambda / nm),
spc= "I / a.u", c = expression ("/" (c, (mg/l)))))
write.txt.wide (flu, file = "flu.txt", cols = c("c", "spc"),
col.labels = TRUE, header.lines = 2, row.names = TRUE)
write.txt.wide (flu, file = "flu.txt", col.labels = FALSE, row.names = FALSE)
read.txt.wide (file = "flu.txt",
cols = list (c=expression ("/"("c", "mg/l")), spc="I / a.u", .wavelength = "lambda / nm"),
header = TRUE)
# }
Run the code above in your browser using DataLab