將對象通過管道轉發到函數或調用表達式中,並使用結果值更新 lhs
對象。
細節
賦值管道 %<>%
用於更新值,方法是首先將值通過管道傳輸到一個或多個 rhs
表達式中,然後分配結果。例如, some_object %<>%
foo %>% bar
相當於 some_object <- some_object %>% foo
%>% bar
。它必須是鏈中的第一個 pipe-operator ,但否則它的工作方式類似於 %>%
。
也可以看看
%>%
, %T>%
, %$%
例子
iris$Sepal.Length %<>% sqrt
x <- rnorm(100)
x %<>% abs %>% sort
is_weekend <- function(day)
{
# day could be e.g. character a valid representation
day %<>% as.Date
result <- day %>% format("%u") %>% as.numeric %>% is_greater_than(5)
if (result)
message(day %>% paste("is a weekend!"))
else
message(day %>% paste("is not a weekend!"))
invisible(result)
}
相關用法
- R magrittr pipe 管道
- R magrittr exposition 展覽管
- R magrittr pipe-eager 熱切的管子
- R magrittr tee 三通管
- R matrix轉list用法及代碼示例
- R SparkR match用法及代碼示例
- R vcov.gam 從 GAM 擬合中提取參數(估計器)協方差矩陣
- R gam.check 擬合 gam 模型的一些診斷
- R as 強製對象屬於某個類
- R null.space.dimension TPRS 未懲罰函數空間的基礎
- R language-class 表示未評估語言對象的類
- R gam.reparam 尋找平方根懲罰的穩定正交重新參數化。
- R className 類名包含對應的包
- R modelr typical 求典型值
- R extract.lme.cov 從 lme 對象中提取數據協方差矩陣
- R scat 用於重尾數據的 GAM 縮放 t 係列
- R choldrop 刪除並排名第一 Cholesky 因子更新
- R smooth.construct.cr.smooth.spec GAM 中的懲罰三次回歸樣條
- R modelr resample “惰性”重采樣。
- R bandchol 帶對角矩陣的 Choleski 分解
- R BasicClasses 基本數據類型對應的類
- R gam.side GAM 的可識別性邊條件
- R cox.ph 附加 Cox 比例風險模型
- R callGeneric 從方法調用當前通用函數
- R mgcv.parallel mgcv 中的並行計算。
注:本文由純淨天空篩選整理自Stefan Milton Bache等大神的英文原創作品 Assignment pipe。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。