attempt包测试3_Adverbs_20200204Tuesday

1.设置当前工作目录

getwd()
setwd("./attempt/")

2.导入R包

library(attempt)

3.测试:Adverbs take a function and return a modified function.

3.1 silently()

#@ silently() transforms a function so that when you call this new function, it returns nothing unless there is an error or a warning (contrary to attempt that returns the result). In a sense, the new function stay silent unless error or warning.
silent_log <- silently(log)
silent_log(1)
silent_log(“a”)

Error in .f(…) : 数学函数中用了非数值参数

#@ With silently(), the result is never returned.
silent_matrix <- silently(matrix)
silent_matrix(1:3,2)

Warning message:

In .f(…) : 数据长度[3]不是矩阵行数[2]的整倍

3.2 surely()

#@ surely() transforms a function so that when you call this new function, it calls attempt() - i.e. in the code below, calling sure_log(1) is the same as calling attempt(log(1)). In a sense, you’re sure this new function will always work.
sure_log <- surely(log)
sure_log(1)

[1] 0

sure_log(“a”)

Error: 数学函数中用了非数值参数

3.3 with_message() and with_warning()

#@ These two functions take a function, and add a warning or a message to it.
as_num_msg <- with_message(as.numeric, msg = “We’re performing a numeric conversion”)
as_num_warn <- with_warning(as.numeric, msg = “We’re performing a numeric conversion”)
as_num_msg(“1”)

We’re performing a numeric conversion

[1] 1

as_num_warn(“1”)

[1] 1

Warning message:

In as_num_warn(“1”) : We’re performing a numeric conversion

3.4 without_message(), without_warning(), and discretly()

#@ These three functions do the opposite, as they remove warnings and messages:
matrix(1:3, ncol = 2)

[,1] [,2]

[1,] 1 3

[2,] 2 1

Warning message:

In matrix(1:3, ncol = 2) : 数据长度[3]不是矩阵行数[2]的整倍

no_warning_matrix <- without_warning(matrix)
no_warning_matrix(1:3, ncol = 2)

[,1] [,2]

[1,] 1 3

[2,] 2 1

4.结束

sessionInfo()

R version 3.6.2 (2019-12-12)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:

[1] LC_COLLATE=Chinese (Simplified)_China.936

[2] LC_CTYPE=Chinese (Simplified)_China.936

[3] LC_MONETARY=Chinese (Simplified)_China.936

[4] LC_NUMERIC=C

[5] LC_TIME=Chinese (Simplified)_China.936

attached base packages:

[1] stats4 parallel stats graphics grDevices utils

[7] datasets methods base

other attached packages:

[1] attempt_0.3.0 Biostrings_2.54.0 XVector_0.26.0

[4] IRanges_2.20.2 S4Vectors_0.24.2 BiocGenerics_0.32.0

loaded via a namespace (and not attached):

[1] Seurat_3.1.2 TH.data_1.0-10

[3] Rtsne_0.15 colorspace_1.4-1

[5] seqinr_3.6-1 pryr_0.1.4

[7] ggridges_0.5.2 rstudioapi_0.10

[9] leiden_0.3.2 listenv_0.8.0

[11] npsurv_0.4-0 ggrepel_0.8.1

[13] alakazam_0.3.0 mvtnorm_1.0-12

[15] codetools_0.2-16 splines_3.6.2

[17] R.methodsS3_1.7.1 mnormt_1.5-5

[19] lsei_1.2-0 TFisher_0.2.0

[21] zeallot_0.1.0 ade4_1.7-13

[23] jsonlite_1.6 packrat_0.5.0

[25] ica_1.0-2 cluster_2.1.0

[27] png_0.1-7 R.oo_1.23.0

[29] uwot_0.1.5 sctransform_0.2.1

[31] readr_1.3.1 compiler_3.6.2

[33] httr_1.4.1 backports_1.1.5

[35] assertthat_0.2.1 Matrix_1.2-18

[37] lazyeval_0.2.2 htmltools_0.4.0

[39] prettyunits_1.1.0 tools_3.6.2

[41] rsvd_1.0.2 igraph_1.2.4.2

[43] gtable_0.3.0 glue_1.3.1

[45] RANN_2.6.1 reshape2_1.4.3

[47] dplyr_0.8.3 Rcpp_1.0.3

[49] Biobase_2.46.0 vctrs_0.2.1

[51] multtest_2.42.0 gdata_2.18.0

[53] ape_5.3 nlme_3.1-142

[55] gbRd_0.4-11 lmtest_0.9-37

[57] stringr_1.4.0 globals_0.12.5

[59] lifecycle_0.1.0 irlba_2.3.3

[61] gtools_3.8.1 future_1.16.0

[63] zlibbioc_1.32.0 MASS_7.3-51.4

[65] zoo_1.8-7 scales_1.1.0

[67] hms_0.5.3 sandwich_2.5-1

[69] RColorBrewer_1.1-2 reticulate_1.14

[71] pbapply_1.4-2 gridExtra_2.3

[73] ggplot2_3.2.1 stringi_1.4.3

[75] mutoss_0.1-12 plotrix_3.7-7

[77] caTools_1.17.1.4 bibtex_0.4.2.2

[79] Rdpack_0.11-1 SDMTools_1.1-221.2

[81] rlang_0.4.2 pkgconfig_2.0.3

[83] bitops_1.0-6 lattice_0.20-38

[85] ROCR_1.0-7 purrr_0.3.3

[87] htmlwidgets_1.5.1 cowplot_1.0.0

[89] tidyselect_0.2.5 RcppAnnoy_0.0.14

