-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikkel Roald-Arbøl
committed
Mar 17, 2024
0 parents
commit f0ff1d1
Showing
11 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^renv$ | ||
^renv\.lock$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
source("renv/activate.R") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
renv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Package: trackballr | ||
Type: Package | ||
Title: What the Package Does (Title Case) | ||
Version: 0.1.0 | ||
Author: Who wrote it | ||
Maintainer: The package maintainer <yourself@somewhere.net> | ||
Description: More about what it does (maybe more than one line) | ||
Use four spaces when indenting paragraphs within the Description. | ||
License: What license is it under? | ||
Encoding: UTF-8 | ||
LazyData: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exportPattern("^[[:alpha:]]+") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#' Title | ||
#' | ||
#' @param data | ||
#' @param x | ||
#' @param y | ||
#' @param sampling_rate | ||
#' @param rollmean_k | ||
#' @param mouse_dcpm | ||
#' | ||
#' @return | ||
#' @export | ||
#' | ||
#' @examples | ||
augment_trackball <- function( | ||
data, | ||
x, | ||
y, | ||
sampling_rate = 125, | ||
rollmean_k = 30, | ||
mouse_dcpm = 394 | ||
) { | ||
data <- data %>% | ||
mutate(row = row_number(), | ||
time = row / sampling_rate, | ||
x = y_Right, | ||
x = zoo::rollmean(x, k = rollmean_k, fill = NA), | ||
y = y_Left, | ||
y = zoo::rollmean(y, k = rollmean_k, fill = NA), | ||
cum_x = 0, | ||
cum_y = 0) %>% | ||
select(!c(1:4)) %>% | ||
mutate(distance = sqrt(x^2 + y^2) / mouse_dpcm, | ||
v_translation = distance * sampling_rate, | ||
direction = atan2(y,x), | ||
rotation = if_else(abs(x) > 1 & abs(y) > 1, | ||
abs(lag(direction) - direction), | ||
0), | ||
rotation = if_else(rotation > pi, 2*pi - rotation, rotation), | ||
v_rotation = rotation * sampling_rate) %>% | ||
mutate( | ||
x = replace_na(x, 0), | ||
y = replace_na(y, 0)) | ||
# filter(distance < 1000) # Filters away trials covering less than 1000 pixels | ||
data$cum_x <- cumsum(data$x) | ||
data$cum_y <- cumsum(data$y) | ||
return(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#' Title | ||
#' | ||
#' @param x A vector of numbers | ||
#' | ||
#' @return | ||
#' @export | ||
#' | ||
#' @examples | ||
mode <- function(x){ | ||
which.max(tabulate(x)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Title | ||
#' | ||
#' @param data | ||
#' @param sensor_names | ||
#' | ||
#' @return | ||
#' @export | ||
#' | ||
#' @examples | ||
read_trackball_from_rdata <- function( | ||
data, | ||
sensor_names = c("Left", "Right") | ||
){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
\name{hello} | ||
\alias{hello} | ||
\title{Hello, World!} | ||
\usage{ | ||
hello() | ||
} | ||
\description{ | ||
Prints 'Hello, world!'. | ||
} | ||
\examples{ | ||
hello() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"R": { | ||
"Version": "4.3.2", | ||
"Repositories": [ | ||
{ | ||
"Name": "CRAN", | ||
"URL": "https://packagemanager.posit.co/cran/latest" | ||
} | ||
] | ||
}, | ||
"Packages": { | ||
"renv": { | ||
"Package": "renv", | ||
"Version": "1.0.3", | ||
"Source": "Repository", | ||
"Repository": "CRAN", | ||
"Requirements": [ | ||
"utils" | ||
], | ||
"Hash": "41b847654f567341725473431dd0d5ab" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source |