r - Extract Characters/String before Space from a factor data type column -


this question has answer here:

i have r data frame in 1 column has factor data type text in column. want extract string column considering text before space. tried gsub( " .*$", "", data[, 3] ),where summary field.but not working. example: data "abcd efgh ijk" & want "abcd" tried convert factor field character field using

data[, 3] <- sapply(data[, 3], as.character) 

but it's failed retrieve string before first space. can please help?

sorry can't able put data here client data

or

 x <- "abcd efgh ijk"  strsplit(x, " ")[[1]][1] 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -