R 中带有 permtest 函数的这段代码有什么问题?
What's wrong with this code with permtest function in R?
ID pounds Drug
1 1 46.4 B
2 2 40.4 A
3 3 27.6 B
4 4 93.2 B
5 5 28.8 A
6 6 36.0 A
7 7 81.2 B
8 8 14.4 B
9 9 64.0 A
10 10 29.6 A
我的密码是
test <-permtest(data1$pounds[Drug=='A'],data1$pounds[Drug=='B'])
但我收到一条错误消息,提示未找到对象 'Drug'。
求助!
我们需要提取 $
或 [[
的列。这里它在全局环境中搜索一个对象 'Drug',它不是在那里创建的,而是只在 'data1' 的环境中创建的。所以,要么使用 $/[[
permtest(data1$pounds[data1$Drug=='A'],data1$pounds[data1$Drug=='B'])
或使用with
with(data1, permtest(pounds[Drug == 'A'], pounds[Drug == 'B']))
ID pounds Drug
1 1 46.4 B
2 2 40.4 A
3 3 27.6 B
4 4 93.2 B
5 5 28.8 A
6 6 36.0 A
7 7 81.2 B
8 8 14.4 B
9 9 64.0 A
10 10 29.6 A
我的密码是
test <-permtest(data1$pounds[Drug=='A'],data1$pounds[Drug=='B'])
但我收到一条错误消息,提示未找到对象 'Drug'。 求助!
我们需要提取 $
或 [[
的列。这里它在全局环境中搜索一个对象 'Drug',它不是在那里创建的,而是只在 'data1' 的环境中创建的。所以,要么使用 $/[[
permtest(data1$pounds[data1$Drug=='A'],data1$pounds[data1$Drug=='B'])
或使用with
with(data1, permtest(pounds[Drug == 'A'], pounds[Drug == 'B']))