- string
- grep("Pole",c("Equator","North Pole","South Pole"))
- 2 3
- grep("pole",c("Equator","North Pole","South Pole"))
- integer(0)
- nchar("South Pole")
- 10
- paste("North","Pole",sep="")
- "NorthPole"
- i<-8
- sprintf("the square of %d is %d",i,i^2) # format print
- substring("Equator",3,5) # "uat"
- strsplit("6-16-2011",split="-")
- [[1]]
- "6" "16" "2011"
- regexpr("uat","Equator")
- 3
- grepexpr("iss","Mississippi")
- 2 5 # find all occurrances
- grep("[au]",c("Equator","North Pole","South Pole"))
- 1 3 # word contains a or u
- grep("o.e",c("Equator","North Pole","South Pole"))
- 2 3 # word contains o+any char+e
- grep("\\.",c("abc","de","f.g")) # escape
- 3
- testsuffix<-function(fn,suff) {
- parts<-strsplit(fn,".",fixed=TRUE) # or strsplit(fn,"\\.")
- nparts<-length(parts[[1]]) # split length
- return(parts[[1]][nparts]==suff)
- }
R语言学习笔记10-字符串篇
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 在挖掘分析的过程当中对字符串的处理是极为重要的,且出现也较为频繁,R语言作为当前最为流行的开源数据分析和可视化平台...