#字符串的替换
str_replace(str,"o","O")
str_replace_all(str,"o","O")
#删除字符串中的字符
str_remove(str," ")
str_remove_all...(str," ")
输出结果:
图片
数据框的处理-dplyr
library(dplyr)
head(iris,5)
#将内部数据iris所有列按Sepal.Length列的数值从小到大排列
head...)),5)
#去除重复的Species列内容
head(arrange(iris,Species,.keep_all = T),5)
#筛选Sepal.Width大于3的行
head(filter(iris...,Sepal.Width>3),5)
#筛选出Sepal.Length和Sepal.Width列
head(select(iris,Sepal.Length,Sepal.Width),5)
#管道符可以将上一函数的输出...图片
MARGIN参数,1表示针对列,2表示针对行
FUN参数,可使用任何函数,包括自定义的函数
data=iris[1:5,1:4]
data
#计算每一列的加和
apply(data,1,sum)