I'm working on a project for uni and I am trying to calculate relatedness between different products and industries. I have created an matrix in excel, which has the export from European countries per HS2 code. I converted this to a csv file and tried to import it to R. However, R reads it as characters instead of numeric, which I need to calculate. I have searched for many answers and tried multiple things, however nothing seems to work. Hopefully somebody can help me out! I used
str(data,class)
And indeed, all of my columns are read as chr instead of int
The code I used to import my data is
data=read.csv("matrixproject.csv",sep=";",row.names=1,header=T)
matrix=as.matrix(data)
I have tried to use the following code
data_num <- as.data.frame(apply(data, 2, as.numeric))
However this changes all my values to NA, so it does not help. Does anyone have any idea how to change this? As I can not do any further work on my project until this is solved. Thank you in advance!