Skip to content

Commit

Permalink
Add nearestPOI.R
Browse files Browse the repository at this point in the history
  • Loading branch information
davebraze committed Jun 29, 2017
1 parent 6734d45 commit 04a40c6
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 44 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: FDBeye
Type: Package
Title: Functions to Ease Work with Eyetracker Data
Version: 0.0.19
Date: 2016-10-25
Version: 0.0.20
Date: 2017-06-28
Authors@R: c(
person("David", "Braze", email="[email protected]", role=c("aut", "cre")),
person("Tao", "Gong", role="aut"),
Expand All @@ -20,6 +20,7 @@ Imports:
grid,
plyr,
png,
purrr,
stats,
stringr,
tools,
Expand All @@ -35,7 +36,7 @@ License: MIT + file LICENSE
LazyData: true
URL: https://github.com/davebraze/FDBeye
BugReports: https://github.com/davebraze/FDBeye/issues
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
Suggests:
knitr,
rmarkdown
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export(get_xybounds)
export(inked)
export(makeReport)
export(mark_oob)
export(nearestPOI)
export(readELascii)
export(reg2regdef)
export(regdef2ias)
Expand Down
40 changes: 40 additions & 0 deletions R/nearestPOI.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##' @title Find the nearest Point of Interest for each fixation.
##'
##' @description For each fixation in a fixation report, this function
##' will determine the nearest Point of Interest and the
##' fixation's distance from that Point of Interest.
##'
##' @details For each fixation in a fixation report, this function
##' will determine the nearest Point of Interest and the
##' fixation's distance from that Point of Interest.
##'
##' The value of \code{supplement} determines whether to return
##' the POI values within an enriched version of \code{fixReport},
##' or as a simple two column data.frame.
##'
##' @param fixReport A fixation Report as may be created by
##' fixReport(). Must contain columns \code{xpos} and \code{ypos}.
##' @param poiList A data.frame containing x,y coordinates for Points
##' of Interest. The data.frame must contain exactly two columns,
##' named \code{xpos} and \code{ypos}, in that order.
##' @param supplement If TRUE, nearestPOI() will return a data.frame
##' consisting of fixReport suplemented with columns nearestpoi
##' and dist2poi. If FALSE return a 2 column data.frame with just
##' those two columns.
##' @return A data.frame including columns nearestpoi and dist2poi.
##' @author Dave Braze <davebraze@@gmail.com>
##' @export
nearestPOI <- function (fixReport, poiList, supplement=TRUE) {
f <- function(fix=fix, poiList=poiList) {
## Find nearest poi for one fixation.
tmp <- rbind(fix[c("xpos", "ypos")], poi) ## should merge rather than rbind
dst <- as.matrix(dist(tmp))[-1,1]
.nearestpoi <- which.min(dst)
names(.nearestpoi) <- NULL
.dist2poi <- min(dst)
retval <- data.frame(nearestpoi=.nearestpoi, dist2poi=.dist2poi)
}
retval <- purrr::by_row(fixReport, f, poi=poi, .collate="row",
.labels=supplement)
select(retval, -matches("^.row$"))
}
1 change: 0 additions & 1 deletion man/EToralreading.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/FDBeye.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/adjust_y.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/ascAnon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/cat_lines1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/cat_lines2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/cat_lines3.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/cat_lines4.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/edf2asc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/fixPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/fixReport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/getBGcol.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/getChars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/getEyelinkTrialData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/getLines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/getMargins.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/get_start_pts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/get_xybounds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/inked.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/makeReport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/mark_oob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions man/nearestPOI.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 33 additions & 7 deletions man/readELascii.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/reg2regdef.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/regdef2ias.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/region2SRias.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/saccReport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/trial_plots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04a40c6

Please sign in to comment.