search for: dat_separated

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

2024 Jul 19
1
Extract
...d numeric data. The string is not duplicated. library(tidyr) dat <- read.csv(text="Year,Sex,string 2002,F,15 xc Ab 2003,F,14 2004,M,18 xb 25 35 21 2005,M,13 25 2006,M,14 ac 256 AV 35 2007,F,11", header=TRUE, stringsAsFactors=FALSE) # split the 'string' column based on spaces dat_separated <- dat |> separate(string, into = paste0("S", 1:5), sep = " ", fill = "right", extra = "merge") Tim -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Val Sent: Friday, July 19, 2024 12:52 PM To:...
2024 Jul 19
1
Extract
...y(tidyr) > > dat <- read.csv(text="Year,Sex,string > 2002,F,15 xc Ab > 2003,F,14 > 2004,M,18 xb 25 35 21 > 2005,M,13 25 > 2006,M,14 ac 256 AV 35 > 2007,F,11", header=TRUE, stringsAsFactors=FALSE) > > # split the 'string' column based on spaces > dat_separated <- dat |> > separate(string, into = paste0("S", 1:5), sep = " ", > fill = "right", extra = "merge") > > Tim > > > -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of Val &gt...
2024 Jul 19
4
Extract
Hi All, I want to extract new variables from a string and add it to the dataframe. Sample data is csv file. dat<-read.csv(text="Year, Sex,string 2002,F,15 xc Ab 2003,F,14 2004,M,18 xb 25 35 21 2005,M,13 25 2006,M,14 ac 256 AV 35 2007,F,11",header=TRUE) The string column has a maximum of five variables. Some rows have all and others may not have all the five variables. If missing