I am trying to split a column into two separate ones when the divider is a dot.
Following this example, I have tried first:
library(tidyverse)
df1 <- data.frame(Sequence.Name= c(2.1, 2.1, 2.1),
var1 = c(1, 1, 0))
df1$Sequence.Name %>%
as.character %>%
str_split_fixed(".",2) %>%
head
#> [,1] [,2]
#> [1,] "" ".1"
#> [2,] "" ".1"
#> [3,] "" ".1"
Created on 2021-04-05 by the reprex package (v0.3.0)
But this is not what I want: the first column is empty, and the second one has still the dot.
Following the comments in the post I linked above, I tried to add fixed="."
or fixed=TRUE
, but it does not seem to work:
library(tidyverse)
df1 <- data.frame(Sequence.Name= c(2.1, 2.1, 2.1),
var1 = c(1, 1, 0))
df1$Sequence.Name %>%
as.character %>%
str_split_fixed(".",fixed=".",2) %>%
head
#> Error in str_split_fixed(., ".", fixed = ".", 2): unused argument (fixed = ".")
Created on 2021-04-05 by the reprex package (v0.3.0)