I am doing an essay for my PhD course, and I am having trouble with this question. I am going to send the part in which I have trouble and the whole thing.
dt
MC2 MC3
1: It was in INR None of the above
2: It was in INR None of the above
3: It was in INR None of the above
4: It was in INR None of the above
5: It was in INR None of the above
---
102: It was in USD (American Dollars) The foreigners were given a priority entry
103: It was in USD (American Dollars) The foreigners were given a priority entry
104: It was in USD (American Dollars) The foreigners were given a priority entry
105: It was in USD (American Dollars) The foreigners were given a priority entry
106: It was in USD (American Dollars) The foreigners were given a priority entry
MC2_dummy MC3_dummy PPU1 PPU2 PPU3
1: 0 0 7 7 6
2: 0 0 6 5 5
3: 0 0 7 6 7
4: 0 0 5 5 7
5: 0 0 5 5 5
---
102: 1 1 4 5 4
103: 1 1 6 5 6
104: 1 1 3 3 3
105: 1 1 4 3 4
106: 1 1 1 2 2
> typeof(dt$MC2)
[1] "character"
> typeof(dt$MC2_dummy)
[1] "character"
> typeof(dt$MC3_dummy)
[1] "character"
> typeof(dt$PPU1)
[1] "integer"
>
> typeof(dt$PPU2)
[1] "integer"
> typeof(dt$PPU3)
[1] "integer"
I tried this code:
dt = as.numeric(unlist(datatable))
Warning message:
NAs introduced by coercion
I tried also a lot of other potential ideas that I saw on youtube:
cor(dt[sapply(dt$MC2_dummy, dt$PPU1, is.numeric)])
Error: 'dt$PPU1' não é uma função, caracter ou símbolo
dt = as.numeric(datatable)
Error: 'list' object cannot be coerced to type 'double'
I am having trouble to convert this data into numeric. I am using data.table. Could someone help me?