I just ran below R code but I am getting error msg... Could anyone help me how to make this code runable on my machine. Thanks.
Here's the command:
load(file = "c:\\abcdeXXX.RData")
And here's the resulting error message:
Error in if (!grepl("RD[AX]2\n", magic)) { : argument is of length zero
I suspect your file is empty.
The error message means that the argument magic has length zero. If you read the source code for load, you will find the following line of code:
magic <- readChar(con, 5L, useBytes = TRUE)
Thus magic is the first 5 bytes of your file. In other words, your file is empty.
it is possible that the RData file you are trying to open is damaged or incomplete. Can you open it on another machine?
Also worth noting, early versions of R cannot open RData files created by later versions of R. Although I would not expect a version mismatch to cause your error.
Related
I am actually trying to open a netcdf file with 'Ferret' and I get this error message.
In sum up, when trying to open the file:
use all_sondes_test.nc
I get the following message:
NetCDF: Not a valid data type or _FillValue type mismatch (OPeNDAP/netCDF Error code -45) is this a CDF file ?
I hope the problem looks clear to the community.
I have already tried to find some help on the web, without any success.
Thanks for your help !
So I'm rather new to R, and I'm learning how to mine text from this handy website: https://eight2late.wordpress.com/2015/05/27/a-gentle-introduction-to-text-mining-using-r/
I do have my own text set of .doc, .docx, and .xlsx files and I'm trying to mine them. They're located in a folder in my working directory called 'files', but I have already encountered an error after simply writing a few lines of code.
The code I have so far is:
library(tm)
library(readtext)
data = readtext('files')
At this point, after waiting for 25 seconds or so, I get the error:
Error: System call to 'antiword' failed (1): The Big Block Depot is damaged
and the code stops running there.
I have tried searching online for solutions but it seems like a fairly rare error and so I only found 1 possible solution at https://github.com/ropensci/antiword/issues/1 but that did not work for me.
This solution suggested that one of my files were corrupt, and suggested using the code
fixInNamespace(antiword, pos="package:antiword")
to change the error to a warning to not interrupt the reading of the files. I tried that, and at first it raised the error of
Error in as.environment(pos):
no item called "package:antiword" on the search list
After which, I loaded the antiword library with a library(antiword) and changed the stop( to a warning(. However, when I ran the data = readtext('files') line again, it immediately raised the error
Error in is_windows() : could not find function "is_windows"
I'm at a loss here! Any help would be appreciated. Should I be using another package in this case?
I had the same problem with my code, where I tried to get a doc. file in R. I also used the readtext library. What helped me was converting the Word documents I was trying to get into R from doc. to docx. When I ran the same code after it worked.
I am a Bioinformatics student and pretty much an amateur R user. I have gone through almost the whole of the internet without getting any examples for the working of this package except the documentation provided by 'Bioconductor'-website. I am currently working on the 'AllelicImbalance' package provided by 'Bioconductor' for handling genomics data such as large 'BAM' files to find specific allelic positions and then analyzing them. I have gone ahead with their tutorial by creating a BAM format file. Then later to operate the file, I have set my working directory where my files have been saved.
The code for operating is -
> library(AllelicImbalance)
> searchArea<-GRanges(seqnames = c("17"), ranges = IRanges(79478301, 79478361))
> pathToFiles<-system.file("ERR009135.bam", package = "AllelicImbalance")
> reads<-impBamGAL(pathToFiles, searchArea, verbose=FALSE)
I get an error after the last command which says -
Error in .local(UserDir, ...) : No bam files found in
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="": The filename, directory name, or volume label syntax is incorrect
The samples that I have used are present in here and are paired-end 'fastqc' files - ftp://ftp.sra.ebi.ac.uk/vol1/fastq/ERR009/ERR009135
To download these files, a stable and fast internet connection is required. Later I converted these files to the 'BAM' format using the 'Linux' in the file 'ERR009135.bam'.
I would love to know if it is a general R syntax error or is it a major error where I need to make modifications with my files such as the 'BAM' files (ERR009135.bam). Please do reply with any suggestions or modifications. Will be deeply appreciated.
Thank you in advance!
I manage a number of Excel reports, and I use R to do the preprocessing and write the output report. It's great because all I have to do is run the R function and distribute the reports, and the rest of the report writing is inactive time. The reports need to be in Excel format because it is the easiest to disseminate and the audience is large and non-technical. Once the data is pre-processed, I do this very, very simply using XLConnect:
file.copy(from = template,
to = newFileName)
writeWorksheetToFile(file = newFileName,
data = newData,
sheet = "Data",
clearSheets = T)
However, one of my reports began throwing this error when I attempted to write the new data:
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
Furthermore, before throwing the error, the function ties up R for 15 minutes. The normal writing time is less than 10 seconds. I must confess, I don't understand what this error even means, and it did not succumb to my usual debugging methods or to any other SO solution.
I've noticed that others have referred to rJava (reinstalling this package didn't work) and to a Java cache of log files (not sure where this would be located on Mac). I'm especially confused as the report ran with no problems just one day earlier using precisely the same process, AND my other reports using the exact same process still work just fine.
I didn't update Java or R or my OS, or debug/rewrite any of the R code. So, starting from the beginning - how can I investigate this 'envir' error? What would you do if you were in my shoes? I've been working on this for a couple days and I'm stumped.
I'm happy to provide extra information if it will provide better context for more discerning programmers than myself :)
Update:
My previous answer (below) did not, in fact, fix this intermittent error (which as the OP points out is extremely difficult to unpick due to the Java dependency). Instead, I followed the advice given here and migrated from the XLConnect package to openxlsx, which sidesteps the problem entirely.
Previous answer:
I've been frustrated by precisely this error for a while, including the apparent intermittency and the tying up of R for several minutes when writing a workbook.
I just realised what the problem was: the length of the name of an Excel worksheet appears to be limited to 31 characters, and my R code was generating worksheet names in excess of this limit.
Just to be clear, I'm referring to the names of the individual tabbed sheets within an Excel workbook, not the filename of the workbook itself.
Trimming each worksheet name to no more than 31 characters fixed this error for me.
If I have more data loaded in R I'm having difficulties with opening and choosing new file via file.choose() and later upload via read.csv(), but I would not get to that point since the file.choose function stacks and the R "crushes" and reports something like "unidentified error occurred and that the R must restart".
I'm using RStudio and running this on Windows 7. The hardware is up to date.
Could someone point me on why this is happing and what would be a remedy against this. Are there other options to select file? I know I can insert the path right into the read.csv command, but the (file is different every time).
EDIT:
The error just happened again. I can not reproduce the error so it happens rather only with high likelihood if the conditions for it are met.
The error reads as: R Session Aborted.R encountered fatal error. The session was terminated. And in window: "Start New Session".
EDIT 2:
I would just rephrase my question. The question is whether there is other option like command or package that deals with choosing a file. [file.choose()]
The error can not be reproduced and hence I can not expect someone gives reasonable comment on this. But if this occurred someone in the past and solved it, I would like to hear about it. Thanks.
EDIT 3: Further to the error. I have spotted just now sentence in red in Console: Error: Unable to provide connection with R