R Assign (or copy) column classes from a data frame to another

前端 未结 1 386
星月不相逢
星月不相逢 2020-12-31 15:25

I produced a large data frame (1700+obs,159 variables) with a function that collects info from a website. Usually, the function finds numeric values for some columns, and th

相关标签:
1条回答
  • 2020-12-31 16:02

    You could try this:

    dfWrong[] <- mapply(FUN = as,dfWrong,sapply(dfCorrect,class),SIMPLIFY = FALSE)
    

    ...although my first instinct is to agree with Oliver that if it were me I'd try to ensure the correct class at the point you're reading the data.

    0 讨论(0)
提交回复
热议问题