This works as expected, it's hard to know what your problem is without seen your data, or at least a sample of it.
# Sample data using dput(K)
K <- structure(c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 5, 4.4, 4.9, 3.5,
3, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 1.4, 1.4, 1.3, 1.5,
1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3,
0.2, 0.2, 0.1), .Dim = c(10L, 4L), .Dimnames = list(NULL, NULL))
A <- 2
K
#> [,1] [,2] [,3] [,4]
#> [1,] 5.1 3.5 1.4 0.2
#> [2,] 4.9 3.0 1.4 0.2
#> [3,] 4.7 3.2 1.3 0.2
#> [4,] 4.6 3.1 1.5 0.2
#> [5,] 5.0 3.6 1.4 0.2
#> [6,] 5.4 3.9 1.7 0.4
#> [7,] 4.6 3.4 1.4 0.3
#> [8,] 5.0 3.4 1.5 0.2
#> [9,] 4.4 2.9 1.4 0.2
#> [10,] 4.9 3.1 1.5 0.1
K > A
#> [,1] [,2] [,3] [,4]
#> [1,] TRUE TRUE FALSE FALSE
#> [2,] TRUE TRUE FALSE FALSE
#> [3,] TRUE TRUE FALSE FALSE
#> [4,] TRUE TRUE FALSE FALSE
#> [5,] TRUE TRUE FALSE FALSE
#> [6,] TRUE TRUE FALSE FALSE
#> [7,] TRUE TRUE FALSE FALSE
#> [8,] TRUE TRUE FALSE FALSE
#> [9,] TRUE TRUE FALSE FALSE
#> [10,] TRUE TRUE FALSE FALSE
apply(K > A, 2, all)
#> [1] TRUE TRUE FALSE FALSE
K < A
#> [,1] [,2] [,3] [,4]
#> [1,] FALSE FALSE TRUE TRUE
#> [2,] FALSE FALSE TRUE TRUE
#> [3,] FALSE FALSE TRUE TRUE
#> [4,] FALSE FALSE TRUE TRUE
#> [5,] FALSE FALSE TRUE TRUE
#> [6,] FALSE FALSE TRUE TRUE
#> [7,] FALSE FALSE TRUE TRUE
#> [8,] FALSE FALSE TRUE TRUE
#> [9,] FALSE FALSE TRUE TRUE
#> [10,] FALSE FALSE TRUE TRUE
apply(K < A, 2, all)
#> [1] FALSE FALSE TRUE TRUE
Created on 2019-02-08 by the reprex package (v0.2.1)
Could you please turn this into a self-contained REPR oducible EX ample (reprex) ? A reprex makes it much easier for others to understand your issue and figure out how to help.
If you've never heard of a reprex before, you might want to start by reading this FAQ:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…