Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

r - Split first 10 characters of a string using CSPLIT


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use sub here for a base R option:

input = "Table 1.1. Patient Completion Summary"
table_name <- sub("^.*\b(Table \d+(?:\.\d+)*).*$", "\1", input)
table_name

[1] "Table 1.1"

This answer is flexible and makes no assumptions about the table name, other than it be some number, followed by optional dot separator and digit, zero or more times over.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...