I have a database that contains 3 variables: var1
, var2
and var 3
. I tried to use some functions in R that would return me a logical value if any of the rows had the same values. One of them was the all
function, as below:
apply(meusdados,1,all)
However, I noticed that it returns% with% only for values other than% with% if there is repetition.
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
In addition, this function does not work with vectors with characters, returning all% with%.
How to correct this, so that if the identical lines return the value boolean TRUE
?
My data with the numeric variables are these:
structure(list(var1 = c(1, 0, 1, 0, 1, 0, 1, 0, 0, 1), var2 = c(0,
0, 0, 1, 1, 1, 0, 0, 1, 1), var3 = c(1, 0, 1, 1, 1, 1, 0, 0,
0, 0)), .Names = c("var1", "var2", "var3"), class = "data.frame", row.names = c(NA,
-10L))
With the strings, these are:
structure(list(var1 = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 1L, 2L), .Label = c("compras", "opfin"), class = "factor"),
var2 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L
), .Label = c("compras", "opfin"), class = "factor"), var3 = structure(c(2L,
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("compras",
"opfin"), class = "factor")), .Names = c("var1", "var2",
"var3"), row.names = c(NA, -10L), class = "data.frame")