首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据更改失败的值

数据更改失败的值
EN

Stack Overflow用户
提问于 2017-05-22 11:43:51
回答 1查看 56关注 0票数 2

当我从IR站点提取matadata时,我发现不能重写dataframe的值。在我提取的matadata中,有一个名为“Related”的属性值是“查看原文”(意思是“查找源”),需要用它在网页中的真正链接来替换。

代码语言:javascript
复制
> 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")

我尝试使用行名和列名称来定位“相关URL”的值,并将其值更改为:

代码语言:javascript
复制
meta_ru <- “http://www.jdis.org”
imeta_dc[c("Related URLs"), c("itemDisplayTable")] <- meta_ru

我使用行名而不是行号,因为这些元数据有不同的长度和不同的属性序列,只有这样才能准确地定位一个属性。此外,当我这样做时,没有任何错误或警告发生,但是数据无法写入,并且它变成了空白。我们应该做些什么来避免这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-22 11:57:21

dataset有一个问题,字段itemDisplayTable是因子,您需要首先将其转换为字符,然后使用rowname()函数将其分配给如下所示的值。

代码语言:javascript
复制
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)

输出

您可以在这里看到,相关的URL现在不是空的,在最后的输出中填充了"http://www.jdis.org“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44112008

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档