Question: error in running R
0
gravatar for F
3.8 years ago by
F3.4k
Iran
F3.4k wrote:

sorry,

how i can make my datasets numeric?

mim <- build.mim(mycounts,estimator="spearman")
Error in cor(dataset, method = estimator, use = "complete.obs") : 
  'x' must be numeric

 

R software error • 1.9k views
ADD COMMENTlink modified 3.6 years ago • written 3.8 years ago by F3.4k
1
gravatar for F
3.6 years ago by
F3.4k
Iran
F3.4k wrote:

I did like below

# read as matrix
as.matrix(mycounts)
# viewing mycounts class
class(mycounts)
# setting as numeric
sapply(mycounts, class)
ADD COMMENTlink modified 8 weeks ago by RamRS23k • written 3.6 years ago by F3.4k
3
gravatar for apelin20
3.8 years ago by
apelin20470
Canada
apelin20470 wrote:
head(mycounts)

output please. Try

mim <- build.mim(as.numeric(mycounts),estimator="spearman")
ADD COMMENTlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by apelin20470
3
gravatar for Shicheng Guo
3.8 years ago by
Shicheng Guo7.7k
Shicheng Guo7.7k wrote:
mim <- build.mim(data.matrix(mycounts),estimator="spearman")
ADD COMMENTlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by Shicheng Guo7.7k
1
gravatar for ebrown1955
3.8 years ago by
ebrown1955300
United States
ebrown1955300 wrote:

Do you have row/column names in mycounts? If so, change these to headers and row.names.

Otherwise, try:

as.numeric(mycounts)

instead of just mycounts as suggested above.

ADD COMMENTlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by ebrown1955300

thank you,

I tried,

mycounts <- as.matrix(read.table("file.txt", sep="\t", header=TRUE))

then

res_aracne <- build.mim(mycounts,estimator = "spearman")

also

mim <- build.mim(as.numeric(mycounts),estimator="spearman")

and

mim <- build.mim(data.matrix(mycounts),estimator="spearman")
as.numeric(mycounts)

but all the same error

ADD REPLYlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by F3.4k

Can you provide the output of:

head(mycounts)

So we can see what R is seeing?

ADD REPLYlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by ebrown1955300

thank u

ADD REPLYlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by F3.4k

These values include alphanumeric characters. This function only accepts numbers. You can only input a dataset of numeric values.

ADD REPLYlink written 3.8 years ago by ebrown1955300

 these are rows name

ADD REPLYlink written 3.8 years ago by F3.4k

exactly. so what's the result of

dim(my counts)
ADD REPLYlink modified 8 weeks ago by RamRS23k • written 3.8 years ago by andrew.j.skelton735.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1580 users visited in the last hour