how does someone do a complement function in rstudio? I want this ultimately to work on a dataframe. Here I am using simple variables to start. The dataset I want to apply this to has id numbers.
zf <- c(1,2,3,4,5,6,7,8,9)
cat(zf,"\n")
zf1 <- c(1,3,5,7,9)
cat(zf1,"\n")
zf2 <- zf[!zf1]
cat(zf2,"\n","\n")
library(dplyr)
anti_join(zf1,df)
OUTPUT:
1 2 3 4 5 6 7 8 9
1 3 5 7 9
Error in UseMethod("anti_join") :
no applicable method for 'anti_join' applied to an object of class "c('double', 'numeric')"
zf <- c(1,2,3,4,5,6,7,8,9)
zf <-as.data.frame(zf)
zf
zf1 <- c(1,3,5,7,9)
zf1 <-as.data.frame(zf1)
zf1
zf2 <- zf[!zf1]
zf2 <-as.data.frame(zf2)
zf2
library(dplyr)
anti_join(zf1,df)
OUTPUT:
Error in anti_join()
: ! by
must be supplied when x
and y
have no common variables. use by = character()` to perform a cross-join. Backtrace: 1. dplyr::anti_join(zf1, df) 2. dplyr:::anti_join.data.frame(zf1, df)
[image] Show Traceback
Error in anti_join(zf1, df) : use by = character()` to perform a cross-join.