如何用R语言从学号列表中随机抽取两个男生
r语言读取(加载)txt格式的数据作为dataframe,根据学号字段从dataframe中随机抽取10名学生的数据。
详细编码如下。
report card 1 = read . table(file = ' test 1 . txt ',header=TRUE)
report card 2 = read . table(file = ' test 2 txt ' header = TRUE)names(report card 1)names(report card 2)report card = merge(report card report card 2,by = xh)print(head(report card))xh = sample(report card $ xh,size=10,replace = TRUE)samples = report card[report card $ xh % in % xh]print(samples).