Unclosed parenthesis in grep.Rd

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unclosed parenthesis in grep.Rd

Hugh Parsonage
Lines 129-131:
\code{grep(value = FALSE)} returns a vector of the indices
of the elements of \code{x} that yielded a match (or not, for
\code{invert = TRUE}. This will be an integer vector unless the input

There should be a closing parenthesis after \code{invert = TRUE}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Unclosed parenthesis in grep.Rd

Martin Maechler
>>>>> Hugh Parsonage <[hidden email]>
>>>>>     on Mon, 5 Mar 2018 13:39:24 +1100 writes:

    > Lines 129-131: \code{grep(value = FALSE)} returns a vector
    > of the indices of the elements of \code{x} that yielded a
    > match (or not, for \code{invert = TRUE}. This will be an
    > integer vector unless the input

    > There should be a closing parenthesis after \code{invert =
    > TRUE}

Thank you, Hugh!  I've added the ')' now.
Martin

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Unclosed parenthesis in grep.Rd

Etienne Sanchez
There are probably more unmatched parentheses around:

detect <- function(file) {
  text <- paste(readLines(file), collapse = "")
  nchar(gsub("[^(]", "", text)) != nchar(gsub("[^)]", "", text))
}

docs <- list.files("r-source-trunk/src/library",
                   pattern = "\\.Rd$",
                   full.names = TRUE,
                   recursive = TRUE)

suspicious <- docs[sapply(docs, detect)]

length(suspicious)
# [1] 114


2018-03-05 9:27 GMT+01:00 Martin Maechler <[hidden email]>:

>
> >>>>> Hugh Parsonage <[hidden email]>
> >>>>>     on Mon, 5 Mar 2018 13:39:24 +1100 writes:
>
>     > Lines 129-131: \code{grep(value = FALSE)} returns a vector
>     > of the indices of the elements of \code{x} that yielded a
>     > match (or not, for \code{invert = TRUE}. This will be an
>     > integer vector unless the input
>
>     > There should be a closing parenthesis after \code{invert =
>     > TRUE}
>
> Thank you, Hugh!  I've added the ')' now.
> Martin
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Unclosed parenthesis in grep.Rd

Duncan Murdoch-2
On 05/03/2018 11:48 AM, Etienne Sanchez wrote:

> There are probably more unmatched parentheses around:
>
> detect <- function(file) {
>    text <- paste(readLines(file), collapse = "")
>    nchar(gsub("[^(]", "", text)) != nchar(gsub("[^)]", "", text))
> }
>
> docs <- list.files("r-source-trunk/src/library",
>                     pattern = "\\.Rd$",
>                     full.names = TRUE,
>                     recursive = TRUE)
>
> suspicious <- docs[sapply(docs, detect)]
>
> length(suspicious)
> # [1] 114

Doing an automatic search is a good idea.  Here's a function that finds
some errors that would be missed by yours, and gives a more informative
report.

detect <- function(file) {
   text <- readLines(file)
   letters <- strsplit(text, "")
   line <- unlist(lapply(seq_along(letters), function(i) rep(i,
length(letters[[i]]))))
   column <- unlist(lapply(seq_along(letters), function(i)
seq_len(length(letters[[i]]))))
   letters <- unlist(letters)
   open <- letters == "("
   close <- letters == ")"
   sum <- cumsum(open) - cumsum(close)

   result <- FALSE
   report <- function(msg, where) {
    message(msg, paste(file, line[where], column[where], sep=":"))
    message(text[line[where]])
    message(paste(c(rep(" ", column[where] - 1), "^"), collapse = ""))
    ## rstudioapi::navigateToFile(file, line[where], column[where])
   }
   if (any(sum < 0)) {
    report("Extra close paren: ", match(TRUE, sum < 0))
    result <- TRUE
   }
   if (sum[length(sum)] > 0) {
    report("Extra open paren: ", length(sum) - match(TRUE, rev(sum ==
0)) + 2)
    result <- TRUE
   }
}

If you use RStudio, you can uncomment the ## line to have it jump to the
location of the suspicious entry.

Duncan Murdoch

>
>
> 2018-03-05 9:27 GMT+01:00 Martin Maechler <[hidden email]>:
>>
>>>>>>> Hugh Parsonage <[hidden email]>
>>>>>>>      on Mon, 5 Mar 2018 13:39:24 +1100 writes:
>>
>>      > Lines 129-131: \code{grep(value = FALSE)} returns a vector
>>      > of the indices of the elements of \code{x} that yielded a
>>      > match (or not, for \code{invert = TRUE}. This will be an
>>      > integer vector unless the input
>>
>>      > There should be a closing parenthesis after \code{invert =
>>      > TRUE}
>>
>> Thank you, Hugh!  I've added the ')' now.
>> Martin
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel