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某列末尾添加數(shù)據(jù)?

直接用append(某list,要寫入的數(shù)據(jù))

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

Arguments

xthe vector to be modified.

valuesto be included in the modified vector.計(jì)劃貼入的對象

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:同樣可以進(jìn)行數(shù)據(jù)擴(kuò)展的還有transmute()函數(shù),與mutate()函數(shù)不同的是,該函數(shù)擴(kuò)展新變量的同時(shí),將刪除所有原始變量。


dplyr

dplyr包的5個(gè)函數(shù)可以有效的執(zhí)行數(shù)據(jù)處理的大部分任務(wù),分別如下:

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

filter:用于選取特定條件下的某些行

arrange:用于實(shí)現(xiàn)數(shù)據(jù)一列或多列的升降排序

mutate:用于在數(shù)據(jù)集中添加列

summarise:用于實(shí)現(xiàn)數(shù)據(jù)匯總

data.table

data.table包提供了一個(gè)非常簡潔的通用格式:DT[i,j,by],可以理解為:對于數(shù)據(jù)集DT,選取子集行i,通過by分組計(jì)算j

顏色版

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

自定義色系,漸變色

gray(0:10/10)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容