R 旋转/旋转和行的复制

R 旋转/旋转和行的复制,r,revolution-r,R,Revolution R,在对一个长表进行子集设置之后,我尝试合并两个xdf文件,该长表具有基于变量的重复ID 假设我有两列:id和type 我根据saytype='type1'对原始xdf表进行子集划分,并获取第一个xdf文件 我根据saytype='type2'对原始xdf表进行子集划分,并获得第二个xdf文件 第一个xdf文件如下所示 (有很多不同的ID,但我在下面的示例中显示了一个ID) 第二个xdf文件如下所示 (有很多不同的ID,但我在下面的示例中显示了一个ID) 然后,我将两个xdf文件合并到另一个xdf文

在对一个长表进行子集设置之后,我尝试合并两个xdf文件,该长表具有基于变量的重复ID

假设我有两列:id和type

我根据say
type='type1'
对原始xdf表进行子集划分,并获取第一个xdf文件 我根据say
type='type2'
对原始xdf表进行子集划分,并获得第二个xdf文件

第一个xdf文件如下所示 (有很多不同的ID,但我在下面的示例中显示了一个ID)

第二个xdf文件如下所示 (有很多不同的ID,但我在下面的示例中显示了一个ID)

然后,我将两个xdf文件合并到另一个xdf文件中

rxMerge(file1, file2, outFile = final, autoSort = FALSE, matchVars = 'id', type = 'full', overwrite = TRUE)
我得到两条id=1的记录,如

id type1 type2
__ ____ ______
1    5    NA

1    NA    3
我期待着

id type1 type2
__ ____ ______
1    5    3

我做错了什么?

嗯。。。在RRE 7.4.1中,您给出的示例适用于我:

# Example data
x <- data.frame(id = 1, type1 = 5)
y <- data.frame(id = 1, type2 = 3)

# Creating XDFs for the example data
file1 <- tempfile(fileext = ".xdf")
rxImport(inData = x, outFile = file1)

file2 <- tempfile(fileext = ".xdf")
rxImport(inData = y, outFile = file2)

# Merging into a third XDF
final <- tempfile(fileext = ".xdf")

rxMerge(inData1 = file1, 
        inData2 = file2, 
        outFile = final, 
        autoSort = FALSE, 
        matchVars = 'id',
        type = 'full',
        overwrite = TRUE)

# Check the output
rxDataStep(final)
#示例数据

嗯。。。在RRE 7.4.1中,您给出的示例适用于我:

# Example data
x <- data.frame(id = 1, type1 = 5)
y <- data.frame(id = 1, type2 = 3)

# Creating XDFs for the example data
file1 <- tempfile(fileext = ".xdf")
rxImport(inData = x, outFile = file1)

file2 <- tempfile(fileext = ".xdf")
rxImport(inData = y, outFile = file2)

# Merging into a third XDF
final <- tempfile(fileext = ".xdf")

rxMerge(inData1 = file1, 
        inData2 = file2, 
        outFile = final, 
        autoSort = FALSE, 
        matchVars = 'id',
        type = 'full',
        overwrite = TRUE)

# Check the output
rxDataStep(final)
#示例数据
x
# Example data
x <- data.frame(id = 1, type1 = 5)
y <- data.frame(id = 1, type2 = 3)

# Creating XDFs for the example data
file1 <- tempfile(fileext = ".xdf")
rxImport(inData = x, outFile = file1)

file2 <- tempfile(fileext = ".xdf")
rxImport(inData = y, outFile = file2)

# Merging into a third XDF
final <- tempfile(fileext = ".xdf")

rxMerge(inData1 = file1, 
        inData2 = file2, 
        outFile = final, 
        autoSort = FALSE, 
        matchVars = 'id',
        type = 'full',
        overwrite = TRUE)

# Check the output
rxDataStep(final)