Checking for identical columns in a data frame in R

后端 未结 3 1705
南方客
南方客 2020-12-30 23:47

Suppose you have a data frame called data with two identical columns:

A B
1 1
2 2
3 3
4 4

How can I check if these two columns are identica

3条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 00:39

    You could use all():

    > data <- data.frame(A=c(1,2,3,4), B=c(1,2,3,4))
    > all(data$A == data$B)
    [1] TRUE
    

提交回复
热议问题