我想用dplyr解决以下问题.优选具有一个窗口功能.我有一个房屋和购买价格的数据框架.以下是一个例子:
houseID year price
1 1995 NA
1 1996 100
1 1997 NA
1 1998 120
1 1999 NA
2 1995 NA
2 1996 NA
2 1997 NA
2 1998 30
2 1999 NA
3 1995 NA
3 1996 44
3 1997 NA
3 1998 NA
3 1999 NA
Run Code Online (Sandbox Code Playgroud)
我想建立一个这样的数据框:
houseID year price
1 1995 NA
1 1996 100
1 1997 100
1 1998 120
1 1999 120
2 1995 NA
2 1996 NA
2 1997 NA
2 1998 30 …Run Code Online (Sandbox Code Playgroud) 我使用 vscode 版本 1.45.1。使用克隆存储库时,我收到“凭据错误”。最近我更改了 github 上的用户名。这可能就是原因。我如何告诉 VS Code?
我来自丹麦,需要能够在我的 R 代码中使用丹麦语字母。
\n\n如果我添加一些代码,例如:
\n\nprint("\xc3\x85rhus er bare \xc3\xb8v...")\nRun Code Online (Sandbox Code Playgroud)\n\n并将其保存为 R-studio 中的 R 脚本文件,下次我在 R-studio 中打开该文件时,我得到:
\n\nprint("?rhus er bare ?v...")\nRun Code Online (Sandbox Code Playgroud)\n 在基于代理的实时建模项目中,我遇到以下问题:假设我有一些具有公共比例X的类MyClass(X是双精度).我需要一个可以按排序方式包含我的对象的类(称为FancyList).如果我插入一个新的MyClass对象,它应插入具有较低X的对象和具有较高X的对象之间.
FancyList _fancyList = new FancyList();
// Allocate MyClass objects. The X proporty is defined in the constructor
MyClass c1 = new MyClass(2.0)
MyClass c2 = new MyClass(3.0)
MyClass c3 = new MyClass(2.5)
_fancyList.Insert(c1);
_fancyList.Insert(c2);
_fancyList.Insert(c3);
// In the fancyList c3 is after c1 and before c2. Therefore c1 is the first
// element, and c2 is the last element
Run Code Online (Sandbox Code Playgroud)
插入物尽可能快是很重要的.
示例:包含多个个体和 3 个变量的数据框:年份(整数)、性别(因子:男性/女性)和联合(因子:是/否)。我想计算给定年份和性别成为工会成员的概率。我通常用aggregate()来做到这一点。我是否一直都在这样做,我正在寻找一种在 dplyr 中快速完成的方法。
亲切的问候,彼得