Modified version of infolocs that: 1) allows to
return a single data frame by burst or id (parameter "by"); 2) can
simply the output to a vector if a single column is requested (parameter
"simplify"); 3) returns NULL if infolocs exists, but
which is not a colum of it (note that adehabitatLT::infolocs
already returns NULL if there is no infolocs);
Usage
infolocs(ltraj, which, by = c("burst", "id", "none"), simplify = FALSE)Arguments
- ltraj
An object of class
ltraj.- which
An optional character vector containing the names of the variables in the
infolocsattribute to be returned.- by
Character. Either
"burst","id", or"none"to return only one element for all bursts/id together.- simplify
Logical. If a single variable is requested, should the function return 1-column data frames (
FALSE, default) or vector (TRUE).
See also
See infolocs for further details on the
function and all available arguments.
Author
Modified by Mathieu Basille mathieu@basille.org
Examples
## Load puechcirc data, and add some random infolocs:
data(puechcirc)
infolocs(puechcirc)
#> NULL
info <- list(data.frame(A = rnorm(80), B = runif(80), C = rpois(80,
1)), data.frame(A = rnorm(69, 10), B = runif(69, 10, 11),
C = rpois(69, 10)), data.frame(A = rnorm(66, -10), B = runif(66,
-10, -9), C = rpois(66, 100)))
## Watch the row names (for a reason, 'puechcirc[[2]]' starts with line 2):
info <- mapply(function(x, y) {
row.names(x) <- row.names(y)
return(x)
}, info, puechcirc, SIMPLIFY = FALSE)
infolocs(puechcirc) <- info
puechcirc
#>
#> *********** List of class ltraj ***********
#>
#> Type of the traject: Type II (time recorded)
#> * Time zone: Europe/Paris *
#> Regular traject. Time lag between two locs: 600 seconds
#>
#> Characteristics of the bursts:
#> id burst nb.reloc NAs date.begin date.end
#> 1 CH93 CH930824 80 16 1993-08-24 17:00:00 1993-08-25 06:10:00
#> 2 CH93 CH930827 69 17 1993-08-27 19:10:00 1993-08-28 06:30:00
#> 3 JE93 JE930827 66 19 1993-08-27 19:20:00 1993-08-28 06:10:00
#>
#>
#> infolocs provided. The following variables are available:
#> [1] "A" "B" "C"
## Parameters "by" and "simplify"
infolocs(puechcirc, "A", simplify = TRUE)
#> $CH930824
#> [1] -1.400043517 0.255317055 -2.437263611 -0.005571287 0.621552721
#> [6] 1.148411606 -1.821817661 -0.247325302 -0.244199607 -0.282705449
#> [11] -0.553699384 0.628982042 2.065024895 -1.630989402 0.512426950
#> [16] -1.863011492 -0.522012515 -0.052601910 0.542996343 -0.914074827
#> [21] 0.468154420 0.362951256 -1.304543545 0.737776321 1.888504929
#> [26] -0.097445104 -0.935847354 -0.015950311 -0.826788954 -1.512399651
#> [31] 0.935363190 0.176488611 0.243685465 1.623548883 0.112038083
#> [36] -0.133997013 -1.910087468 -0.279237242 -0.313445978 1.067307879
#> [41] 0.070034850 -0.639123324 -0.049964899 -0.251483443 0.444797116
#> [46] 2.755417575 0.046531380 0.577709069 0.118194874 -1.911720491
#> [51] 0.862086482 -0.243236740 -0.206087195 0.019177592 0.029560754
#> [56] 0.549827542 -2.274114857 2.682557184 -0.361221255 0.213355750
#> [61] 1.074345882 -0.665088249 1.113952419 -0.245896412 -1.177563309
#> [66] -0.975850616 1.065057320 0.131670635 0.488628809 -1.699450568
#> [71] -1.470736306 0.284150344 1.337320413 0.236696283 1.318293384
#> [76] 0.523909788 0.606748047 -0.109935672 0.172181715 -0.090327287
#>
#> $CH930827
#> [1] 8.099939 10.935784 9.690948 10.263067 8.209408 9.211741 8.866978
#> [8] 10.363653 9.714112 10.517669 9.897091 9.025930 11.270672 10.960865
#> [15] 10.768721 11.035931 9.526113 8.724665 9.694379 12.211769 8.958332
#> [22] 8.853476 8.324673 11.525939 10.554186 11.993110 9.845879 12.564408
#> [29] 11.061999 11.142695 11.123839 9.602999 9.176739 9.421115 11.763789
#> [36] 10.132992 10.376499 11.138708 11.241263 10.612091 9.570620 11.360461
#> [43] 9.929143 9.727846 7.553320 10.065487 8.901491 9.366822 7.936346
#> [50] 12.648932 8.846602 9.659362 10.786363 8.729487 10.542142 10.075106
#> [57] 10.558514 10.415406 8.547700 10.941206 9.661064 9.924426 10.040204
#> [64] 10.124301 9.001567 11.233390 10.340424 9.527298 10.708753
#>
#> $JE930827
#> [1] -11.392847 -11.142291 -8.295391 -10.080074 -10.437281 -10.119215
#> [7] -9.213537 -10.578945 -10.145427 -9.473542 -8.266422 -8.551343
#> [13] -8.481807 -10.384007 -8.172875 -10.551492 -10.865754 -10.343831
#> [19] -8.937124 -9.186942 -8.196517 -10.105069 -9.017547 -11.713303
#> [25] -10.832020 -8.899508 -10.173820 -9.821188 -10.698429 -10.960449
#> [31] -10.975423 -10.338577 -8.847653 -9.594899 -10.470922 -10.133251
#> [37] -8.773318 -9.667056 -10.347088 -10.098551 -9.965234 -9.613873
#> [43] -9.979169 -9.992413 -9.069156 -10.684750 -9.662598 -10.412138
#> [49] -9.065739 -8.159683 -10.704820 -9.991490 -7.965810 -11.341686
#> [55] -8.841021 -10.203209 -10.378029 -8.263889 -10.845248 -10.961571
#> [61] -8.982509 -11.496054 -11.184819 -9.369766 -7.898747 -10.613737
#>
infolocs(puechcirc, "A", by = "id", simplify = TRUE)
#> $CH93
#> CH931 CH932 CH933 CH934 CH935 CH936
#> -1.400043517 0.255317055 -2.437263611 -0.005571287 0.621552721 1.148411606
#> CH937 CH938 CH939 CH9310 CH9311 CH9312
#> -1.821817661 -0.247325302 -0.244199607 -0.282705449 -0.553699384 0.628982042
#> CH9313 CH9314 CH9315 CH9316 CH9317 CH9318
#> 2.065024895 -1.630989402 0.512426950 -1.863011492 -0.522012515 -0.052601910
#> CH9319 CH9320 CH9321 CH9322 CH9323 CH9324
#> 0.542996343 -0.914074827 0.468154420 0.362951256 -1.304543545 0.737776321
#> CH9325 CH9326 CH9327 CH9328 CH9329 CH9330
#> 1.888504929 -0.097445104 -0.935847354 -0.015950311 -0.826788954 -1.512399651
#> CH9331 CH9332 CH9333 CH9334 CH9335 CH9336
#> 0.935363190 0.176488611 0.243685465 1.623548883 0.112038083 -0.133997013
#> CH9337 CH9338 CH9339 CH9340 CH9341 CH9342
#> -1.910087468 -0.279237242 -0.313445978 1.067307879 0.070034850 -0.639123324
#> CH9343 CH9344 CH9345 CH9346 CH9347 CH9348
#> -0.049964899 -0.251483443 0.444797116 2.755417575 0.046531380 0.577709069
#> CH9349 CH9350 CH9351 CH9352 CH9353 CH9354
#> 0.118194874 -1.911720491 0.862086482 -0.243236740 -0.206087195 0.019177592
#> CH9355 CH9356 CH9357 CH9358 CH9359 CH9360
#> 0.029560754 0.549827542 -2.274114857 2.682557184 -0.361221255 0.213355750
#> CH9361 CH9362 CH9363 CH9364 CH9365 CH9366
#> 1.074345882 -0.665088249 1.113952419 -0.245896412 -1.177563309 -0.975850616
#> CH9367 CH9368 CH9369 CH9370 CH9371 CH9372
#> 1.065057320 0.131670635 0.488628809 -1.699450568 -1.470736306 0.284150344
#> CH9373 CH9374 CH9375 CH9376 CH9377 CH9378
#> 1.337320413 0.236696283 1.318293384 0.523909788 0.606748047 -0.109935672
#> CH9379 CH9380 CH931 CH932 CH933 CH934
#> 0.172181715 -0.090327287 8.099939177 10.935784286 9.690948497 10.263066677
#> CH935 CH936 CH937 CH938 CH939 CH9310
#> 8.209408144 9.211741155 8.866978331 10.363652568 9.714112086 10.517669134
#> CH9311 CH9312 CH9313 CH9314 CH9315 CH9316
#> 9.897091330 9.025930407 11.270672301 10.960864787 10.768721370 11.035930771
#> CH9317 CH9318 CH9319 CH9320 CH9321 CH9322
#> 9.526112926 8.724665125 9.694379326 12.211769487 8.958331619 8.853476150
#> CH9323 CH9324 CH9325 CH9326 CH9327 CH9328
#> 8.324672697 11.525938655 10.554185515 11.993110265 9.845879260 12.564408338
#> CH9329 CH9330 CH9331 CH9332 CH9333 CH9334
#> 11.061999145 11.142694878 11.123838843 9.602998507 9.176738849 9.421115375
#> CH9335 CH9336 CH9337 CH9338 CH9339 CH9340
#> 11.763789378 10.132992146 10.376499328 11.138707653 11.241263075 10.612090945
#> CH9341 CH9342 CH9343 CH9344 CH9345 CH9346
#> 9.570619913 11.360461327 9.929142569 9.727846316 7.553319971 10.065486641
#> CH9347 CH9348 CH9349 CH9350 CH9351 CH9352
#> 8.901491098 9.366821824 7.936345549 12.648932029 8.846601614 9.659362124
#> CH9353 CH9354 CH9355 CH9356 CH9357 CH9358
#> 10.786362576 8.729486890 10.542141549 10.075105900 10.558514422 10.415406399
#> CH9359 CH9360 CH9361 CH9362 CH9363 CH9364
#> 8.547700231 10.941206122 9.661064128 9.924425753 10.040204392 10.124301066
#> CH9365 CH9366 CH9367 CH9368 CH9369
#> 9.001567449 11.233390065 10.340424488 9.527297518 10.708753061
#>
#> $JE93
#> JE931 JE932 JE933 JE934 JE935 JE936 JE937
#> -11.392847 -11.142291 -8.295391 -10.080074 -10.437281 -10.119215 -9.213537
#> JE938 JE939 JE9310 JE9311 JE9312 JE9313 JE9314
#> -10.578945 -10.145427 -9.473542 -8.266422 -8.551343 -8.481807 -10.384007
#> JE9315 JE9316 JE9317 JE9318 JE9319 JE9320 JE9321
#> -8.172875 -10.551492 -10.865754 -10.343831 -8.937124 -9.186942 -8.196517
#> JE9322 JE9323 JE9324 JE9325 JE9326 JE9327 JE9328
#> -10.105069 -9.017547 -11.713303 -10.832020 -8.899508 -10.173820 -9.821188
#> JE9329 JE9330 JE9331 JE9332 JE9333 JE9334 JE9335
#> -10.698429 -10.960449 -10.975423 -10.338577 -8.847653 -9.594899 -10.470922
#> JE9336 JE9337 JE9338 JE9339 JE9340 JE9341 JE9342
#> -10.133251 -8.773318 -9.667056 -10.347088 -10.098551 -9.965234 -9.613873
#> JE9343 JE9344 JE9345 JE9346 JE9347 JE9348 JE9349
#> -9.979169 -9.992413 -9.069156 -10.684750 -9.662598 -10.412138 -9.065739
#> JE9350 JE9351 JE9352 JE9353 JE9354 JE9355 JE9356
#> -8.159683 -10.704820 -9.991490 -7.965810 -11.341686 -8.841021 -10.203209
#> JE9357 JE9358 JE9359 JE9360 JE9361 JE9362 JE9363
#> -10.378029 -8.263889 -10.845248 -10.961571 -8.982509 -11.496054 -11.184819
#> JE9364 JE9365 JE9366
#> -9.369766 -7.898747 -10.613737
#>
infolocs(puechcirc, "A", by = "none", simplify = TRUE)
#> [1] -1.400043517 0.255317055 -2.437263611 -0.005571287 0.621552721
#> [6] 1.148411606 -1.821817661 -0.247325302 -0.244199607 -0.282705449
#> [11] -0.553699384 0.628982042 2.065024895 -1.630989402 0.512426950
#> [16] -1.863011492 -0.522012515 -0.052601910 0.542996343 -0.914074827
#> [21] 0.468154420 0.362951256 -1.304543545 0.737776321 1.888504929
#> [26] -0.097445104 -0.935847354 -0.015950311 -0.826788954 -1.512399651
#> [31] 0.935363190 0.176488611 0.243685465 1.623548883 0.112038083
#> [36] -0.133997013 -1.910087468 -0.279237242 -0.313445978 1.067307879
#> [41] 0.070034850 -0.639123324 -0.049964899 -0.251483443 0.444797116
#> [46] 2.755417575 0.046531380 0.577709069 0.118194874 -1.911720491
#> [51] 0.862086482 -0.243236740 -0.206087195 0.019177592 0.029560754
#> [56] 0.549827542 -2.274114857 2.682557184 -0.361221255 0.213355750
#> [61] 1.074345882 -0.665088249 1.113952419 -0.245896412 -1.177563309
#> [66] -0.975850616 1.065057320 0.131670635 0.488628809 -1.699450568
#> [71] -1.470736306 0.284150344 1.337320413 0.236696283 1.318293384
#> [76] 0.523909788 0.606748047 -0.109935672 0.172181715 -0.090327287
#> [81] 8.099939177 10.935784286 9.690948497 10.263066677 8.209408144
#> [86] 9.211741155 8.866978331 10.363652568 9.714112086 10.517669134
#> [91] 9.897091330 9.025930407 11.270672301 10.960864787 10.768721370
#> [96] 11.035930771 9.526112926 8.724665125 9.694379326 12.211769487
#> [101] 8.958331619 8.853476150 8.324672697 11.525938655 10.554185515
#> [106] 11.993110265 9.845879260 12.564408338 11.061999145 11.142694878
#> [111] 11.123838843 9.602998507 9.176738849 9.421115375 11.763789378
#> [116] 10.132992146 10.376499328 11.138707653 11.241263075 10.612090945
#> [121] 9.570619913 11.360461327 9.929142569 9.727846316 7.553319971
#> [126] 10.065486641 8.901491098 9.366821824 7.936345549 12.648932029
#> [131] 8.846601614 9.659362124 10.786362576 8.729486890 10.542141549
#> [136] 10.075105900 10.558514422 10.415406399 8.547700231 10.941206122
#> [141] 9.661064128 9.924425753 10.040204392 10.124301066 9.001567449
#> [146] 11.233390065 10.340424488 9.527297518 10.708753061 -11.392847056
#> [151] -11.142290768 -8.295391263 -10.080073634 -10.437281240 -10.119215094
#> [156] -9.213537135 -10.578945246 -10.145426885 -9.473542009 -8.266421890
#> [161] -8.551342780 -8.481806851 -10.384007254 -8.172874823 -10.551491750
#> [166] -10.865753541 -10.343831481 -8.937123542 -9.186941796 -8.196516639
#> [171] -10.105068694 -9.017546638 -11.713302622 -10.832019527 -8.899508118
#> [176] -10.173820106 -9.821187982 -10.698429449 -10.960449159 -10.975423042
#> [181] -10.338576503 -8.847652926 -9.594898817 -10.470922497 -10.133251019
#> [186] -8.773317644 -9.667056005 -10.347088466 -10.098550690 -9.965233940
#> [191] -9.613872978 -9.979168772 -9.992413223 -9.069155970 -10.684749941
#> [196] -9.662598487 -10.412137704 -9.065738870 -8.159683259 -10.704819663
#> [201] -9.991489688 -7.965810114 -11.341686068 -8.841020818 -10.203208958
#> [206] -10.378028555 -8.263888957 -10.845247816 -10.961571493 -8.982508947
#> [211] -11.496053742 -11.184818730 -9.369765627 -7.898747486 -10.613736810
## Try to retrieve the column `toto`:
infolocs(puechcirc, "toto")
#> NULL