Data Type Conversion in R (2 Examples) | Convert Character & Factor to Numeric Class

Pubblicato il: 26 luglio 2019
sul canale di: Statistics Globe
26,201
162

How to convert characters and factors to numeric in R. More details in these tutorials: https://statisticsglobe.com/convert-c...
https://statisticsglobe.com/how-to-co...
https://statisticsglobe.com/convert-d...

R syntax of this video:

Example 1 - Character to Numeric

x_char <- as.character(c(8, 4, 6, 4, 6, 5)) # Example data

x_char_to_num <- as.numeric(x_char) # Convert to numeric


Example 2 - Factor to Numeric

x_fac <- as.factor(c(8, 4, 6, 4, 6, 5)) # Example data

x_fac_to_num <- as.numeric(x_fac) # Wrong!! Be careful!
x_fac_to_num <- as.numeric(as.character(x_fac)) # Correct


In questa pagina del sito puoi guardare il video online Data Type Conversion in R (2 Examples) | Convert Character & Factor to Numeric Class della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Statistics Globe 26 luglio 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 26,201 volte e gli è piaciuto 162 spettatori. Buona visione!