0

I need to apply the filter condition on String columns along with numeric columns. This way it is not giving the expected output. If anyone has encountered the same problem, please help

Num1<-c(1,2,3,4,5)
Num2<-c(1,2,2,1,1)
String1<-c("AA","BB","CC","DD","EE")
String2<-c("AA","BB","CC","DD","FF")
data<-c(Num1,Num2,String1,String2)
df<-data%>%
filter((Num2<Num1) & (String1==String2))
ash25
  • 113
  • 1
  • 11
  • 1
    It would be helpful if you provided an example of what you want to accomplish along with the desired output and data. Please refer to this: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Sumedh Jul 10 '16 at 03:21

1 Answers1

0

We need to create a data.frame instead of a vector

data<- data.frame(Num1,Num2,String1,String2, stringsAsFactors=FALSE)

and then the OP would work

data %>%
    filter(Num2 < Num1 & String1 == String2)
#   Num1 Num2 String1 String2
#1    3    2      CC      CC
#2    4    1      DD      DD
akrun
  • 874,273
  • 37
  • 540
  • 662