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
{{ message }}
Repository navigation
read.spc cannot handle spectra files with only one line in the audit log that ends with "\r\n" #64
After tracing down the function in the code, it looks like the origin is in the "hyperSpec:::split.string" function.
What happens is when variable "x" only has one line and ends with "\r\n\" (for example "myString\r\n\"), the pos matrix will turn into an array rather then a matrix and cause the error above.
Alternate versions of strings using "r\n\" like:
"myString\r\n\test"
"myString\r\n\test\r\n\"
Do seem to work.
Let me know if there are further questions on this.
Thanks for contacting us. It seems that the issue is OS-specific, as you indicate that it is related to \r\n. I have a few additional questions:
what R version do you use?
what hyperSpec version do you use?
what operating system do you use?
what operating system was used to create the data file?
could you provide an example of a data file? You may zip it and drag-and-drop here.
could you provide a minimal reproducible example of code (a.k.a, reprex) that reproduces the reproduction of the issue. I recommend using reprex package to generate a reprex.
If possible, show us how the expected result should look like.
could you provide a minimal reproducible example of code (a.k.a, reprex) that reproduces the reproduction of the issue. I recommend using reprex package to generate a reprex.
If possible, show us how the expected result should look like.
In the function "hyperSpec:::string.split" adjust the following line:
x <- apply(pos, 1, function(p, x) substr(x, p[1], p[2]),
x)
To include a check whether the variable "pos" is a matrix(which has dimensions), otherwise it should be an array according on how the script acts:
if(!is.null(dim(pos))){
x <- apply(pos, 1, function(p, x) substr(x, p[1], p[2]),
x)
} else {
x <- substr(x, pos[1], pos[2])
return(x)
}
I can reproduce the issue with hySpc.read.spc package:
hySpc.read.spc::read.spc("Example_spectra.spc")
## Error in apply(pos, 1, function(p, x) substr(x, p[1], p[2]), x) : ## dim(X) must have a positive length
It seems that function read.spc() is not renamed into read_spc() yet. And internal function split.string() is now a part of hySpc.read.spc package (so I'll migrate the issue to the appropriate repo).
Activity
GegznaV commentedon Nov 16, 2021
Hello, Patric (@PAAC1984),
Thanks for contacting us. It seems that the issue is OS-specific, as you indicate that it is related to
\r\n. I have a few additional questions:hyperSpecversion do you use?reprexpackage to generate a reprex.PAAC1984 commentedon Nov 16, 2021
3.6.0 (2019-04-26)
hyperSpec_0.100.0
Windows 10 x64
Windows 10 x64
Example_spectra.zip
library(hyperSpec)
hyperSpec::read.spc("../Example_spectra.spc")
In the function "hyperSpec:::string.split" adjust the following line:
x <- apply(pos, 1, function(p, x) substr(x, p[1], p[2]),
x)
To include a check whether the variable "pos" is a matrix(which has dimensions), otherwise it should be an array according on how the script acts:
if(!is.null(dim(pos))){
x <- apply(pos, 1, function(p, x) substr(x, p[1], p[2]),
x)
} else {
x <- substr(x, pos[1], pos[2])
return(x)
}
GegznaV commentedon Nov 17, 2021
Thank you @PAAC1984.
@cbeleites, could you look into this?
Does this issue belong tohyperSpecor tohySpc.read.spc?GegznaV commentedon Nov 17, 2021
I can reproduce the issue with hySpc.read.spc package:
It seems that function
read.spc()is not renamed intoread_spc()yet. And internal functionsplit.string()is now a part of hySpc.read.spc package (so I'll migrate the issue to the appropriate repo).GegznaV commentedon Nov 17, 2021
GitHub does not allow transferring the issue to the particular
hySpc.read.spcrepo. But the following discussion must continue there: