daily function

1 : ifelse(expression,value1,value2)

2:select_(iris, .dots = list(quote(-Petal.Length), quote(-Petal.Width)))

select 和 select_ 

select

select(iris, starts_with("Petal"))

select(iris, ends_with("Width"))

select(iris, contains("etal"))

select(iris, matches(".t."))

select(iris, Petal.Length, Petal.Width)

可以通过各种方式定义想要筛选的列名

select_

Programming with select ---------------------------------------------------

select_(iris, ~Petal.Length)

select_(iris, "Petal.Length")

select_(iris, lazyeval::interp(~matches(x), x = ".t."))

select_(iris, quote(-Petal.Length), quote(-Petal.Width))

select_(iris, .dots = list(quote(-Petal.Length), quote(-Petal.Width)))

3:append()

1.如何往list某列末尾添加数据?

直接用append(某list,要写入的数据)

append(x, values, after = length(x))

Arguments

xthe vector to be modified.

valuesto be included in the modified vector.计划贴入的对象

aftera subscript, after which the values are to be appended.表示想在x中贴的位置

举例:

例一:

> L1

$p1

[1] 2 3 4 5

$p2

[1] 10 11 12 13 14 15

> append(L1$p1,13)

[1]  2  3  4  513

例二:

> append(1:5, 0:1,after = 3)

[1] 1 2 30 14 5


4:同样可以进行数据扩展的还有transmute()函数,与mutate()函数不同的是,该函数扩展新变量的同时,将删除所有原始变量。


dplyr

dplyr包的5个函数可以有效的执行数据处理的大部分任务,分别如下:

select:用于选取一列或者多列

filter:用于选取特定条件下的某些行

arrange:用于实现数据一列或多列的升降排序

mutate:用于在数据集中添加列

summarise:用于实现数据汇总

data.table

data.table包提供了一个非常简洁的通用格式:DT[i,j,by],可以理解为:对于数据集DT,选取子集行i,通过by分组计算j

颜色版

colorRampPalette(c("blue","white"))(10)

自定义色系,渐变色

gray(0:10/10)

你可能感兴趣的:(daily function)