使用“ join”的mutate_impl(.data,点)中的错误。码 [英] Error in mutate_impl(.data, dots) using "join" code

查看:80
本文介绍了使用“ join”的mutate_impl(.data,点)中的错误。码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含100000行的数据集,其中order_date显示订单日期,而user_id显示用户ID。我正在尝试创建一个新变量来显示用户在同一天的总订单。我的数据是这样的:

I have a dataset with 100000 rows where order_date shows the order date and user_id where shows the user's ID. I am trying to create a new variable that shows the user's total order within the same day. My data is like this:

order_date=structure(c(15587, 15647, 15734, 15560, 15599, 15778, 15708, 
15520, 15592, 15447, 15718, 15787, 15519, 15486, 15514, 15784, 
15619, 15705, 15552, 15734, 15493, 15661, 15563, 15600, 15790, 
15485, 15546, 15767, 15704, 15726), class = "Date") 

user_id=c(22607, 28275, 32238, 20202, 4391, 7983, 29590, 11820, 22956, 
3196, 31125, 11709, 6586, 2920, 9698, 36814, 6954, 30368, 19052, 
827, 6599, 517, 8761, 20174, 37367, 11647, 18764, 27271, 30302, 
14808)

daten = data.frame(order_date = order_date, user_id = user_id)

我正在使用此代码:

daten<-join(daten, count(daten, c("order_date", "user_id")))

它会创建一个名为 freq的新变量,并且一直有效到今天。现在它不起作用,并且我收到这样的错误消息:

It creates a new variable called "freq" and it was working until today. Now it doesn't work and I am getting an error message like this:

mutate_impl(.data,点)中的错误:
c( order_date, user_id)的长度必须为100000(行数)或一个,而不是2

Error in mutate_impl(.data, dots) : Column c("order_date", "user_id") must be length 100000 (the number of rows) or one, not 2

I使用 str 检查了两个变量的结构,并说它们都有100000行。

I checked the structure of both variables using str and it says both have 100000 rows.

推荐答案

我不确定您打算使用哪个 join inner_join ),但有一件事肯定不正确在您的代码中大约是 count

I'm not sure which join (inner_join) you intend to use but one thing certainly not correct in your code is about count.

count(daten,c( order_date , user_id))应该更改为:

count(daten, order_date, user_id)

这篇关于使用“ join”的mutate_impl(.data,点)中的错误。码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