摘要: 在R语言中使用正则表达式替换,可以使用sub()函数,用于全局替换则用gsub()函数。 1、例子 假设有一个字符串向量,需要将多字节文本过滤出来: >a<-c("abc\x9422",'女','男','女') 如果直接对其使用大小写转换函数toupper(),则会报错: > toupper(a) 阅读全文
posted @ 2015-10-26 14:37 hongweigg 阅读(81) 评论(0) 推荐(0)
摘要: 分组统计 1、假定有一组成绩数据,要求根据性别进行分组统计: > score ID score1 score2 Gender 1 101 11.35321 0.9 male 2 102 12.58654 0.6 male 3 103 19.79380 0.9 female 4 104 12.0135 阅读全文
posted @ 2015-10-26 09:36 hongweigg 阅读(34) 评论(0) 推荐(0)