Skip to content

is.na(PB) throws warning when valid PB supplied #10

@MilesMcBain

Description

@MilesMcBain

The issue that PB is a numeric vector, which is.na() is vectorised over. So if() sees a vector of FALSE which rightly throws a warning in newer versions of R.

Here's a Reprex:

library(tidyverse)
library(magrittr)

structure(list(

P = structure(c(2, 3, 3, 2, 1, 1, 0, 0, 0, 1,
2, 2, 3, 3, 2.25, 2.75, 2.75, 2.25, 0.25, 0.75, 0.75, 0.25, 0.25,
0.75, 0.75, 0.25, 1.1, 1.1, 2, 2, 1, 0, 0, 1, 2, 2, 0, 1, 1,
0, 1.25, 1.25, 1.75, 1.75, 0.25, 0.25, 0.75, 0.75, 1.25, 1.25,
1.75, 1.75), .Dim = c(26L, 2L), .Dimnames = list(NULL, c("x",
"y"))),

PB = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 

S = structure(c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 2L, 3L, 4L, 1L, 6L, 7L,
8L, 9L, 10L, 5L, 12L, 13L, 14L, 11L, 16L, 17L, 18L, 15L, 20L,
21L, 22L, 19L, 24L, 25L, 26L, 23L), .Dim = c(26L, 2L), .Dimnames = list(
NULL, c("segment_start", "segment_end"))), 

SB = c(1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0), 

H = structure(c(2.5, 0.5, 0.5, 1.5, 0.5, 1.5), .Dim = c(3L,
2L))), .Names = c("P", "PB", "S", "SB", "H")) %>%
do.call(RTriangle::pslg, .) %>%
RTriangle::triangulate() 
#> Warning in if (is.na(PB)) {: the condition has length > 1 and only the
#> first element will be used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions