Skip to content

Conversation

@jangorecki
Copy link
Member

add argument retOrd to return order

unfold C for codecov

closes #2325

} else if (is.null(x)) { # NULL does not satisfy C isVectorAtomic
NA
} else if (is.atomic(x)) {
if (isTRUE(retOrd)) stop("retOrd works only for data.table/list input")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I saw this error message, I would make my vector a list. Should we automatically do list(x) for convenience?

Copy link
Member Author

@jangorecki jangorecki Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On one hand it would be nice, but fsorted that we use for atomic vectors is likely to be much more efficient. So by default it definitely not good to wrap it in list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only wrap it if retOrd == TRUE. That arg would seem to trump performance considerations of fsorted.

}
\arguments{
\item{x}{ data.table type object or atomic vector. }
\item{by}{ data.table columns used to check if \code{x} is sorted by those columns. }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by = seq_along(x) implies an integer argument. Since a character vector is supported, we may want to point it out.

@Rdatatable Rdatatable deleted a comment from codecov bot Apr 14, 2020
@jangorecki
Copy link
Member Author

@ColeMiller1 maybe I should just export forder at the same time... but there is a pending change to it described in #4346

@jangorecki jangorecki added the WIP label Apr 14, 2020
@MichaelChirico MichaelChirico marked this pull request as draft February 19, 2024 04:18
\item{retOrd}{ logical, when \code{TRUE} it will set an attribute \code{"order"} on the returned value, providing an order of \code{x}. Works only for data.table type \code{x}, not for atomic vector. }
}
\details{
Checks if the input is object is sorted. Can check also by a subset of columns provided in \code{by} argument. Can also return an order used in computation when using \code{retOrd} argument.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should possibly mention integer() trick in case for 1:n

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually explained later on, so maybe just a pointer to section in the manual

@jangorecki
Copy link
Member Author

Argument retOrd is overlapping with #3447 and could possibly be removed from this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

export is.sorted

3 participants