Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205423

Converting factor variables to numeric ones by replacing blanks cells to NA or changing them to "." [duplicate]

$
0
0

This question already has an answer here:

  1. I want to convert some factor variables to numeric variables by this code:

    df$col <- as.numeric(df$col)

  1. The missing values in my dataset are not represented by a dot (i.e., "."). Instead, they are blank cells.

  2. Therefore, the above code allocates a number (i.e., "1") to each blank cells in my dataset.

  3. My question is how I can convert factor variables to numeric ones by replacing blanks cells to NA or changing them to ".".

Thank you so much.


Viewing all articles
Browse latest Browse all 205423

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>