Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何准备数据,包括使用rayleigh.test{circular}的基本方向_R_Statistics - Fatal编程技术网

如何准备数据,包括使用rayleigh.test{circular}的基本方向

如何准备数据,包括使用rayleigh.test{circular}的基本方向,r,statistics,R,Statistics,我有如下格式的数据: quantity direction 10 n 5 e 6 ne 12 n 20 nw 5 s 8 n 1 sw 3 se 2 ne 6 nw 8 n 2 se 3 e 4 w 9 nw 我想在其上运行rayleigh.testfromcircular包(有关我为什么要执行此检查的更多信息:)。我想我必须先使用循环函数来准备数据,但我不知道该怎么做。这个函数的units参数允许的值是“弧度”、“度”、“小时”,我不知道如何将我的方向与之匹配 如何获取瑞利。测试以接受基本方

我有如下格式的数据:

quantity direction
10 n
5 e
6 ne
12 n
20 nw
5 s
8 n
1 sw
3 se
2 ne
6 nw
8 n
2 se
3 e
4 w
9 nw
我想在其上运行
rayleigh.test
from
circular
包(有关我为什么要执行此检查的更多信息:)。我想我必须先使用
循环
函数来准备数据,但我不知道该怎么做。这个函数的units参数允许的值是“弧度”、“度”、“小时”,我不知道如何将我的方向与之匹配


如何获取瑞利。测试以接受基本方向作为输入?

我无法判断瑞利测试是否适用于非连续数据,但下面是一个小示例,说明如何将角色映射到度:

df <- data.frame( quantity = c(37,5,6)  , direction = c("n", "ne" , "n") )

df$direction <- as.factor(df$direction)
# create a map from character to degrees:
map <- setNames( c( 0, 45) , c("n", "ne") )

levels(df$direction) <- map[ levels(df$direction) ]
df