ASCII files in R - r

I have some data that's in an ASCII format. I'm not allowed to put the data online so unfortunately I can't post it on here (although I realize that it would be the most helpful that way). The code I'm using now to get the ASCII data in R is...
library(SAScii)
parse.SAScii("file.txt")
But then I get this error:
Error in firstline:lastline : NA/NaN argument
In addition: Warning message:
In min(a[a > firstline]) : no non-missing arguments to min; returning Inf
I can't find anything online about this error and I was hoping someone might be able to point me to what I could be doing wrong. I know this question is kind of vague but I'm just hoping someone can direct me in the right direction.

Try this to read lines from a file with that name in the working directory:
my.input <- readLines("file.txt")
head(my.input)
str(my.input)

Related

Warning message within R function seems to make the function not work?

Using the syuzhet package in R, the following works but returns a warning message:
object <- get_text_as_string("path/name.txt")
When I put this in a function, it returns the same warning error but does NOT change the value of object:
gen <- function(file){
object <- get_text_as_string(file)
}
gen("path/name.txt")
This is the warning message, if it matters:
Warning message:
In readLines(path_to_file) :
incomplete final line found on 'path/name.txt'
...but again, I get that from get_text_as_string() when used outside of the function, but it DOES change the value of object.
Anyone have any advice? There must be something I don't understand about functions?
(I've looked for similar questions/answers, if I've missed the right one I'd be happy to just be directed there.)

Error in validityMethod(as(object, superClass)) : object 'Matrix_validate' not found

I just try to use :
scRNA <- FindNeighbors(scRNA, dims = pc.num)
and
scRNA.counts <- Read10X(data.dir = "filtered_feature_bc_matrix")
and both of them gives error like :
Error in validityMethod(as(object, superClass)) : object 'Matrix_validate' not found
I guess these code totally run well in other's computer
so I wonder what's wrong with my code and how to fix it ?
Indeed, to solve the problem for you, it should be sufficient to do what #Mikael Jagan says:
update.packages("Matrix")
2nd thought: The above may not solve the problem entirely:
As there are other packages involved, some of these may have to be re-installed (after the updating of Matrix).
Can you post the output (or good summary of that if it's too long) of
traceback()
immediately after producing the error you are seeing?

Error msg in R: Error in unlist_as_integer(x#subscript) : object 'fancy_mseq' not found

I am reading 2 vcf files in to R. They load fine (I have used 3 different methods to do this (read.vcf, readVCF, and fread) and all are fine) however when I go on to try and do anything with 1 of the vcf files, the msg reads:
Error in unlist_as_integer(x#subscript) : object 'fancy_mseq' not found
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'from': object 'fancy_mseq' not found
Usually I just google error msgs but I can not find anything online about this. Does anyone have any idea what could be causing this error message? Whilst it's hard to be 100% sure because of the vcf format, I can't see anything wrong with the file when I call str(), head() or any other ways of looking at the data.
Thank you!

Error in rgdal::OSRIsProjected(obj) : Can't parse user input string

I have a SpatialPolygonsDataFrame dataset called election which includes US County polygons and some attributes. I tried to summary this dataset. But there is an error.
summary(election)
Error in rgdal::OSRIsProjected(obj) : Can't parse user input string
In addition: Warning message: In wkt(obj) : CRS object has no comment
The same error also occur when I plot(election).
No error generated when I name(election) and head(election).
I know this is late, and hopefully you will have found a solution by now, but I ran across the same issue on what I assume is the same dataset/shapefile, so I'm adding this in case anyone comes across the same problem.
Getting the error:
Error in rgdal::OSRIsProjected(obj) : Can't parse user input string
In addition: Warning message:
In wkt(obj) : CRS object has no comment
usually means that the CRS (proj4string for sp objects), or some other aspect of the spdf is invalid. In this case, it actually seems to just be a simple typo; there's just a missing space.
The proj4string, +proj=lcc+lon_0=90w +lat_1=20n +lat_2=60n
should be, +proj=lcc +lon_0=90w +lat_1=20n +lat_2=60n
Note the missing space between "lcc" and "+lon_0=90w"!
However, using proj4string(x)<- fails, again because the p4s is invalid, but we can set the argument manually with
election#proj4string#projargs <- "+proj=lcc +lon_0=90w +lat_1=20n +lat_2=60n"
Hope this helps anyone who seems to have this issue! I've noticed all the issues come from presumably the same dataset.
Best,

Pasted bulk textual data into a CSV file for text mining in R. But I get a strwidth error saying invalid 'cex' value

I've copied the text from various emails that I wrote to a friend in order to perform text mining and see how the wordcloud would result in. (packages used are tm and wordcloud). But when I tried dump the data into a csv file and called the column "letter_text":
df <- read.csv("Letter_Text.csv")
letter_text <- Corpus(VectorSource(df$letter_text))
I got the following error on running wordcloud(letter_text) command on it:
Error in strwidth(words[i], cex = size[i], ...) : invalid 'cex' value
In addition: Warning messages:
1: In max(freq) : no non-missing arguments to max; returning -Inf
2: In max(freq) : no non-missing arguments to max; returning -Inf
I thought maybe I'm exceeding the character length of a CSV cell. So, I dumped the data into a text file. df <- read.table("Letter_Text.txt")
And I still get the same error.
Something tells me that I'm doing a mistake in creating the dataset for mining the textual data of my emails. How do I resolve this error? Or better is there a particular way to create a dataset for Text Mining with your own data?
Please help!
Thanks.

Resources