This is a test version of Biostars. For the public version, visit https://www.biostars.org.
error in running R

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

4 answers

I did like below

# read as matrix
as.matrix(mycounts)
# viewing mycounts class
class(mycounts)
# setting as numeric
sapply(mycounts, class)
head(mycounts)

output please. Try

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

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.

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

Can you provide the output of:

head(mycounts)

So we can see what R is seeing?

thank u

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

these are rows name

exactly. so what's the result of

dim(my counts)

Log in to answer this question.