Search code examples
rdataframenumericfactors

Dataframe convert factors to numerical error


I am trying to convert factors from a data-frame to numeric using the commands

data[] <- lapply (data, function(x) as.numeric(as.character(x))

But it keeps asking me for more coding. What am I doing wrong? The data-frame is named data and it consists of 50 rows and 2 columns. Will this command change every variable in numeric right? Or shall I do something else?

screenshot after using 'dput' at https://i.sstatic.net/5IJZN.png


Solution

  • Shouldn't you add ) at the end of your code?