jimmcl / trajr Goto Github PK
View Code? Open in Web Editor NEWTrajectory Analysis in R
License: Other
Trajectory Analysis in R
License: Other
Hello.
I have been trying to run TrajsMergeStats on multiple .csv files and I have been getting this error:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 1, 0
I tried tracing back the error and this is what I got:
8: stop(gettextf("arguments imply differing number of rows: %s",
paste(unique(nrows), collapse = ", ")), domain = NA)
7: (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,
fix.empty.names = TRUE, stringsAsFactors = FALSE)
{
data.row.names <- if (check.rows && is.null(row.names))
function(current, new, i) {
if (is.character(current))
new <- as.character(new)
if (is.character(new))
current <- as.character(current)
if (anyDuplicated(new))
return(current)
if (is.null(current))
return(new)
if (all(current == new) || all(current == ""))
return(new)
stop(gettextf("mismatch of row names in arguments of 'data.frame', item %d",
i), domain = NA)
}
else function(current, new, i) {
if (is.null(current)) {
...
6: do.call(data.frame, c(x, alis))
5: as.data.frame.list(row, stringsAsFactors = FALSE, check.names = check.names)
4: as.data.frame(row, stringsAsFactors = FALSE, check.names = check.names)
3: tryCatchList(expr, classes, parentenv, handlers)
2: tryCatch({
result <- data.frame()
nc <- NA
for (trj in trjs) {
pb()
row <- statsFn(trj, ...)
row[sapply(row, is.null)] <- NA
if (is.na(nc))
nc <- length(row)
else if (nc != length(row))
stop(sprintf("Statistics for trajectory %d contains %d values, but expected %d",
nrow(result), length(row), nc))
dfrow <- as.data.frame(row, stringsAsFactors = FALSE,
check.names = check.names)
result <- rbind(result, dfrow)
}
result
}, finally = pb(close = TRUE))
1: TrajsMergeStats(CSHL_trjs_raw, masterTrajectory, progressBar = "win")
Any idea what the issue is? my csv files have the same number of columns and I even tried making them the same number of rows and still got the same error.
Hi There,
I'm having issues applying TrajFromCoords to a list of dataframes.
This is probably an easy fix, but I've tried all the dumb things to fix and am still coming up empty. I have a list called nosetracks, which is the x,y coordinates for nose position of a mouse on a table. It consists of 178 elements, each element is a dataframe named for the mouseID_trialnumber_date. All the dataframes have the same structure: 3 columns, "x", "y", and "nose.frame", in that order. "x" and "y" are the coordinates of the nose in the arena and "nose.frame" is the video frame (50 fps).
I am using the following code to apply the function to my list of dataframes.
nosetracks <- lapply(nosetracks, TrajFromCoords)
When I try to apply the function TrajFromCoords over the list, I get the error:
Error in .checkCoords(trj) :
Trajectory contains missing coordinate or time values, first row with NA is 409
I have tried to troubleshoot this as much as I can:
So I guess my question is - what am I doing wrong? Is a missing value actually the problem, or is something else not getting called correctly? Suggestions for how to diagnose the problematic dataframe (given that the list contains over 100 elements, going through them indvidually isn't really very appealing).
Thanks in advance!
The function is described as: Reads multiple trajectories from files, performs some basic sanity checks on them, and optionally smooths and scales them. Attempts to collect and report errors for multiple trajectories in a single call.
However, although smoothP = 3, smoothN = 41,
are changeable smoothing parameters, you can't actually set these to zero or give TrajsBuild() the command to NOT apply smoothing.
Would be very useful!
Internally, csvReadFn is automatically called with the "stringsAsFactors = FALSE" as an argument, an argument which isn't universal to CSV-reading functions: it only works with utils::read.csv() and utils::read.csv2().
With the tidyverse "readr" package, read_csv() doesn't have "stringsAsFactors" as an accepted argument, so when the internal coordList <- csvReadFn(fileName, stringsAsFactors = FALSE)
runs, I get an error. I had to make a wrapper function for read_csv() that accepted the "stringsAsFactors" argument and never used it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.