What does this code means in R? full$Title <- gsub('(.*, )|(\..*)', '', full$Name) [closed]

Multi tool use
```r, message=FALSE, warning=FALSE
# Grab title from passenger names
full$Title <- gsub('(.*, )|(\..*)', '', full$Name)
# Show title counts by sex
table(full$Sex, full$Title)
r feature-engineering
closed as unclear what you're asking by Roland, Rui Barradas, Makyen, MLavoie, camille Nov 16 '18 at 0:00
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
```r, message=FALSE, warning=FALSE
# Grab title from passenger names
full$Title <- gsub('(.*, )|(\..*)', '', full$Name)
# Show title counts by sex
table(full$Sex, full$Title)
r feature-engineering
closed as unclear what you're asking by Roland, Rui Barradas, Makyen, MLavoie, camille Nov 16 '18 at 0:00
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
See?regex
.
– Rui Barradas
Nov 15 '18 at 7:13
add a comment |
```r, message=FALSE, warning=FALSE
# Grab title from passenger names
full$Title <- gsub('(.*, )|(\..*)', '', full$Name)
# Show title counts by sex
table(full$Sex, full$Title)
r feature-engineering
```r, message=FALSE, warning=FALSE
# Grab title from passenger names
full$Title <- gsub('(.*, )|(\..*)', '', full$Name)
# Show title counts by sex
table(full$Sex, full$Title)
r feature-engineering
r feature-engineering
edited Nov 15 '18 at 6:58


Roland
101k6112189
101k6112189
asked Nov 15 '18 at 6:20


siddharth inglesiddharth ingle
1
1
closed as unclear what you're asking by Roland, Rui Barradas, Makyen, MLavoie, camille Nov 16 '18 at 0:00
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Roland, Rui Barradas, Makyen, MLavoie, camille Nov 16 '18 at 0:00
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
See?regex
.
– Rui Barradas
Nov 15 '18 at 7:13
add a comment |
See?regex
.
– Rui Barradas
Nov 15 '18 at 7:13
See
?regex
.– Rui Barradas
Nov 15 '18 at 7:13
See
?regex
.– Rui Barradas
Nov 15 '18 at 7:13
add a comment |
1 Answer
1
active
oldest
votes
(.*, )
-> means any text before and including a comma and space. It will match "test, " in "test, dummy"
(\..*)
-> means anything after and including a dot. It will match ".dummy" in "test.dummy"
(.*, )|(\..*)
-> means matching first OR second pattern
So it will transform something like "test, dummy.something" into "dummy" by replacing matched text with ""
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
(.*, )
-> means any text before and including a comma and space. It will match "test, " in "test, dummy"
(\..*)
-> means anything after and including a dot. It will match ".dummy" in "test.dummy"
(.*, )|(\..*)
-> means matching first OR second pattern
So it will transform something like "test, dummy.something" into "dummy" by replacing matched text with ""
add a comment |
(.*, )
-> means any text before and including a comma and space. It will match "test, " in "test, dummy"
(\..*)
-> means anything after and including a dot. It will match ".dummy" in "test.dummy"
(.*, )|(\..*)
-> means matching first OR second pattern
So it will transform something like "test, dummy.something" into "dummy" by replacing matched text with ""
add a comment |
(.*, )
-> means any text before and including a comma and space. It will match "test, " in "test, dummy"
(\..*)
-> means anything after and including a dot. It will match ".dummy" in "test.dummy"
(.*, )|(\..*)
-> means matching first OR second pattern
So it will transform something like "test, dummy.something" into "dummy" by replacing matched text with ""
(.*, )
-> means any text before and including a comma and space. It will match "test, " in "test, dummy"
(\..*)
-> means anything after and including a dot. It will match ".dummy" in "test.dummy"
(.*, )|(\..*)
-> means matching first OR second pattern
So it will transform something like "test, dummy.something" into "dummy" by replacing matched text with ""
edited Nov 15 '18 at 12:17
answered Nov 15 '18 at 12:12
Billy34Billy34
22615
22615
add a comment |
add a comment |
7M8b0JYzYg9e ZdX4DrYB,7,s1eizBd4MUxIx 7tip MUgAEIrkpEo53 rapThXV kOlb,bHI9qSln hjWN L,H
See
?regex
.– Rui Barradas
Nov 15 '18 at 7:13