-1
Rstudio在工作時崩潰並且未保存的文件無法加載到會話中。但是這些文件以JSON格式提供。一個例子,將json文件轉換爲R /文本文件而不執行
{
"contents" : "library(hgu133a.db)\nx <- hgu133aENSEMBL\nx\nlength(x)\ncount.mappedkeys(x)\nx[1:3]\nlinks(x[1:3])\n\n## Keep only the mapped keys\nkeys(x) <- mappedkeys(x)\nlength(x)\ncount.mappedkeys(x)\nx # now it is a submap\n\n## The above subsetting can also be achieved with\nx <- hgu133aENSEMBL[mappedkeys(hgu133aENSEMBL)]\n\n",
"created" : 1463131195093.000,
"dirty" : true,
"encoding" : "",
"folds" : "",
"hash" : "1482602869",
"id" : "737C178C",
"lastKnownWriteTime" : 0,
"path" : null,
"project_path" : null,
"properties" : {
"tempName" : "Untitled3"
},
"source_on_save" : false,
"type" : "r_source"
}
的JSON格式的文件可以使用讀取的jsonlite::fromJSON
和所需的信息存儲在變量內容。當試圖使用readLines()
or scan()
讀取命令時,命令正在執行而不是將它們轉換爲簡單文件。如何將其轉換爲r
文件?
輸出(?):在r
腳本/文本文件中的命令。
library(hgu133a.db)
x <- hgu133aENSEMBL
x
length(x)
count.mappedkeys(x)
x[1:3]
links(x[1:3])
## Keep only the mapped keys
keys(x) <- mappedkeys(x)
length(x)
count.mappedkeys(x)
x
# now it is a submap
## The above subsetting can also be achieved with
x <- hgu133aENSEMBL[mappedkeys(hgu133aENSEMBL)]
'writeLines(JSON $內容,CON = 「/path/to/file.R」)'? –