I dont have much knowledge in R. I have a .txt file with a correlation matrix which was previously created from long records.
the text there in the file looks something like:
"15075060" "15085030" "15085040"
"15075060" 1 0.441716695007761 0.433807683928689
"15085030" 0.441716695007761 1 0.477591938543259
"15085040" 0.433807683928689 0.477591938543259 1
This is a representative example because the real matrix is much bigger. The numbers in the quotation marks are the sources that were correlated. I read the data using read.table to create a data frame and then i convert it into a matrix (called matto) with:
mattox =matrix(as.numeric(unlist(matto)),nrow=nrow(matto))
and I obtain a matrix like this:
>mattox
[,1] [,2] [,3]
[1,] 1.0000000 0.4417167 0.4338077
[2,] 0.4417167 1.0000000 0.4775919
[3,] 0.4338077 0.4775919 1.0000000
as an option 2, if I convert it into a matrix using:
as.matrix(sapply(matto, as.numeric))
then i obtain a matrix like this:
> matto
X.15075060 X.15085030 X.15085040
15075060 1.0000000 0.4417167 0.4338077
15085030 0.4417167 1.0000000 0.4775919
15085040 0.4338077 0.4775919 1.0000000
although I dont know why I get those X before the numbers at the column heads
when I try to plot this correlations using the function corrplot i obtain something like this for the matrix mattox:
corrplot(mattox, type="upper")
but the problem is that i dont see here the head names of the columns and rows (numbers in quotation marks from the .txt file). And for the other matrix (matto) i obtain an error when i try to use corrplot, the error says:
Error in matrix(if (is.null(value)) logical() else value, nrow = nr, dimnames = list(rn, :
length of 'dimnames' [2] not equal to array extent
I would like to obtain a graphic just like the one I obtained but with the names of columns and rows instead of numbers 1,2,3... something like the next graph, which I found online for othe case:
how can I fix this?