1

我正在尝试将元数据附加到 R 中的列。我有一个大型数据集,并且想通过评论在 R 中提取元数据信息(或者有更合适的地方吗?)。我将元数据输入到单独文件中的单个单元格中,并在定义注释时尝试引用它们。

我尝试了以下方法:

comment(data$cat)=as.quoted(metadata$catdot)
comment(data$cat)
# NULL

下一个我试图在我想要插入的文本周围加上引号

comment(data$cat)=as.quoted(metadata$cat)
# Error in parse(text = x) : <text>:1:5: unexpected symbol
# 1: how many
   ^

使用引号的另一种尝试。请忽略愚蠢的文字,我只是用我编写的数据集和元数据测试代码

comment(data$place)=metadata$placequote
# Error in `comment<-`(`*tmp*`, value = list("whether the location is a shelter or a foster home because that is really important the poor little dogs and cats just don't have anywhere else to go maybe they are blind or starving and it's really just such a shame")) : 
# attempt to set invalid 'comment' attribute

comment(data$place)=readChar(metadata$place,nchars=81)
# Error in readChar(metadata$place, nchars = 81) : 
# cannot read from this connection

comment(data$place)=paste(readLines(metadata$place), collapse=" ")
# Error in readLines(metadata$place) : 'con' is not a connection
4

0 回答 0