我希望从下面的数据集中找到旅行持续时间和年龄的相关性。我正在使用功能cor(age,df$tripduration)
。但是,它给了我输出NA。你能不能让我知道我该如何处理关联?我找到了 “时代” 的语法如下:如何查找数据集中的相关性
age <- (2017-as.numeric(df$birth.year))
和tripduration(seconds)
作为df$tripduration
。
以下是数据。性别中的数字1表示男性,2表示女性。
tripduration birth year gender
439 1980 1
186 1984 1
442 1969 1
170 1986 1
189 1990 1
494 1984 1
152 1972 1
537 1994 1
509 1994 1
157 1985 2
1080 1976 2
239 1976 2
344 1992 2
你一定做了一个错字的地方,因为当我运行示例代码中,我得到8.37% – lebelinoz