r - R中的聚类抽样
问题描述
我想了解这个脚本中发生了什么。为什么在整群抽样中需要均值、标准差?rnorm(200, mean=7, sd=1)
在这个data.frame的上下文中是什么意思?
#make this example reproducible
set.seed(1)
#create data frame
df <- data.frame(tour = rep(1:10, each=20),
experience = rnorm(200, mean=7, sd=1))
#view first six rows of data frame
head(df)
#randomly choose 4 tour groups out of the 10
clusters <- sample(unique(df$tour), size=4, replace=F)
#define sample as all members who belong to one of the 4 tour groups
cluster_sample <- df[df$tour %in% clusters,]
#view how many customers came from each tour
table(cluster_sample$tour)
解决方案
推荐阅读
- excel - Excel VBA - 如何在每 12 个月后增加值
- typescript - Typescript 通过同级属性推断类型
- reactjs - 使用 axios 发送退款表单时出错
- python - 如何在 macOS 上使用 python 打开应用程序?
- typescript - 理解 typescript 类型断言
- mysql - 你好。我尝试使用 django + mySQL (api) 执行命令 docker-compose up (build I have done) 项目。但我有例外:
- byte - 区分异步数据流中最重要和最不重要的字节
- amazon-web-services - Terraform AWS,未创建实例
- angular - 服务工作者获取事件未触发(路径问题)
- python-3.x - python中的写入模式不创建新文件