ComenzarEmpieza gratis

Combine data that have timezones

Recall that xts objects store the time index as seconds since midnight, 1970-01-01 in the UTC timezone. merge() uses this underlying index and returns a result with the first object's timezone.

This exercise provides an example. The two objects in your workspace are identical except for the index timezone. The index values are the same instances in time, but measured in different locations. The london object's timezone is Europe/London and the chicago object's timezone is America/Chicago.

Este ejercicio forma parte del curso

Importing and Managing Financial Data in R

Ver curso

Instrucciones del ejercicio

  • Fill in the object names so the result of the merge() will have a London timezone.
  • Use str() to look at the structure of tz_london and note the TZ and the local time range printed in the first line of output.
  • Now complete the merge() command so the result will have a Chicago timezone.
  • Use str() to look at the structure of tz_chicago and note how the TZ and local time range have changed.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Create merged object with a London timezone
tz_london <- merge(___, ___)

# Look at tz_london structure


# Create merged object with a Chicago timezone
tz_chicago <- merge(___, ___)

# Look at tz_chicago structure
Editar y ejecutar código