Análisis Interactivo del Rendimiento de Videos en TikTok

Desarrollo de un dashboard para evaluar métricas de rendimiento de contenidos en TikTok, transformación de datos, genera 4 visualizaciones interactivas (Plotly/ggplot) con interpretaciones detalladas.

library(shiny)
## Warning: package 'shiny' was built under R version 4.4.3
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.3
## Warning: package 'ggplot2' was built under R version 4.4.3
## Warning: package 'tidyr' was built under R version 4.4.3
## Warning: package 'purrr' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
## Warning: package 'stringr' was built under R version 4.4.3
## Warning: package 'forcats' was built under R version 4.4.3
## Warning: package 'lubridate' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)
## Warning: package 'plotly' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(DT)
## Warning: package 'DT' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'DT'
## 
## The following objects are masked from 'package:shiny':
## 
##     dataTableOutput, renderDataTable
tiktok <- read.csv("tiktok_dataset.csv", stringsAsFactors = FALSE)
names(tiktok)
##  [1] "X."                       "claim_status"            
##  [3] "video_id"                 "video_duration_sec"      
##  [5] "video_transcription_text" "verified_status"         
##  [7] "author_ban_status"        "video_view_count"        
##  [9] "video_like_count"         "video_share_count"       
## [11] "video_download_count"     "video_comment_count"

Limpieza y Transformación de Datos

# Renombrar columnas para consistencia
colnames(tiktok) <- tolower(colnames(tiktok))

# Limpieza de caracteres no numéricos (como comas)
tiktok <- tiktok %>%
  mutate(
    video_view_count = as.numeric(gsub(",", "", video_view_count)),
    video_like_count = as.numeric(gsub(",", "", video_like_count)),
    video_comment_count = as.numeric(gsub(",", "", video_comment_count)),
    video_share_count = as.numeric(gsub(",", "", video_share_count))
  )
## Warning: There were 4 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `video_view_count = as.numeric(gsub(",", "",
##   video_view_count))`.
## Caused by warning:
## ! NAs introducidos por coerción
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 3 remaining warnings.
# Eliminar filas incompletas
cat("Filas antes de na.omit:", nrow(tiktok), "\n")
## Filas antes de na.omit: 19382
tiktok <- na.omit(tiktok)
cat("Filas después de na.omit:", nrow(tiktok), "\n")
## Filas después de na.omit: 19084
# Crear variable engagement_rate
tiktok <- tiktok %>%
  mutate(engagement_rate = (video_like_count + video_comment_count + video_share_count) / video_view_count)

Visualizaciones Interactivas

1.- Distribución de vistas de los videos:

plot_ly(tiktok, x = ~video_view_count, type = "histogram", nbinsx = 30) %>%
  layout(title = "Distribución de Vistas",
         xaxis = list(title = "Vistas"),
         yaxis = list(title = "Cantidad de Videos"))

2.- Relación vistas vs likes:

plot_ly(tiktok, x = ~video_view_count, y = ~video_like_count, type = 'scatter', mode = 'markers') %>%
  layout(title = "Relación entre Vistas y Likes",
         xaxis = list(title = "Vistas"),
         yaxis = list(title = "Likes"))

3.- Comparacion entre los Top 20 Videos mas vistos:

top_videos <- tiktok %>%
  arrange(desc(video_view_count)) %>%
  slice_head(n = 20) %>%
  mutate(video_id = factor(video_id, levels = video_id[order(video_view_count)]))

ggplotly(
  ggplot(top_videos, aes(x = video_id, y = engagement_rate)) +
    geom_bar(stat = "identity", fill = "gold") +
    labs(title = "Los 20 Videos más Vistos", x = "Video ID", y = "Engagement Rate") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
)

4.- Correlacion multiple:

plot_ly(tiktok, x = ~video_like_count, y = ~video_comment_count, z = ~video_share_count,
        type = "scatter3d", mode = "markers",
        marker = list(size = 3, color = ~video_view_count, colorscale = 'Viridis')) %>%
  layout(title = "Relación entre Likes, Comentarios y Shares")

Conclusion:

El análisis desarrolla un dashboard que evalua el rendimiento de videos en TikTok, integrando limpieza de datos (normalización, tratamiento de limpieza de datos) y creación de métricas como el engagement rate. Las visualizaciones revelan:

1.- Distribución de vistas concentrada en valores moderados,

2.- Relación positiva entre vistas y likes,

3.- Alta variabilidad en engagement en los top 20 videos. Herramientas como Plotly y ggplot permiten explorar dinámicamente los datos, facilitando la identificación de patrones clave para optimizar estrategias de contenido.

4.- Correlacion multiple que se muestra una relación tridimensional entre engagement (likes, comentarios, shares), con vistas como color para profundidad.