Skip to content

Commit

Permalink
fixed problems of calcFreqs = T in convert_wideToLong() (possibly…
Browse files Browse the repository at this point in the history
… caused by newer version of dplyr?)
  • Loading branch information
raphywink committed Jan 28, 2019
1 parent 9af0e52 commit fb0dd65
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Imports:
RSQLite (>= 1.0.0),
DBI (>= 0.3.1),
httpuv (>= 1.3.2),
dplyr (>= 0.4.3),
dplyr (>= 0.7.8),
readr (>= 1.1.1),
tibble (>= 1.4.2),
purrr (>= 0.2.4),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
* normalize length now also using `list()` with `do.call(rbind, res_list)`
* implemted new `runMINNI` boolean parameter in `runBASwebservice_all()`


## bug fixes

* https default on `serve()`
* fixed problems of `calcFreqs = T` in `convert_wideToLong()` (possibly caused by newer version of dplyr?)


# emuR 1.1.1

Expand Down
12 changes: 6 additions & 6 deletions R/emuR-emuRtrackdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,22 @@ convert_wideToLong <- function(td, calcFreqs = F){
# get col idx values of tracks (T1-TN)
tracks_colIdx = grep(pattern = "^T[0-9]+$", names(td))

tracks_long = dplyr::ungroup(td) %>%
tracks_long = dplyr::ungroup(td) %>%
tidyr::gather(key = "track_name", value = "track_value", min(tracks_colIdx):max(tracks_colIdx), convert = T) %>%
dplyr::mutate(freq = as.numeric(substring(.data$track_name, 2))) %>%
dplyr::group_by(.data$sl_rowIdx) %>%
dplyr::mutate(freq = as.numeric(substring(.data$track_name, 2))) %>%
dplyr::group_by(.data$sl_rowIdx) %>%
dplyr::arrange(.data$freq, .by_group = T)

# calc freq if calcFreqs = F otherwise drop column
if(calcFreqs) {
tracks_long = tracks_long %>%
dplyr::mutate(freq=seq(0, (unique(.data$sample_rate) / 2), length.out = length(tracks_colIdx)))
tracks_long = tracks_long %>%
dplyr::mutate(freq = rep(seq(0, (unique(.data$sample_rate) / 2), length.out = length(tracks_colIdx)), each = n() / length(tracks_colIdx)))
} else{
tracks_long = tracks_long %>%
dplyr::select(-.data$freq)
}

return(tracks_long)
return(dplyr::ungroup(tracks_long))
}

#######################
Expand Down

0 comments on commit fb0dd65

Please sign in to comment.