trimSpace(seqinr)
trimSpace()所属R语言包:seqinr
Trim leading and/or trailing spaces in strings
修剪引导和/或尾随空格的字符串
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function removes from a character vector the longest successive run of space characters starting at the begining of the strings (leading space), or the longest successive run of space characters at the end of the strings (trailing space), or both (and this is the default behaviour).
该函数将一个字符向量的连续运行时间最长的空白字符从期初的字符串(前导空格),或连续运行时间最长的空格字符结束的字符串(空格),或两者(这是默认行为)。
用法----------Usage----------
trimSpace(x, leading = TRUE, trailing = TRUE, space = "[:space:]")
参数----------Arguments----------
参数:x
a character vector
字符向量
参数:leading
logical defaulting to TRUE: should leading spaces be trimed off?
逻辑默认为TRUE:应领先的的空间被trimed关闭?
参数:trailing
logical defaulting to TRUE: should trailing spaces be trimed off?
逻辑默认为TRUE:尾随空格trimed了吗?
参数:space
an extended regular expression defining space characters
扩展正则表达式定义的空格字符
Details
详细信息----------Details----------
The default value for the space character definition is large: in addition to the usual space, other character such as the tabulation and newline character are considered as space characters. See extended regular expression for a complete list.
空格字符定义的默认值是巨大的:除了通常的空间,被认为是其他字符,如制表符和换行符的字符空格字符。扩展正则表达式的完整列表。
值----------Value----------
a character vector with the same length as x.
一个字符的矢量具有相同的长度为x。
(作者)----------Author(s)----------
J.R. Lobry
参考文献----------References----------
参见----------See Also----------
Extended regular expressionsare described in regular expression (aka regexp).
扩展定期expressionsare正则表达式(又名regexp)。
实例----------Examples----------
#[]
# Simple use:[使用简单:]
#[]
stopifnot( trimSpace(" seqinR ") == "seqinR" )
#[]
# Basic use, remove space at both ends:[基本使用,除去两端的空间:]
#[]
testspace <- c(" with leading space", "with trailing space ", " with both ")
stopifnot(all( trimSpace(testspace) == c("with leading space", "with trailing space", "with both")))
#[]
# Remove only leading space:[仅删除前导空格:]
#[]
stopifnot(all( trimSpace(testspace, trailing = FALSE) == c("with leading space", "with trailing space ", "with both ")))
#[]
# Remove only trailing space:[仅删除尾随空格:]
#[]
stopifnot(all( trimSpace(testspace, leading = FALSE) == c(" with leading space", "with trailing space", " with both")))
#[]
# This should do nothing:[这应该什么都不做:]
#[]
stopifnot(all( trimSpace(testspace, leading = FALSE, trailing = FALSE) == testspace))
#[]
# How to use alternative space characters:[如何使用替代空格字符:]
#[]
allspaces <- "\t\n\f\r seqinR \t\n\f\r"
stopifnot(trimSpace(allspaces) == "seqinR")
stopifnot(trimSpace(allspaces, space = "\t\n") == "\f\r seqinR \t\n\f\r")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|