Need help !
I have a dataset with columns, Name of school, SAT scores of math, reading and writing.
The Name of school column has many rows of the school names and the other SAT score columns are with numbers. Some of the cells in the dataset has alphabet 's' instead of the number.
All the types of the columns are character.
My question is:
(1) How to change the columns of scores with numbers from character to numeric. (there are some alphabet 's' in the column without the aphostrophee).
(2) How to replace the alphabet to zero or blank. There are many cells with the alphabet in the dataset.
Something along the lines of
newColumn <- as.numeric(oldColumn) newColumn <- ifelse(is.na(newColumn),0,newColumn)
The first line converts characters to numeric. Cells that can't be converted become NA. The second line replaces NA with 0.
Thanks for your response.
By doing what you mentioned, it is showing that the alphabet s is double and value 0.
s double  0
What i need is the full dataset with all the alphabets to be replaced by zero or blank.
Post a Reproducible Example so that folks can see exactly what you're doing and a little about your data.
Sure, will do tomorrow morning
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.