gpt4 book ai didi

mysql - 显示同时存在于 MYSQL 表和/或 R 对象中的数据

转载 作者:行者123 更新时间:2023-12-01 00:32:38 25 4
gpt4 key购买 nike

我认为这是一个常规问题,回答了几次,但我只是不知道如何正确地提出问题=(

在 MySQL 中:
我有 2 个表,里面有某种字符串,现在我想要:
1.两个表中出现的数据
2. a表b中没有的数据

在 R 中相同:
我有 2 R data.frame s,我想要:
1. a和b中出现的数据
2. a中出现b中不出现的数据

最佳答案

R 中:

a <- data.frame(V1=sample(letters[1:3],20,TRUE),V2=rnorm(20))
b <- data.frame(V1=sample(letters[2:4],20,TRUE),V2=rnorm(20))

# the data that occur in a and b
(ab <- merge(a,b,by="V1"))

# the data that occur in a but not in b
aNOTb <- merge(a,b,by="V1",all=TRUE)
(aNOTb <- aNOTb[is.na(aNOTb$V2.y),])

关于mysql - 显示同时存在于 MYSQL 表和/或 R 对象中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3821796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com