a column(variable) in a data frame is also 'data.frame',how to change it into int or numeric?
‘str(data)’ to browse the data frame and found one variable is a ‘data.frame’, how can I change it into a normal vector/variable? Because now it cannot be exported correctly.
str(data) $ ID : num [1:3177] 1.11e+11 1.11e+11 1.11e+11 1.11e+11 $ indcate :'data.frame': 3177 obs. of 1 variable: ..$ X: int [1:3177] 2 3 3 2 2 2 3 2 1 1 ...
(1)so I tried to change the type of this variable but failed
> as.numeric((data$indcate)) Error: 'list' object cannot be coerced to type 'double' > as.integer((data$indcate)) Error: 'list' object cannot be coerced to type 'integer' > as.factor((data$indcate)) X <NA> Levels: c(2, 3, 1) Warning message: In xtfrm.data.frame(x) : cannot xtfrm data frames
(2)here is the export file, I export it as csv.file. There are some redundant columns behind.
Not sure I’ve totally understood but I think the issue is that your item is currently a list. You should be able to resolve it by adding
unlist() to your code:
Answered By – anonymous2