[91] plyr_1.8.5 magrittr_1.5

[93] R6_2.4.1 gplots_3.0.1.2

[95] multcomp_1.4-12 pillar_1.4.3

[97] sn_1.5-4 fitdistrplus_1.0-14

[99] survival_3.1-8 tibble_2.1.3

[101] future.apply_1.4.0 tsne_0.1-3

[103] crayon_1.3.4 KernSmooth_2.23-16

[105] plotly_4.9.1 progress_1.2.2

[107] grid_3.6.2 data.table_1.12.8

[109] metap_1.2 digest_0.6.23

[111] tidyr_1.0.0 numDeriv_2016.8-1.1

[113] R.utils_2.9.2 RcppParallel_4.4.4

[115] munsell_0.5.0 viridisLite_0.3.0

attempt包测试3_Adverbs_2020-02-04相关推荐

  1. Biostrings包测试1_2020-01-29

    Biostrings包测试1_20200129Wednesday 1.设置当前工作目录 setwd("Biostrings/") 2.导入R包 library(Biostrings ...

  2. ping包测试内容写入文件,并使用python对相应的结果进行统计分析

    一.ping包测试内容写入log文件,bat脚本如下: @ECHO OFF %~d0 cd %cd%\ start CMD.EXE /C "ping.exe 192.168.1.21 > ...

  3. 【Android 插件化】Hook 插件化框架 ( 创建插件应用 | 拷贝插件 APK | 初始化插件包 | 测试插件 DEX 字节码 )

    Android 插件化系列文章目录 [Android 插件化]插件化简介 ( 组件化与插件化 ) [Android 插件化]插件化原理 ( JVM 内存数据 | 类加载流程 ) [Android 插件 ...

  4. 【364天】跃迁之路——程序员高效学习方法论探索系列(实验阶段122-2018.02.04)...

    实验说明 从2017.10.6起,开启这个系列,目标只有一个:通过探索新的学习方法,用2年的时间,实现2.5倍速的成长,获得普通程序员>= 5年的技术水平. 实验期2年(2017.10.06 - ...

  5. 小明分享|ESP8266设置STA模式ping包测试

    硬件准备 PC机.USB数据线.ESP8266开发板,路由器 软件准备 串口调试助手(如:XCOM) 固件(可以使用的是开发板自带的固件) Flash Download 烧录工具: https://w ...

  6. 面试题 02.04. 分割链表

    面试题 02.04. 分割链表 编写程序以 x 为基准分割链表,使得所有小于 x 的节点排在大于或等于 x 的节点之前.如果链表中包含 x,x 只需出现在小于 x 的元素之后(如下所示).分割元素 x ...

  7. win10中Charles从下载安装到证书设置和雷电模拟器或浏览器中抓包测试

    一.下载安装及证书设置 1.在Charles官网https://www.charlesproxy.com/download/下载,我这边下载的是免费体验版的. 体验版用一段时间就会退出,这里另外提供给 ...

  8. Windows脚本 同网段ip检测与持续ping包测试

    ::@echo off title IP 地址检测 -- das白::检测此计算机是否与 172.0.0.1 - 172.0.0.39 互通 结果存入D盘 <检测结果.txt> set i ...

  9. 行测题库:行测每日一练常识判断练习题02.04

    行测题库:行测每日一练常识判断练习题02.04 1.下列说法错误的是: A.CPI反映居民所购生活消费品的价值和服务项目价格变动趋势 B.通货膨胀的实质是社会总需求小于社会总供给 C.经济学领域中最初 ...

最新文章

  1. DIY 一套正版、免费、强大的 Visual Studio 2012 IDE
  2. 算法--------------整数反转
  3. 关于“如何破坏单例“我说了好几种方式,面试官却说:我其实随便问问,没想到你真会
  4. (仿头条APP项目)4.父类BaseFragment创建,用retrofit和gson获取并解析服务器端数据
  5. C++Builder中使用Pas文件
  6. 第十八课 色彩样式与滤镜
  7. 能否用痰盂盛饭——谈谈在头文件中定义外部变量
  8. leetcode24. 两两交换链表中的节点(思路+解析)
  9. [ASM]查看加密的vba代码
  10. php画弧,php绘制一条弧线的方法
  11. ExtJS学习------Ext.define的继承extend,用javascript实现相似Ext的继承
  12. 新版风格收款码三合一制作生成系统源码 附多个模板
  13. 超现实数surreal number学习
  14. 获取路由器内的ADSL上网账号和密码或者获取电脑内的ADSL上网账号和密码教程(by 星空武哥)
  15. 大厂面试题之计算机网络重点篇 (附答案)
  16. Android 权限适配 从此第三方系统新增的权限无法判断状态的问题得到解决! 如MIUI自启动, 后台弹出界面权限等
  17. FPGA三分频,五分频,奇数分频
  18. 5个球放入3个箱子_排列组合问题,把5个相同的球放到三个相同的盒子里,要求每个盒子都有球,则不同的放球方法是多少?...
  19. Unity中Scale详解
  20. smart gesture安装失败_3ds Max 2014 下载与安装步骤

热门文章

  1. 软件测试面试题【含答案】
  2. uni-app制作海报并转发
  3. 如何实现复制微信图文到Word文档
  4. Java多线程(超详解)
  5. 咖说 | 暗潮涌动,ERC20 BTC 正在搅动市场
  6. QNX Neutrino 进程间通信编程之Signals
  7. 微信指数和其他平台的微指数有什么区别
  8. C++进阶学习(二)----C到C++II
  9. 【编译原理】分析PL0编译器
  10. Kvm*虚机中创建虚机