search for: fix_colnam

Displaying 3 results from an estimated 3 matches for "fix_colnam".

Did you mean: fix_colnames
2024 Jul 22
3
Extract
...e need to break the pipeline into two or that we need to find another approach which is what we do here. We can use the base R code below. Note that the column names produced by transform(S = read.table(...)) are S.V1, S.V2, etc. so to fix the column names remove .V from all column names as in the fix_colnames function shown. It does no harm to apply that to all column names since the remaining column names will not match. fix_colnames <- function(x) { setNames(x, sub("\\.V", "", names(x))) } dat |> transform(S = read.table(text = string, header = FALSE...
2024 Jul 22
1
Extract
...line into two or that we need to find another > approach which is what we do here. > > We can use the base R code below. Note that the column names produced > by transform(S = read.table(...)) are S.V1, S.V2, etc. so to fix the > column names remove .V from all column names as in the fix_colnames > function shown. It does no harm to apply that to all column names > since the remaining column names will not match. > > fix_colnames <- function(x) { > setNames(x, sub("\\.V", "", names(x))) > } > > dat |> > transform(S = read...
2024 Jul 21
1
Extract
As always, good point. Here's a piped version of your code for those who are pipe afficianados. As I'm not very skilled with pipes, it might certainly be improved. dat <- dat$string |> read.table( text = _, fill = TRUE, header = FALSE, na.strings = "") |> (\(x)'names<-'(x,paste0("s", seq_along(x))))() |>