i'm starting deal with R, and i face this problem: i prepared a data table on excel then export as a CSV on R i use the formula read.csv2 after i set the data frame tryinf to exlude the first column with the name of the country.
i would like to plot and do the PC analisys but i'm stuck in the non-numerical argument problem. how can i handle it? or find a possible non-numerical factor? the error is:
pairs(dati) Error in pairs.default(dati) : non-numeric argument to 'pairs'
update:
str(dati) 'data.frame': 184 obs. of 6 variables: $ Political Stability and Absence of Violence/Terrorism: chr "1.17" "-2.41" "-2.06" "-0.33" ... $ Government Effectiveness : chr "1.41" "-2.18" "-0.86" "-0.69" ... $ Voice and Accountability : chr "1.56" "-1.91" "-1.58" "-0.65" ... $ Rule of Law : chr "1.16" "-1.79" "-1.63" "-0.68" ... $ Regulatory Quality : chr "1.27" "-2.09" "-1.42" "-0.47" ... $ Control of Corruption : chr "1.32" "-1.29" "-1.17" "-0.89" ...
CodePudding user response:
pairs
is failing because your data frame only has character columns.
We can try fixing this using type.convert()
which will convert all the character columns to the appropriate class.
dati2 <- type.convert(dati, as.is = TRUE)
pairs(dati2)