ComenzarEmpieza gratis

Groups of mutants

In addition to calculating summary statistics by group, you can mutate columns with group-specific values. For example, one technique to normalize values is to subtract the mean, then divide by the standard deviation. You could perform group-specific normalization using the following code.

a_tibble %>%
  group_by(grp1, grp2) %>%
  mutate(normalized_x = (x - mean(x)) / sd(x))

Este ejercicio forma parte del curso

Introduction to Spark with sparklyr in R

Ver curso

Instrucciones del ejercicio

A Spark connection has been created for you as spark_conn. A tibble attached to the track metadata stored in Spark has been pre-defined as track_metadata_tbl.

  • Group the contents of track_metadata by artist_name.
  • Add a new column named time_since_first_release.
    • Make this equal to the groupwise year minus the first year (that is, the min() year) that the artist released a track.
  • Arrange the rows in descending order of time_since_first_release.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# track_metadata_tbl has been pre-defined
track_metadata_tbl

track_metadata_tbl %>%
  # Group by artist
  ___ %>%
  # Calc time since first release
  ___ %>%
  # Arrange by descending time since first release
  ___
Editar y ejecutar código