Now that we've acquired the data and learned a little about what the fields mean, the next step is to clean up the data and conduct some exploratory analysis.
Make sure you have the packages mentioned at the beginning of this chapter under the Requirements section installed and you have successfully imported the FINVIZ
data into R using the steps in the previous sections.
To clean and explore the data, closely follow the ensuing instructions:
- Imported numeric data often contains special characters such as percentage signs, dollar signs, commas, and so on. This causes R to think that the field is a character field instead of a numeric field. For example, our
FINVIZ
dataset contains numerous values with percentage signs that must be removed. To do this, we will create aclean_numeric
function that will strip away any unwanted characters using thegsub
command. We will create this function once and then use it multiple times throughout...