I working with some strings that is very messy as shown below
Value
-------------------
25
32.12 . (05-
33.90 ,
46.70 ,
() 26.60
27.2
23.24 . (12-
36.52 ,
27.1814404432133 [
29.73 . (22-
31.8058003525076 [
35.40 ,
38.44 .
46.14 ,
29.26 [
25.44 .
I am not sure how to clean this efficiently such that this looks like this.
Value
-------------------
25
32.12
33.90
46.70
26.60
27.2
23.24
36.52
27.1814404432133
29.73
31.8058003525076
35.40
38.44
46.14
29.26
25.44
I tried using sub function, sub(" .*", '', Value) to capture everything before space but that did not work, so looking for some suggestions or tips on how to clean this string.
Value <- c(" 25 \n", " 32.12 . (05-", "33.90 ,\n", "46.70 ,\n", " () 26.60 ",
" 27.2 ", " 23.24 . (12-", "36.52 ,\n", " 27.1814404432133\n\n[",
" 29.73 . (22-", " 31.8058003525076\n\n[", "35.40 ,\n", " 38.44 .\n",
"46.14 ,\n", " 29.26\n\n[", " 25.44 .\n")
df <- data.frame(Value)