I am working with the R programming language.
Suppose I have the following data:
a = c("12234.2434", "gg.546", "45657herg.6657767")
b = a
my_data = data.frame(a,b)
I am trying to create a new variable "c" that contains the first two "entries" before the decimal point and the first two "entries" after the decimal point. If done correctly, this would look something like this: 34.243, gg.546, rg.665
a b c
1 12234.2434 12234.2434 34.243
2 gg.546 gg.546 gg.546
3 45657herg.6657767 45657herg.6657767 rg.665
Normally, I would have done this using the substr() function in R - but since the numbers are of different length, the decimal point can be in different positions, thus making the substr() function not very useful in this case.
I know how to solve this problem in Microsoft Excel by using the "text to columns" and "delimited" option by specifying "fixed width delimitation" with the "decimal point" - but I am trying to do this in R using the "dplyr" library.
Can someone please show me how to do this?
Thanks!