How to turn all values of a data.frame into numeric?

Asked

Viewed 69 times

-2

I imported a database into R and when executing t() function to transpose rows and columns, all values that should be numerical were transformed into factor!

How could I turn all the values of all the columns into numerical? I can transform column by column, but in this case I have 5570 columns and all need to be transformed into numerical..

Any simple solution? I prefer to use tidyverse.

  • 1

    Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please take a look at this link (mainly in the use of function dput) and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.

  • when performing function t(): Do not do this to a date frame..

1 answer

-1


Three things: first, t() is not recommended for a data.frame. Second, when it matters, put the argument stringsAsFactors = FALSE in the read.csv(). Third, try to use as.numeric() in everything. I imagine it will work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.