Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.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
需要R函数来操作两个数据帧_R_Spotfire - Fatal编程技术网

需要R函数来操作两个数据帧

需要R函数来操作两个数据帧,r,spotfire,R,Spotfire,在这种情况下,我能得到一些编写有效R函数的帮助吗? 我有一个汇总表和一个明细表。我想根据某些条件,用细节表中的匹配值替换汇总表中的值(或创建另一个输出表)。我需要有关R脚本的帮助,该脚本可以完成以下任务: Name Date Type Value A 1/2/2016 F 10 A 1/2/2016 P 11 A 1/3/2016

在这种情况下,我能得到一些编写有效R函数的帮助吗? 我有一个汇总表和一个明细表。我想根据某些条件,用细节表中的匹配值替换汇总表中的值(或创建另一个输出表)。我需要有关R脚本的帮助,该脚本可以完成以下任务:

Name    Date    Type    Value                   
A   1/2/2016    F   10                  
A   1/2/2016    P   11                  
A   1/3/2016    F   12                  
A   1/3/2016    F   13                  
A   1/3/2016    P   2                   
B   1/2/2016    F   25                  
B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
a) 对于汇总表a中的每个唯一组合(名称和日期)

Name    Date    Type    Value                   
A   1/2/2016    F   10                  
A   1/2/2016    P   11                  
A   1/3/2016    F   12                  
A   1/3/2016    F   13                  
A   1/3/2016    P   2                   
B   1/2/2016    F   25                  
B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
a。对表B(明细表)上的匹配记录执行以下操作:

Name    Date    Type    Value                   
A   1/2/2016    F   10                  
A   1/2/2016    P   11                  
A   1/3/2016    F   12                  
A   1/3/2016    F   13                  
A   1/3/2016    P   2                   
B   1/2/2016    F   25                  
B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
一,。如果A值之和=B值之和,则复制/替换具有详细信息的记录

Name    Date    Type    Value                   
A   1/2/2016    F   10                  
A   1/2/2016    P   11                  
A   1/3/2016    F   12                  
A   1/3/2016    F   13                  
A   1/3/2016    P   2                   
B   1/2/2016    F   25                  
B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
二,。如果A值之和不等于B值之和

Name    Date    Type    Value                   
A   1/2/2016    F   10                  
A   1/2/2016    P   11                  
A   1/3/2016    F   12                  
A   1/3/2016    F   13                  
A   1/3/2016    P   2                   
B   1/2/2016    F   25                  
B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
  • 找出区别
  • 将该差值添加到表B中的类型“P”值中,以确保总和匹配
  • 然后复制到新表或用详细信息替换记录(使用调整后的“P”值) 表A:

    Name    Date    valueA
    A   1/2/2016    21
    A   1/3/2016    27
    B   1/2/2016    50
    
    Name    Date    Type    Value                   
    A   1/2/2016    F   10                  
    A   1/2/2016    P   11                  
    A   1/3/2016    F   12                  
    A   1/3/2016    F   13                  
    A   1/3/2016    P   2                   
    B   1/2/2016    F   25                  
    B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
    
    表B:

    Name    Date    Type    ValueB
    A   1/2/2016    F   10
    A   1/2/2016    P   11
    A   1/3/2016    F   12
    A   1/3/2016    F   13
    A   1/3/2016    P   2
    B   1/2/2016    F   25
    B   1/2/2016    P   12
    
    Name    Date    Type    Value                   
    A   1/2/2016    F   10                  
    A   1/2/2016    P   11                  
    A   1/3/2016    F   12                  
    A   1/3/2016    F   13                  
    A   1/3/2016    P   2                   
    B   1/2/2016    F   25                  
    B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
    
    预期产量

    Name    Date    Type    Value                   
    A   1/2/2016    F   10                  
    A   1/2/2016    P   11                  
    A   1/3/2016    F   12                  
    A   1/3/2016    F   13                  
    A   1/3/2016    P   2                   
    B   1/2/2016    F   25                  
    B   1/2/2016    P   25  <<-- Adjust Values of "P" type with the difference
    
    Name日期类型值
    A 2016年1月2日第10层
    A 2016年1月2日第11页
    A 2016年1月3日F 12
    A 2016年1月3日F 13
    A 2016年1月3日第2页
    B 2016年1月2日F 25
    
    B 2016年1月2日第25页-明白了吗?如果没有,我想可以通过转换来完成。好的…我如何在没有脚本的情况下遍历行。。。但如果我能通过转换轻松处理数千条记录。。。请告诉我怎么做。谢谢,想好了吗?如果没有,我想可以通过转换来完成。好的…我如何在没有脚本的情况下遍历行。。。但如果我能通过转换轻松处理数千条记录。。。请告诉我怎么做。谢谢