Skip to content

Commit

Permalink
Fixed as.POSIXct origin bug in phase transitions functions
Browse files Browse the repository at this point in the history
  • Loading branch information
leifeld committed Feb 10, 2024
1 parent 8118bf9 commit 3d6bd05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rDNA/rDNA/DESCRIPTION
@@ -1,6 +1,6 @@
Package: rDNA
Version: 3.0.11
Date: 2024-02-04
Date: 2024-02-10
Title: Discourse Network Analysis in R
Authors@R:
c(person(given = "Philip",
Expand Down
10 changes: 5 additions & 5 deletions rDNA/rDNA/R/rDNA.R
Expand Up @@ -4882,7 +4882,7 @@ dna_phaseTransitions <- function(distanceMethod = "absdiff",

# temporal embedding via MDS
if (!requireNamespace("MASS", quietly = TRUE)) {
mem <- data.frame("date" = as.POSIXct(dates, format = "%d-%m-%Y", tz = "UTC"),
mem <- data.frame("date" = as.POSIXct(dates, tz = "UTC", origin = "1970-01-01"),
"state" = l[[best]]$memberships)
results$states <- mem
warning("Skipping temporal embedding because the 'MASS' package is not installed. Consider installing it.")
Expand All @@ -4892,7 +4892,7 @@ dna_phaseTransitions <- function(distanceMethod = "absdiff",
distmat <- distance_mat + 1e-12
mds <- MASS::isoMDS(distmat) # MDS of distance matrix
points <- mds$points
mem <- data.frame("date" = as.POSIXct(dates, format = "%d-%m-%Y", tz = "UTC"),
mem <- data.frame("date" = as.POSIXct(dates, tz = "UTC", origin = "1970-01-01"),
"state" = l[[best]]$memberships,
"X1" = points[, 1],
"X2" = points[, 2])
Expand Down Expand Up @@ -5084,7 +5084,7 @@ dna_phaseTransitions2 <- function(distanceMethod = "absdiff",

# retrieve mid-point dates (gamma)
m <- .jcall(exporter, "[Lexport/Matrix;", "getMatrixResultsArray") # get list of Matrix objects from Exporter object
dates <- sapply(m, function(x) as.POSIXct(.jcall(x, "J", "getDateTimeLong"), origin = "1970-01-01"))
dates <- sapply(m, function(x) .jcall(x, "J", "getDateTimeLong")) # long integers, still needs conversion to date

# define clustering function
hclustMethods <- c("single", "average", "complete", "ward")
Expand Down Expand Up @@ -5216,7 +5216,7 @@ dna_phaseTransitions2 <- function(distanceMethod = "absdiff",

# temporal embedding via MDS
if (!requireNamespace("MASS", quietly = TRUE)) {
mem <- data.frame("date" = as.POSIXct(dates, format = "%d-%m-%Y", tz = "UTC"),
mem <- data.frame("date" = as.POSIXct(dates, tz = "UTC", origin = "1970-01-01"),
"state" = l[[best]]$memberships)
results$states <- mem
warning("Skipping temporal embedding because the 'MASS' package is not installed. Consider installing it.")
Expand All @@ -5226,7 +5226,7 @@ dna_phaseTransitions2 <- function(distanceMethod = "absdiff",
distmat <- distance_mat + 1e-12
mds <- MASS::isoMDS(distmat) # MDS of distance matrix
points <- mds$points
mem <- data.frame("date" = as.POSIXct(dates, format = "%d-%m-%Y", tz = "UTC"),
mem <- data.frame("date" = as.POSIXct(dates, tz = "UTC", origin = "1970-01-01"),
"state" = l[[best]]$memberships,
"X1" = points[, 1],
"X2" = points[, 2])
Expand Down

0 comments on commit 3d6bd05

Please sign in to comment.