Open b-steve opened 5 months ago
I've implemented it so:
traps
object does not have an x
and y
column, we assign the colnames x
and y
respectivley to the traps
object.y
as first column, x
as second) then we leave it as is. If any change is required, warning is output:
Warning message:
In FUN(X[[i]], ...) :
'traps' object missing required column names 'x' and 'y'. Columns will be renamed.
(Not really sure about this message, maybe you could think of a better warning?)
Works for list of traps, for example when multiple session data is present. Also works for NULL trap names. (Anymore edge cases?)
Sidenote: Found out is.list(data.frame())
returns TRUE??? But is(data.frame(), 'list')
returns false... WHYY :(
Additional sidenote: I've added the check in read.acre()
rather than create.capt()
as I felt it was more appropriate here, maybe you have different opinion.
Thanks! Let's add the check that the traps
object has two columns. For the warning message, how about this?
"The
traps
object is missing the column namesx
andy
. The first and second columns are being treated as the x- and y-coordinates, respectively".
The
traps
argument provided toread.acre()
needs to have columns namedx
andy
. At the moment, if you forget to name your columns, thenread.capt()
executes without error, but functions applied to the resulting object (e.g.,plot(data, type = "capt")
) do result in errors and it's not obvious to the user what their mistake was.Some possible solutions:
read.acre()
to throw an informative error when the columns intraps
are not namedx
andy
.read.acre()
to name the columnsx
andy
if they are not named.The latter is easier for the user, but the former would assume the first column provides the x-coordinate and the second column provides the y-coordinate, which might be risky.