chop_standard_at: standardized a variable of dataframe according chopped...

Description Usage Arguments Value Examples

View source: R/standard.R

Description

standardized a variable of dataframe after chop first pitch, and discard last pitch when last pitch was less than second-to-last within each group

Usage

1
chop_standard_at(.data, .var, .group, .pitch)

Arguments

.data

data.frame, must contain '.var', '.group' and '.pitch' variables

.var

specify the variables which to be standardized

.group

group variable contained in .data

.pitch

pitch variable contained in .data, each group have same pitch serial, for example, "p0, p10, p20, ... p100"

Value

standardized data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(tidyverse)
library(easyuse)
data(ChineseTones)

d <- ChineseTones

m <- d %>%
  group_by(type) %>%
  summarise_if(is.numeric, mean) %>%
  modify_at(vars(starts_with("p")), log10)

ld <- m %>%
  pivot_longer(
    cols = starts_with("p"),
    names_to = "id",
    values_to = "value"
  ) %>%
  mutate(time = 1000 * time * seq(0, 1, by = 0.1))

ld %>%
  chop_standard_at(.var = value, .group = type, .pitch = id)

perlatex/easyuse documentation built on April 14, 2020, 5:35 a.m.