Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
numeroteca
VerbaR
Commits
cc931abc
Commit
cc931abc
authored
Mar 09, 2020
by
numeroteca
Browse files
posibilita crear img de plots en directorios de cada caso
parent
b7622128
Changes
2
Hide whitespace changes
Inline
Side-by-side
analysis/verba-processing.R
View file @
cc931abc
...
...
@@ -3,53 +3,65 @@
# ---- Load libraries -----
library
(
tidyverse
)
# Load data
data
<-
read.delim
(
"data/verba/180320_180430_cifuentes-y-palabras-relacionadas_clasificado.csv"
,
sep
=
","
)
data
<-
read.delim
(
"data/verba/140104_140228_barcenas-palabras-relacionadas_01.csv"
,
sep
=
","
)
data
<-
read.delim
(
"data/verba/140104_140228_messi_01.csv"
,
sep
=
","
)
# Settings ------
# subtitle_text <- "Telediarios de TVE. 20 marzo - 29 abril 2018"
# subtitle_text <- "Telediarios de TVE. 4 enero - 28 febrero 2017"
subtitle_text
<-
"Telediarios de TVE. 1 marzo - 30 junio 2017"
# el_caso <- "caso Máster (Cristina Cifuentes)"
el_caso
<-
"caso Lezo y caso Púnica"
caso_path
<-
"lezo-punica"
# el_caso <- "Messi"
caption_text
<-
"Datos: Verba (Civio). Gráfico: numeroteca.org"
# Load data ---------------
# data <- read.delim("data/verba/180320_180430_cifuentes-y-palabras-relacionadas_clasificado.csv",sep = ",")
# data <- read.delim("data/verba/140104_140228_barcenas-palabras-relacionadas_01.csv",sep = ",")
# data <- read.delim("data/verba/140104_140228_messi_01.csv",sep = ",")
data
<-
read.delim
(
"data/verba/170301_170630_lezo-punica.csv"
,
sep
=
","
)
# Preprocess data -------
# preprocessed data (cifuentes)
i
# preprocessed data (cifuentes)
# data$date <- as.Date(data$date)
# data$date2 <- as.POSIXct(data$date)
# raw vera data
#
Transform
raw ver
b
a data
into date format
data
$
date
<-
as.Date
(
data
$
programme_date
)
# Transforms in to date-time format. TODO: loses hour!
data
$
date2
<-
as.POSIXct
(
data
$
date
)
# create variable Telediario based on programme_date
data
$
telediario_fino
<-
substr
(
data
$
programme_date
,
11
,
13
)
table
(
data
$
telediario_fino
)
# simplifies times
# simplifies times when times are not the standard T15 and T21.
# Transforms T22 and T20 to T21, and T14 to T15.
# T15 is 15:00h program and T21 is 21:00h program
data
[
data
$
telediario_fino
==
"T22"
,]
$
telediario_fino
<-
"T21"
data
[
data
$
telediario_fino
==
"T20"
,]
$
telediario_fino
<-
"T21"
data
[
data
$
telediario_fino
==
"T14"
,]
$
telediario_fino
<-
"T15"
table
(
data
$
telediario_fino
)
# test borrable
# data$id <- as.character(data$id)
# data[data$id == "GxCr-W0BCKkHyZ2v_0lo",]$id <- "wer"
# levels(data$telediario_fino) <- c("15:00h","21.00h")
data
$
date2
[
1
]
+
3600
# Settings
subtitle_text
<-
"Telediarios de TVE. 20 marzo - 29 abril 2018"
subtitle_text
<-
"Telediarios de TVE. 4 enero - 28 febrero 2017"
el_caso
<-
"caso Máster (Cristina Cifuentes)"
el_caso
<-
"caso Lezo y caso Púnica"
el_caso
<-
"Messi"
caption_text
<-
"Datos: Verba. Gráfico: numeroteca.org"
# data$date2[1] + 3600
# Plots ----------------------
# Número de frases por telediario
png
(
filename
=
paste
(
"img/apariciones-n-telediarios-caso
-master
_01.png"
,
sep
=
""
),
width
=
1200
,
height
=
9
00
)
png
(
filename
=
paste
(
"img/
"
,
caso_path
,
"/
apariciones-n-telediarios-
"
,
caso
_path
,
"
_01.png"
,
sep
=
""
),
width
=
1200
,
height
=
7
00
)
ggplot
(
data
=
data
)
+
geom_bar
(
aes
(
x
=
date2
))
+
# si hay clasificación por caso: fill=caso
theme_minimal
(
base_family
=
"Roboto Condensed"
,
base_size
=
22
)
+
scale_x_datetime
(
date_breaks
=
"1 day"
,
date_labels
=
"%d"
)
+
# scale_x_datetime(date_breaks = "1 day", date_labels = "%d") +
scale_x_datetime
(
date_breaks
=
"5 day"
,
date_labels
=
"%d"
,
#secondary axis to add months
sec.axis
=
sec_axis
(
~
.
,
labels
=
scales
::
time_format
(
"%b"
))
)
+
labs
(
title
=
paste
(
"Número de frases sobre "
,
el_caso
,
sep
=
""
),
subtitle
=
subtitle_text
,
x
=
NULL
,
...
...
@@ -58,14 +70,15 @@ ggplot(data = data ) +
theme
(
panel.grid.minor.x
=
element_blank
(),
panel.grid.minor.y
=
element_blank
(),
# panel.grid.major.x = element_blank(),
panel.grid.major.y
=
element_blank
()
panel.grid.major.x
=
element_blank
(),
panel.grid.major.y
=
element_blank
(),
axis.ticks.x
=
element_line
()
)
+
facet_wrap
(
~
telediario_fino
,
ncol
=
1
)
dev.off
()
# Cuando hablan del caso dentro del Telediario
png
(
filename
=
paste
(
"img/apariciones-cuando-telediarios
-
caso
-master
_01.png"
,
sep
=
""
),
width
=
1200
,
height
=
900
)
png
(
filename
=
paste
(
"img/
"
,
caso_path
,
"/
apariciones-cuando-telediarios
_"
,
caso
_path
,
"
_01.png"
,
sep
=
""
),
width
=
1200
,
height
=
900
)
ggplot
(
data
=
data
)
+
#%>% filter( date> "2018-04-01" & date < "2018-04-05" )
geom_rect
(
aes
(
xmin
=
min
(
data
$
date2
+
41000
)
,
xmax
=
max
(
data
$
date2
+
82800
+
40000
),
ymin
=
0
,
ymax
=
90
/
60
),
alpha
=
0.02
,
fill
=
"lightgrey"
)
+
geom_segment
(
aes
(
x
=
date2
+
82800
,
xend
=
date2
+
82800
,
y
=
start_time
/
60
,
yend
=
(
start_time
+30
)
/
60
),
alpha
=
0.8
,
size
=
4
)
+
#, color=caso
...
...
@@ -75,8 +88,8 @@ ggplot(data = data ) + #%>% filter( date> "2018-04-01" & date < "2018-04-05" )
# color="#999999", data =data, curvature = -0.2, size = 0.1) +
# annotate(geom = "text", x = as.POSIXct("2018-03-26"), y = 7, label = "Portada (1:30 minutos)",
# family = "Roboto Condensed", hjust = 0,size=6,size=0.6) +
theme_minimal
(
base_family
=
"Roboto Condensed"
,
base_size
=
22
)
+
scale_x_datetime
(
date_breaks
=
"
3
day"
,
date_labels
=
"%d"
,
expand
=
c
(
0.01
,
0.05
))
+
theme_minimal
(
base_family
=
"Roboto Condensed"
,
base_size
=
18
)
+
scale_x_datetime
(
date_breaks
=
"
1
day"
,
date_labels
=
"%d"
,
expand
=
c
(
0.01
,
0.05
))
+
labs
(
title
=
paste
(
"Cuándo hablan del "
,
el_caso
,
" en los telediarios"
,
sep
=
""
),
subtitle
=
paste
(
subtitle_text
),
x
=
NULL
,
...
...
@@ -85,12 +98,11 @@ ggplot(data = data ) + #%>% filter( date> "2018-04-01" & date < "2018-04-05" )
theme
(
panel.grid.minor.x
=
element_blank
(),
panel.grid.minor.y
=
element_blank
(),
#
panel.grid.major.x = element_blank(),
panel.grid.major.x
=
element_blank
(),
panel.grid.major.y
=
element_blank
()
)
+
facet_wrap
(
~
telediario_fino
,
ncol
=
1
)
dev.off
()
dev.off
()
png
(
filename
=
paste
(
"img/apariciones-cuando-telediarios-caso-master_01_v.png"
,
sep
=
""
),
width
=
900
,
height
=
1200
)
ggplot
(
data
=
data
)
+
#%>% filter( date> "2018-04-01" & date < "2018-04-05" )
...
...
cifuentes
.Rproj
→
verbar
.Rproj
View file @
cc931abc
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment