Error input data must be numeric in R, how to solve it? (.txt)
1
0
Entering edit mode
9 months ago
n.emamijoo • 0

enter image description here

I have a problem, when I input data (.txt), and I want to perform x.cor<- cor(x) in R, I got an error: Error in cor(x) : 'x' must be numeric

my .txt data is like that:

R cor • 563 views
ADD COMMENT
0
Entering edit mode

How is this related to bioinformatics? This is a simple R error, did you try Googling the error message? Also, that data is not numeric.

ADD REPLY
0
Entering edit mode

my data are from Gene expressions in cells. and i want to calculate correlations of genes and create a pheatmap.

ADD REPLY
1
Entering edit mode
9 months ago
Ram 43k

What organism are these cells and what language is the data in?

EDIT: Some Googling showed me that this could possibly be Arabic numerals: https://www.softschools.com/languages/arabic/numbers_1_10_in_arabic/

You need the "English numeral" from the table in that page, not the Arabic part. Some more Googling got me to a StackOverflow answer with this R code:

persian <- "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9"
english <- "01234567890123456789"
persian.tonumber <- function(s) as.numeric(chartr(persian,english,s))

Once you run the above code, you can use the persian.tonumber function like you would any R function:

persian.tonumber("<your input here>")

See the linked post for a concrete example

ADD COMMENT

Login before adding your answer.

Traffic: 2473 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6