rdata

When loading data in Rstudio getting error “ReadItem: unknown type 161, perhaps written by later version of R”?

寵の児 提交于 2020-05-13 22:38:03
问题 When I am trying to load a clean data in Rstudio, file name called salesClean.RData, I am getting error. Error message is: ReadItem: unknown type 161, perhaps written by later version of R Screenshot of error message: 回答1: Here is what worked for me: Simple Solution: Try to use the tool Load Workspace . It allows you to select the Rds file and load it into memory. Best Solution: In some cases you do need to load the file programatically. In these situations you will probably prefer get your R

When loading data in Rstudio getting error “ReadItem: unknown type 161, perhaps written by later version of R”?

*爱你&永不变心* 提交于 2020-05-13 22:37:43
问题 When I am trying to load a clean data in Rstudio, file name called salesClean.RData, I am getting error. Error message is: ReadItem: unknown type 161, perhaps written by later version of R Screenshot of error message: 回答1: Here is what worked for me: Simple Solution: Try to use the tool Load Workspace . It allows you to select the Rds file and load it into memory. Best Solution: In some cases you do need to load the file programatically. In these situations you will probably prefer get your R

quickly load a subset of rows from data.frame saved with `saveRDS()`

╄→гoц情女王★ 提交于 2020-01-25 04:29:06
问题 With a large file (1GB) created by saving a large data.frame (or data.table ) is it possible to very quickly load a small subset of rows from that file? ( Extra for clarity : I mean something as fast as mmap , i.e. the runtime should be approximately proportional to the amount of memory extracted, but constant in the size of the total dataset. "Skipping data" should have essentially zero cost. This can be very easy, or impossible, or something in between, depending on the serialiization

Loop over a subset, source a file and save results in a dataframe

放肆的年华 提交于 2020-01-17 05:58:52
问题 Similar questions have been asked already but none was able to solve my specific problem. I have a .R file ("Mycalculus.R") containing many basic calculus that I need to apply to subsets of a dataframe: one subset for each year where the modalities of "year" are factors (yearA, yearB, yearC) not numeric values. The file generates a new dataframe that I need to save in a Rda file. Here is what I expect the code to look like with a for loop (this one obviously do not work): id <- identif(unlist

Create R data with a dynamic variable name from function for package?

岁酱吖の 提交于 2020-01-05 05:47:27
问题 I am working on a function which is part of a package. This package contains a template for a new package, and a function which creates R data for the new package which has to have a dynamic name provided to this function. At the moment I am doing the following: makedata <- function(schemeName, data) { rdsFile <- paste0(schemeName, ".rds") varName <- paste0(schemeName) saveRDS( data, file = file.path( ".", "data", rdsFile ) ) cat( paste0(varName, " <- readRDS(\"./", rdsFile, "\")"), file =

Converting Rdata files to CSV - Error in data.frame arguments imply differing number of rows

我怕爱的太早我们不能终老 提交于 2019-12-19 11:42:56
问题 I'm trying to use the R code from this answer to convert a bunch of rdata files to CSV. resave <- function(file){ e <- new.env(parent = emptyenv()) load(file, envir = e) objs <- ls(envir = e, all.names = TRUE) for(obj in objs) { .x <- get(obj, envir =e) message(sprintf('Saving %s as %s.csv', obj,obj) ) write.csv(.x, file = paste0(obj, '.csv')) } } resave('yourData.RData') However on one of the files I'm getting this error: Error in data.frame(`2` = list(pos = c(6506L, 6601L, 21801L, 21811L,

Reading Rdata file with different encoding

不想你离开。 提交于 2019-12-18 04:46:28
问题 I have an .RData file to read on my Linux (UTF-8) machine, but I know the file is in Latin1 because I've created them myself on Windows. Unfortunately, I don't have access to the original files or a Windows machine and I need to read those files on my Linux machine. To read an Rdata file, the normal procedure is to run load("file.Rdata") . Functions such as read.csv have an encoding argument that you can use to solve those kind of issues, but load has no such thing. If I try load("file.Rdata"

Importing data into R (rdata) from Github

对着背影说爱祢 提交于 2019-12-17 16:35:27
问题 I want to put some R code plus the associated data file (RData) on Github. So far, everything works okay. But when people clone the repository, I want them to be able to run the code immediately. At the moment, this isn't possible because they will have to change their work directory (setwd) to directory that the RData file was cloned (i.e. downloaded) to. Therefore, I thought it might be easier, if I changed the R code such that it linked to the RData file on github. But I cannot get this to

Get specific object from Rdata file

跟風遠走 提交于 2019-12-17 03:51:40
问题 I have a Rdata file containing various objects: New.Rdata |_ Object 1 (e.g. data.frame) |_ Object 2 (e.g. matrix) |_... |_ Object n Of course I can load the data frame with load('New.Rdata') , however, is there a smart way to load only one specific object out of this file and discard the others? 回答1: .RData files don't have an index (the contents are serialized as one big pairlist). You could hack a way to go through the pairlist and assign only entries you like, but it's not easy since you

Saving matrix in Rdata and updating Rdata file

核能气质少年 提交于 2019-12-13 14:17:57
问题 I have a matrix: mat<-matrix(data=1:30,ncol=10,nrow=3) I would like to save this to Rdata: save(mat, file="m.Rdata") Then load it back: m<-load("m.Rdata") Then look at its contents: m [1] "mat" All it displays is the name of the matrix saved but the values are lost. What am I doing wrong? Also Once I have saved the matrix I would like to create a new matrix: mat2<-matrix(data=30:59,ncol=10,nrow=3) I would then like to save this mat2 into the same Rdata file, what is the right procedure? 回答1: