admin管理员组文章数量:1400800
I have dowloaded a MATLAB file with species names and their ecological group from /
In step 5 on this page the file library.mat can be downloaded (zipped). I then use the function readMat() from the R.matlab library to read this file:
library(R.matlab)
ambi<-readMat("library.mat")
I get this 7 warnings:
Warning messages:
1: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 2: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 3: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 4: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 5: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 6: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 7: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw
I don't know what this means but I suspect it has something to do with encodings. I would be very thankful if someone can tell me what the reason is and how I can solve this problem. I don't have MATLAB. I am using R version 4.4.3 on Swedish Windows 11.
I have dowloaded a MATLAB file with species names and their ecological group from https://ambi.azti.es/download/
In step 5 on this page the file library.mat can be downloaded (zipped). I then use the function readMat() from the R.matlab library to read this file:
library(R.matlab)
ambi<-readMat("library.mat")
I get this 7 warnings:
Warning messages:
1: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 2: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 3: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 4: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 5: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 6: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw 7: In convertUTF8(ary) : out-of-range values treated as 0 in coercion to raw
I don't know what this means but I suspect it has something to do with encodings. I would be very thankful if someone can tell me what the reason is and how I can solve this problem. I don't have MATLAB. I am using R version 4.4.3 on Swedish Windows 11.
Share Improve this question edited Mar 25 at 17:56 M-- 29.5k10 gold badges69 silver badges106 bronze badges Recognized by R Language Collective asked Mar 25 at 15:47 Mats_BMats_B 1451 silver badge8 bronze badges1 Answer
Reset to default 1I looks like R.matlab
is doing you a favour by omitting those characters. While I am not an SME, an internet search suggests those characters are often omitted from the affected species names so perhaps they are errors? At least there are only seven to deal with if you have to manually edit them.
To examine the issue, you can use the rmatio
package, as it will retain the non-UTF characters.
library(rmatio)
library(stringi)
# Unzip .mat previously downloaded from
# https://azti.sharepoint/sites/Proyectos/AMBI/Documentos%20compartidos/Forms/AllItems.aspx?id=%2Fsites%2FProyectos%2FAMBI%2FDocumentos%20compartidos%2FLibrary%2D2024%2Ezip&parent=%2Fsites%2FProyectos%2FAMBI%2FDocumentos%20compartidos&p=true&ga=1
# Edit file path where necessary
unzip("data/AMBI/Library-2024.zip",
files = "library.mat",
exdir = "data/AMBI/")
ambi <- read.mat("data/AMBI/library.mat")
# Convert to df
df <- data.frame(name = unlist(ambi$specieslist$name),
group = unlist(ambi$specieslist$group),
reassign = unlist(ambi$specieslist$reassign))
# Return rows containing non-UTF
x <- df[which(stri_enc_mark(df$name) == "native"),]
x$name
# [1] "Congetia chesneyi\xfd" "Erythrops go\xfdsi" "Erythrops go\xfdsii"
# [4] "Gymnonereis\xfdcrosslandi" "Hippolyte cura\xfdaoensis" "Neorhynchoplax\xfdsp."
# [7] "Valencinia\xfdsp."
# Convert non-UTF chars
iconv(x$name, from = "macroman", to = "UTF-8")
# [1] "Congetia chesneyi˝" "Erythrops go˝si" "Erythrops go˝sii"
# [4] "Gymnonereis˝crosslandi" "Hippolyte cura˝aoensis" "Neorhynchoplax˝sp."
# [7] "Valencinia˝sp."
The closest encoding I could find was "macroman" but it is still not correct. Again, not an SME, but it appears that in some cases, those non-UTF characters are supposed to be either a "ë", or not there at all. If there is uncertainty, the only thing I can suggest is to contact the data maintainers to find out the correct encoding, or whether these are indeed errors. At least then you can rule out whether it's something to do with R.
本文标签: Out of range values when reading a MATLAB file with RmatlabStack Overflow
版权声明:本文标题:Out of range values when reading a MATLAB file with R.matlab - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744185167a2594256.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论