IRサイトからmatadataを抽出すると、dataframeの値を書き換えることができませんでした。 matadata Iの抽出には、 "関連URL"という属性の値が "查看原文"( "ソースを参照する"という意味)であり、Webページの実際のリンクで置き換える必要があります。データフレームの変更に失敗した値
> 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:[email protected]) ",
"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")
Iは「関連するURL」の値を探し、そのような文によって、その値を変更する行と列の名前を使用しようとした:
meta_ru <- “http://www.jdis.org”
imeta_dc[c("Related URLs"), c("itemDisplayTable")] <- meta_ru
それらのメタデータが持っているので、私はrownames代わりにrownumbersを使用属性の長さと順序が異なる場合、この方法では1つの属性を正確に特定できます。さらにこれを行うと、エラーや警告は発生しませんが、データは書き込めず、空白に変わります。この問題を避けるために私たちは何をすべきですか?
ご回答ありがとうございます。私はこの質問を投稿する前に、最新のテストで。私は "as_factor"を使って "meta_ru"を "factor"クラスに変更しようとしましたが、それでもデータフレームに書き込むことはできませんでした。 「因子」クラスを使用するときには何かトリックはありますか? –
@赵鸿丰あなたは私の知識の中で、文字の機能を使用するために、少なくともファクターを管理することはできません。文字に変換する必要がありますが、何かエラーがありますか?あなたが要素から文字に変換しようとしている間。理想的には、data.frameを読むときは、コードの先頭に常に 'options(stringsAsFactors = F)'を使うべきです。 – PKumar
@赵鸿丰 'library(dplyr);を使うことができます。多くの因子列を一度に文字に変換したい場合は、df1 <- df %>%mutate_if(is.factor、as.character)を使用します。 'df1'はここでは因子のない最後のデータセットです。' df'は因子のあるデータフレームです – PKumar