Joachim, Thanks for another great video.
I was fiddling with a messy dataframe that had a lot of variables in the wrong format - lots of numeric cols in char format and I thought drat this will take some time to convert but then I ran across a package called "hablar". It is based on dplyr (hence the pipe works) so perhaps another addition to the tidyverse. Long story short. This package has a function called "convert()" that can change a lot of variables in single line of code - for instance to change the following columns to char, int and dbl:
convert(chr(x, y, z), int(w, t, q), dbl(s, r, p)) - just amazingly simple. I think it even accepts : or
a:d or a continuous range of columns. Check it out.
haraldurkarlsson
interesting! thank you for the alert!. if u have categorical data that you then coded them with numbers. would u convert them into factors or (charachter> numeric)?
ahmedJaber
i have daily time 01/01/2008 as factor and its a data frame when i convert that column i get this error
NAs introduced by coercion
the column date change to NA all of them could you please let me know how to solve it?
Would this work too? first, we can index the levels of x_fac_to_num which produces a character output of the actual contents of the input vector for which we can then convert that to numeric using as.numeric function...is it the same thing ? What's the difference? Also, why does using the vector to index factor levels produce the correct output of the vector instead of the levels?
SanaKhan-wlbf
You make great videos unfortunately the sound is not good enough some videos you made perviously have echoes. This one low sound. I hope you will fix this. Keep up the hard work.
da_ta
Hello, sometimes I get the following error message: 'list' object cannot be coerced to type 'double'...what does that mean? I have a data set/dataframe full with numeric variables, but after replacing missing values with the median of each column, the type of the columns changes from numeric to character. Now I want to change it back to numeric, but get this weird error message. What can I do? Additional info: The last column is a binary outcome (0 and 1) which obviously has to be a factor, if I want it to use Logistic Regression etc.
borknagarpopinga
extremely useful video, thanks a lot!
jakubkaczynski
Hi, Thank you very much. I got this message" Warning message:
NAs introduced by coercion "
what sould I do, please?
alialchawa
thank you it's so useful but I have a question
what are the situations in which I need to change the type of variables in Rstudio?
MsMoooooni
Hey, Thanks for the amazing content .I have a Date column in my dataset in chr format how do I convert the whole Date column in my data to numeric format? If you could give me the syntax for it, it would be great! Thanks in advance
nidanaaz
if a decimal is converted from factor?
devilliersduplessis
If I have data in the form of "0-9", "10-20", 20-30", ">80" and so on, how do I convert it into numeric?