Question: In this testFrame, the first four columns are read as factors by R. You would like to transform these values to numeric (instead of factor)

In this testFrame, the first four columns are read as factors byIn this testFrame, the first four columns are read as factors by R. You would like to transform these values to numeric (instead of factor) so that you can conduct mathematical calculation. You decided to use as.numeric function for it. However, when you use as.numeric function, you will find that it does not work properly. Which of the following is an incorrect statement on this situation?

In this testFrame, the first four columns are read as factors by R. You would like to transform these values to numeric (instead of factor) so that you can conduct mathematical calculation. You decided to use as.numeric function for it. However, when you use as.numeric function, you will find that it does not work properly. Which of the following is an incorrect statement on this situation? It's because the values are factors, which does not allow mathematical calculation. You must drop commas from the value before applying as.numeric function. We can use gsub function in the process of solving the issue. R automatically recognize commas as part of numbers, so applying as.numeric will transform factors to the same value numbers. For example, factor 4,000 will be transformed to numeric value 4000 by using as.numeric function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The incorrect statement is R automatically recognize commas as part of numbers so applying asnumeri... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!