当我从IR站点提取matadata时,我发现dataframe的值无法重写。 在我提取的matadata中,有一个名为“Related URL”的属性值是“查看原文”(意思是“查找源代码”),需要在网页中用其真实链接替换。
> dput(imeta_dc)
structure(list(itemDisplayTable = structure(c(5L, 8L, 6L, 4L,
3L, 7L, 1L, 1L, 12L, 9L, 13L, 11L, 2L, 10L), .Names = c("Title",
"Author", "Source", "Issued Date", "Volume", "Corresponding Author",
"Abstract", "English Abstract", "Indexed Type", "Related URLs",
"Language", "Content Type", "URI", "专题"), .Label = c(" In the current data-intensive era, the traditional hands-on method of conducting scientific research by exploring related publications to generate a testable hypothesis is well on its way of becoming obsolete within just a year or two. Analyzing the literature and data to automatically generate a hypothesis might become the de facto approach to inform the core research efforts of those trying to master the exponentially rapid expansion of publications and datasets. Here, viewpoints are provided and discussed to help the understanding of challenges of data-driven discovery.",
"[http://ir.las.ac.cn/handle/12502/8904] ", "1, Issue:4, Pages:1-9",
"2016-11-03 ", "Data-driven Discovery: A New Era of Exploiting the Literature and Data",
"Journal of Data and Information Science ", "Ying Ding (E-mail:dingying@indiana.edu) ",
"Ying Ding; Kyle Stirling ", "查看原文 ", "期刊论文", "期刊论文 ",
"其他 ", "英语 "), class = "factor")), .Names = "itemDisplayTable", row.names = c("Title",
"Author", "Source", "Issued Date", "Volume", "Corresponding Author",
"Abstract", "English Abstract", "Indexed Type", "Related URLs",
"Language", "Content Type", "URI", "专题"), class = "data.frame")
我尝试使用行和列的名称来查找“相关网址”的值,并通过这样的句子更改其值:
meta_ru <- “http://www.jdis.org”
imeta_dc[c("Related URLs"), c("itemDisplayTable")] <- meta_ru
我使用rownames而不是rownumbers,因为这些元数据具有不同的长度和不同的属性序列,只有这样才能准确定位一个属性。此外,当我这样做时,没有出现错误或警告,但数据无法写入,并且它变为空白。我们该怎么做才能避免这个问题?
答案 0 :(得分:0)
您的数据集存在一个问题,字段itemDisplayTable
是因素,您需要先将其转换为字符,然后使用rownames()函数将其分配给如下的值。
df$itemDisplayTable <- as.character(df$itemDisplayTable)
meta_ru <- c("http://www.jdis.org")
df[(rownames(df) %in% c("Related URLs"))==T,"itemDisplayTable"] <- meta_ru
View(df)
<强>输出强>:
您可以在此处看到相关网址现在不为空,并在最终输出中填充“http://www.jdis.org”。