Y <- c(1,2,-1,1,
2,2,3,1,
1,1,-2,3) |>
matrix(nrow = 3)
X <- make_non_negative(Y)
Y
X |> round(2)
rowSums(Y)
rowSums(X)
colSums(Y)
colSums(X)
set.seed(2)
Y <- rnorm(3*5) |> matrix(3,5) |> round(3)
Y
tryCatch(make_non_negative(Y), error = function(e) {
print(e)
})
make_non_negative(Y, allowSlack = TRUE) |> round()
Run the code above in your browser using DataLab