I have a data frame like this:
name weight r apple 0.5 y pear 0.4 y cherry 0.1 g watermelon 5.0 pp grape 0.5 y apple pear 0.4 ... ...
I would like to remove all characters before the first space in the name column. Can someone do me a favor? Thanks!
Try the following:
sub(".*? (.+)", "\\1", D$name)
If D is your data frame, try
D
sub(".+? ", "", D$name)
Say your data frame is called 'df'
library(reshape2) df$name = colsplit(df$name," ", names = c("chuck","name"))[,2]
Source: https://habr.com/ru/post/1232206/More articles:jquery input hidden value fails - javascriptStoring a List as JSON in a Text Box with Hibernate - hibernateHow to select individual records for two columns with a join? - sqliOS 9 changed view loading mode - iosThe fastest way to determine the most common factor in a grouped data frame in dplyr - performanceHow to open the Blank App (XAML) in today's visual studio? - C # - c #javascript Unable to get property value 'w90> or null reference - javascriptevent.clipboardData.getData has no text / html in Safari - javascriptto find a set of column indices for nonzero values โโin each row in pandas' data frame - pythonMEMSQL and MySQL - mysqlAll Articles