Contact me:

摘要: ##factor()函数创建因子 factor()函数的第一个参数必须是字符向量,通过levels参数显式设置因子水平, factor(x = character(), levels, labels = levels, exclude = NA, ordered = is.ordered(x), n 阅读全文
posted @ 2020-06-05 17:18 impwa 阅读(2465) 评论(0) 推荐(0) 编辑
摘要: x<-rnorm(3) #随机生成3个随机数 结果:1.4197419 -0.7460519 0.3603622 x<-rnorm(3) #再来一遍,生成的3个随机数又不一样了 结果:1.0796213 0.5598334 0.5344839 set.seed(123) x<-rnorm(3) #随 阅读全文
posted @ 2020-06-04 16:58 impwa 阅读(249) 评论(0) 推荐(0) 编辑
摘要: tapply(x,f,g) x向量组 f(factor)因子或因子列表 g函数 将x按f分组的到子向量组并应用函数g x <- c("男", "女", "男", "男", "女") sex <- factor(x) h <- c(165, 170, 168, 172, 159) tapply(h, 阅读全文
posted @ 2020-06-04 16:41 impwa 阅读(431) 评论(0) 推荐(0) 编辑
摘要: table() 记录数据频数 x <- table(c(1,2,1,3,2,1)); print(x) 1 2 3 3 2 1 阅读全文
posted @ 2020-06-04 12:00 impwa 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 语句输入不完整导致的,后面直接加 ; 回车执行,会退出这种状态 阅读全文
posted @ 2020-06-02 17:01 impwa 阅读(2245) 评论(0) 推荐(0) 编辑
摘要: ##整数型下标 price.map <- c(68, 88, 168) 设某个收银员在一天内分别售出礼品编号为3,2,1,1,2,2,3, 可以用如下的映射方式获得售出的这些礼品对应的价格: items <- c(3,2,1,1,2,2,3) y <- price.map[items]; print 阅读全文
posted @ 2020-06-02 16:52 impwa 阅读(724) 评论(2) 推荐(0) 编辑
摘要: ##Description grep, grepl, regexpr, gregexpr and regexec search for matches to pattern within each element of a character vector: they differ in the f 阅读全文
posted @ 2020-06-02 09:42 impwa 阅读(1020) 评论(0) 推荐(0) 编辑
摘要: 恢复内容开始 看到sprintf函数有点不明所以,原文如下 为了用指定的格式数值型转换成字符型, 可以使用sprintf()函数, 其用法与C语言的sprintf()函数相似, 只不过是向量化的。例如 sprintf('file%03d.txt', c(1, 99, 100)) ## [1] "fi 阅读全文
posted @ 2020-06-01 23:44 impwa 阅读(875) 评论(0) 推荐(0) 编辑
摘要: 在学习读入数据表格时要用到txr.talbe将csv文件转化为数据框形式,特此查了一下 数据框是r中最常见的原始数据形式,类似于数据库表或Excel数据表的形式 Data Frames Description The function data.frame() creates data frames 阅读全文
posted @ 2020-05-31 21:11 impwa 阅读(1409) 评论(0) 推荐(0) 编辑
摘要: dict.items() 把字典中每对 key 和 value 组成一个元组,并把这些元组放在列表中返回 dict = {'one': 1, 'two': 2, 'three': 3} for a,b in dict.items() 两个参数分别对应元祖中两个元素 print(key + ':' + 阅读全文
posted @ 2020-05-15 12:57 impwa 阅读(920) 评论(0) 推荐(0) 编辑