Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个看起来像这样的字符串向量
x <- c("WDNTO","WDRN","WDSAX","WECAX","WEN","WEDTO")
我想要做的是只提取不超过 4 个字符的字符串,导致
WDNT,WDRN,WDSA,WECA,WEN,WEDT
有什么办法呢?
substr(x,1,4) ?substr
我对SO的第一个回答!
使用substr,例如
substr
substr(x, 1, 4)