Skip to content

Commit f0ff1d1

Browse files
author
Mikkel Roald-Arbøl
committed
First commit
0 parents  commit f0ff1d1

11 files changed

+150
-0
lines changed

.Rbuildignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
^renv$
2+
^renv\.lock$
3+
^.*\.Rproj$
4+
^\.Rproj\.user$

.Rprofile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source("renv/activate.R")

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData
4+
.Ruserdata
5+
renv

DESCRIPTION

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: trackballr
2+
Type: Package
3+
Title: What the Package Does (Title Case)
4+
Version: 0.1.0
5+
Author: Who wrote it
6+
Maintainer: The package maintainer <[email protected]>
7+
Description: More about what it does (maybe more than one line)
8+
Use four spaces when indenting paragraphs within the Description.
9+
License: What license is it under?
10+
Encoding: UTF-8
11+
LazyData: true

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exportPattern("^[[:alpha:]]+")

R/augment_trackball.R

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#' Title
2+
#'
3+
#' @param data
4+
#' @param x
5+
#' @param y
6+
#' @param sampling_rate
7+
#' @param rollmean_k
8+
#' @param mouse_dcpm
9+
#'
10+
#' @return
11+
#' @export
12+
#'
13+
#' @examples
14+
augment_trackball <- function(
15+
data,
16+
x,
17+
y,
18+
sampling_rate = 125,
19+
rollmean_k = 30,
20+
mouse_dcpm = 394
21+
) {
22+
data <- data %>%
23+
mutate(row = row_number(),
24+
time = row / sampling_rate,
25+
x = y_Right,
26+
x = zoo::rollmean(x, k = rollmean_k, fill = NA),
27+
y = y_Left,
28+
y = zoo::rollmean(y, k = rollmean_k, fill = NA),
29+
cum_x = 0,
30+
cum_y = 0) %>%
31+
select(!c(1:4)) %>%
32+
mutate(distance = sqrt(x^2 + y^2) / mouse_dpcm,
33+
v_translation = distance * sampling_rate,
34+
direction = atan2(y,x),
35+
rotation = if_else(abs(x) > 1 & abs(y) > 1,
36+
abs(lag(direction) - direction),
37+
0),
38+
rotation = if_else(rotation > pi, 2*pi - rotation, rotation),
39+
v_rotation = rotation * sampling_rate) %>%
40+
mutate(
41+
x = replace_na(x, 0),
42+
y = replace_na(y, 0))
43+
# filter(distance < 1000) # Filters away trials covering less than 1000 pixels
44+
data$cum_x <- cumsum(data$x)
45+
data$cum_y <- cumsum(data$y)
46+
return(data)
47+
}

R/mode.R

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#' Title
2+
#'
3+
#' @param x A vector of numbers
4+
#'
5+
#' @return
6+
#' @export
7+
#'
8+
#' @examples
9+
mode <- function(x){
10+
which.max(tabulate(x))
11+
}

R/read_data.R

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#' Title
2+
#'
3+
#' @param data
4+
#' @param sensor_names
5+
#'
6+
#' @return
7+
#' @export
8+
#'
9+
#' @examples
10+
read_trackball_from_rdata <- function(
11+
data,
12+
sensor_names = c("Left", "Right")
13+
){
14+
15+
}

man/hello.Rd

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
\name{hello}
2+
\alias{hello}
3+
\title{Hello, World!}
4+
\usage{
5+
hello()
6+
}
7+
\description{
8+
Prints 'Hello, world!'.
9+
}
10+
\examples{
11+
hello()
12+
}

renv.lock

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"R": {
3+
"Version": "4.3.2",
4+
"Repositories": [
5+
{
6+
"Name": "CRAN",
7+
"URL": "https://packagemanager.posit.co/cran/latest"
8+
}
9+
]
10+
},
11+
"Packages": {
12+
"renv": {
13+
"Package": "renv",
14+
"Version": "1.0.3",
15+
"Source": "Repository",
16+
"Repository": "CRAN",
17+
"Requirements": [
18+
"utils"
19+
],
20+
"Hash": "41b847654f567341725473431dd0d5ab"
21+
}
22+
}
23+
}

trackballr.Rproj

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
18+
BuildType: Package
19+
PackageUseDevtools: Yes
20+
PackageInstallArgs: --no-multiarch --with-keep.source

0 commit comments

Comments
 (0)