I try to make a plot with legend for both horizontal lines and vertical lines. Now I would like to test out whether I can add if statement base on the event status.
For the df with both Delay and Sick, my codes works. But if I want to modify the my plotting part so I can use it on a df that might only have Delay or Sick, what should I with my geom_vline and scale_linetype_manualpart? for example, if I want to use my codes on df2.
df<-structure(list(Day = c(0L, 0L, 0L, 1L, 1L, 1L, 8L, 8L, 8L, 15L,
15L, 15L, 22L, 22L, 22L, 27L, 29L, 29L, 29L, 36L, 36L, 36L, 43L,
43L, 43L, 43L, 43L, 43L), Subject = c("ELA", "Math", "Art", "Math",
"Art", "ELA", "ELA", "Math", "Art", "ELA", "Math", "Art", "ELA",
"Math", "Art", NA, "ELA", "Math", "Art", "ELA", "Math", "Art",
"Art", "Art", "Math", "Math", "ELA", "ELA"), Score = c(73L, 157L,
75L, 111L, 82L, 69L, 78L, 131L, 93L, 58L, 109L, 99L, 79L, 131L,
84L, NA, 67L, 106L, 90L, 75L, 123L, 95L, 122L, 122L, 137L, 137L,
83L, 83L), Event = c(NA, NA, NA, "Delay", "Delay", "Delay", NA,
NA, NA, NA, NA, NA, NA, NA, NA, "Sick", NA, NA, NA, NA, NA, NA,
"Sick", "Delay", "Sick", "Delay", "Sick", "Delay")), class = "data.frame", row.names = c(NA,
-28L))
ggplot(data =df)+
geom_line(data=df[!is.na(df$Score),],aes(x = Day, y = Score, color=Subject),size=0.8)+
scale_colour_manual(breaks = c("ELA", "Math", "Art"),
values=c(ELA="#cc0022",Math="#70ad47", Art="#fd9300"))+
geom_vline(data=df[(!is.na(df$Event)&df$Event=="Delay"),], aes(xintercept=jitter(Day), linetype="Delay"), color="black", size=0.4)+
geom_vline(data=df[(!is.na(df$Event)&df$Event=="Sick"),], aes(xintercept=jitter(Day), linetype="Sick"), color="purple", size=0.4)+
scale_linetype_manual(name = 'Event',
values = c('Delay' = 1,
'Sick' = 1),
guide = guide_legend(override.aes = list(colour = c("black",
"purple"))))
df2 <-structure(list(Day = c(0L, 0L, 0L, 1L, 1L, 1L, 8L, 8L, 8L, 15L,
15L, 15L, 22L, 22L, 22L, 27L, 29L, 29L, 29L, 36L, 36L, 36L, 43L,
43L, 43L, 43L, 43L, 43L), Subject = c("ELA", "Math", "Art", "Math",
"Art", "ELA", "ELA", "Math", "Art", "ELA", "Math", "Art", "ELA",
"Math", "Art", NA, "ELA", "Math", "Art", "ELA", "Math", "Art",
"Art", "Art", "Math", "Math", "ELA", "ELA"), Score = c(73L, 157L,
75L, 111L, 82L, 69L, 78L, 131L, 93L, 58L, 109L, 99L, 79L, 131L,
84L, NA, 67L, 106L, 90L, 75L, 123L, 95L, 122L, 122L, 137L, 137L,
83L, 83L), Event = c(NA, NA, NA, "Delay", "Delay", "Delay", NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, "Delay", NA, "Delay")), class = "data.frame", row.names = c(NA,
-28L))
I am thinking using sth like this (they don't work)
df<-df2
ggplot(data =df)+
geom_line(data=df[!is.na(df$Score),],aes(x = Day, y = Score, color=Subject),size=0.8)+
scale_colour_manual(breaks = c("ELA", "Math", "Art"),
values=c(ELA="#cc0022",Math="#70ad47", Art="#fd9300"))+
{if (grepl("Delay", df$Event)) geom_vline(data=df[(!is.na(df$Event)&df$Event=="Delay"),], aes(xintercept=jitter(Day), linetype="Delay"), color="black", size=0.4)}+
{if (grepl("Sick", df$Event)) geom_vline(data=df[(!is.na(df$Event)&df$Event=="Sick"),], aes(xintercept=jitter(Day), linetype="Sick"), color="purple", size=0.4)}+
scale_linetype_manual(name = 'Event',
values = c('Delay' = 1,
'Sick' = 1),
guide = guide_legend(override.aes = list(colour = c("black",
"purple"))))
Code chunk 3:
ggplot(data =df)+
geom_line(data=df[!is.na(df$Score),],aes(x = Day, y = Score, color=Subject),size=0.8)+
scale_colour_manual(breaks = c("ELA", "Math", "Art"),
values=c(ELA="#cc0022",Math="#70ad47", Art="#fd9300"))+
geom_vline(data=df[(!is.na(df$Event)&df$Event=="Delay"),], aes(xintercept=jitter(Day),linetype="Delay"), color="black", size=0.4)+
# geom_vline(data=df[(!is.na(df$Event)&df$Event=="Sick"),], aes(xintercept=jitter(Day) ), color="purple", size=0.4)+
scale_linetype_manual(name = 'Event',
values = c(
"Delay" = 1,
"Sick" = 1
),
guide = guide_legend(override.aes = list(colour = c("black",
"purple"))))
With using an if to add the layers you are on the right track. Instead of putting the conditions inside the ggplot code personally I prefer to setup the conditional layers outside of ggplot code and best to put everything inside a function.
Doing so, one option to achieve your desired result may look like so:
EDIT Additionally, instead of using the hack via the linetype aes to get a separate legend you could use the ggnewscale package to add a second color legend. One benefit is that we need no fiddling via override.aes and no additional conditioning to manage the different cases:
library(ggplot2)
plot_fun <- function(df) {
is_delay <- !is.na(df$Event) & df$Event == "Delay"
is_sick <- !is.na(df$Event) & df$Event == "Sick"
layer_delay <- if (any(is_delay)) geom_vline(data = df[is_delay, ], aes(xintercept = jitter(Day), color = "Delay"), size = 0.4)
layer_sick <- if (any(is_sick)) geom_vline(data = df[is_sick, ], aes(xintercept = jitter(Day), color = "Sick"), size = 0.4)
ggplot(data = df) +
geom_line(data = df[!is.na(df$Score), ], aes(x = Day, y = Score, color = Subject), size = 0.8) +
scale_colour_manual(
breaks = c("ELA", "Math", "Art"),
values = c(ELA = "#cc0022", Math = "#70ad47", Art = "#fd9300"),
) +
ggnewscale::new_scale_color() +
layer_delay +
layer_sick +
scale_colour_manual(
name = "Event",
values = c(Delay = "black", Sick = "purple"),
limits = force
)
}
plot_fun(df2)
Related
I've been experimenting with the TikTok Scraper tool (https://github.com/drawrowfly/tiktok-scraper/) for a little while and, while I'm not a expert, I've been using R for some of the more simples analysis of the scraped data, but I've experiencing issues with the hashtags scraping.
Whenever I scrape data from, let's say, an specific hashtag, I receive data in a format that's not very suitable for my work, for instance:
***[{"id":"1662240138893317","name":"globolixoo","title":"","cover":""},{"id":"56170","name":"mentira","title":"","cover":""}]***
All that interests to me are the terms that come after "name": — that is, 'globolixoo' and 'mentira'.
Is there any way in which I can isolate these terms and separate them by comma (globolixoo,mentira)?
Reproducible code example:
dput(head(globolixoo, 10)
structure(list(id = c(6808536063938710528, 6814233256737786880,
6825734509393103872, 6945455970969488384, 6949635086916635648,
6970340938765978624, 6971908200639630336, 6973074032547613696,
6973112184809212928, 6973333129226505216), secretID = c(6808536063938710528,
6814233256737786880, 6825734509393103872, 6945455970969488384,
6949635086916635648, 6970340938765978624, 6971908200639630336,
6973074032547613696, 6973112184809212928, 6973333129226505216
), webVideoUrl = c("https://www.tiktok.com/#aguiarsillvabarbe/video/6808536063938710790",
"https://www.tiktok.com/#deysetavares77/video/6814233256737787141",
"https://www.tiktok.com/#davinunesrocha1988/video/6825734509393104134",
"https://www.tiktok.com/#fernandomedeiros84/video/6945455970969488646",
"https://www.tiktok.com/#marcoaaspm/video/6949635086916635909",
"https://www.tiktok.com/#diverticity/video/6970340938765978885",
"https://www.tiktok.com/#erick.castrooficial/video/6971908200639630597",
"https://www.tiktok.com/#dublagem19/video/6973074032547613958",
"https://www.tiktok.com/#dublagem19/video/6973112184809213189",
"https://www.tiktok.com/#dublagem19/video/6973333129226505478"
), text = c("#GloboLixoo", "#globolixoo", "#GLOBOLIXOO 🤮🤮",
"#GloboLixoo", "#globolixoo", "#globolixoo #mentira kkkkkkk",
"E assim foi a minha chegada aqui... valeu galera ❤️ #lulaxbolsonaro #globolixoo x #bolsonaro2022 #foryou #fory #fyyy #golpista #obrigadogalera",
"Responder a #luizguilhermeol2 #flamengooooo #paravocefo #dublagem19 #flamengosergipe #copaamerica #flamengo #flamengolibertadores #Eriksen #globolixoo",
"Responder a #vinicius.almeida829 #globolixoo #flamengolibertadores #flamengo #copaamerica #flamengosergipe #dublagem19 #neymar #globol",
"#neymar #Eriksen #globolixoo #flamengolibertadores #dublagem19 #flamengosergipe #copaamerica #foryoupage #paravoce #globolixooo #flamengo #fyyy"
), createTime = c(1585235836L, 1586562318L, 1589240162L, 1617114988L,
1618088013L, 1622908971L, 1623273877L, 1623545319L, 1623554204L,
1623605644L), date = c("26/03/2020", "10/04/2020", "11/05/2020",
"30/03/2021", "10/04/2021", "05/06/2021", "09/06/2021", "13/06/2021",
"13/06/2021", "13/06/2021"), authorMeta.id = c(6807209790076404736,
6808216797218505728, 6822488437678539776, 6573364480217792512,
6949596571051525120, 6801837537368605696, 6817099676148990976,
6890609472302023680, 6890609472302023680, 6890609472302023680
), authorMeta.secUid = c("MS4wLjABAAAAUCftiaqGW7kGk4tZlB2socpml7caR7G1BWDVPCMoZeYPYxujhgejBN79QwvG47Ux",
"MS4wLjABAAAANtz2eThsfv8a4hhYR3pX1u2IBHhIX6cQfd9yefX7BjTph4ZafKiw68EYJF3fuqj9",
"MS4wLjABAAAAasFrM5NNvAW8xmzQHoI26Boc1FDwureCXdg2kC5i7maZJRxrtehC_SGJmYRx0cvf",
"MS4wLjABAAAAlepLE-8A44KU_01sgDHePJ0W4XP3EjRYSuOAssGWuGKj_vP2lpyX-OucAhZTmHMF",
"MS4wLjABAAAANc_0vx6MTxJZYFTWUAgyKfG8yzgyW6ujL-pVYsKKpYom2YyhTeOWItG9bEN70fZW",
"MS4wLjABAAAAK10peXSI-KJUKrtQQ_SeWMO4QS7NbxII7BwzudZFY4aws4UdhpjgQ-_0N4bgtQAF",
"MS4wLjABAAAATIlZhohPSapj2p7BEUMG6JM4uQJ9S85Qeg2V_f-il28SnrBMezeIpz6SKuDZVqNN",
"MS4wLjABAAAADWuMEBp9pN_j63r3o8eKwOqxArviqnWQvs-ENGvU03_XPiF2h2ttQubAws_xr3De",
"MS4wLjABAAAADWuMEBp9pN_j63r3o8eKwOqxArviqnWQvs-ENGvU03_XPiF2h2ttQubAws_xr3De",
"MS4wLjABAAAADWuMEBp9pN_j63r3o8eKwOqxArviqnWQvs-ENGvU03_XPiF2h2ttQubAws_xr3De"
), authorMeta.name = c("aguiarsillvabarbe", "deysetavares77",
"davinunesrocha1988", "fernandomedeiros84", "marcoaaspm", "diverticity",
"erick.castrooficial", "dublagem19", "dublagem19", "dublagem19"
), authorMeta.nickName = c("Aguiar Sillva Barbei", "Kayque Jesus",
"Davi Nunes Rocha", "Fernando Medeiros", "user9898887549048",
"diverticity", "Erick Rosário", "Ramon Santos", "Ramon Santos",
"Ramon Santos"), authorMeta.verified = c(FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), authorMeta.signature = c("",
"me seguem no tik Tok gentee meu Instagram é #deyse3760", "",
"", "Sou um cara legal que adora tomar umas cervejas e fazer um bom churrasco...",
"", "Jornalista | Pregador do Evangelho\n\nEX GLOBAL\nInsta:#erick_castrooficial",
"muito obrigado pelo 90k 🙏🙏🙏🔥", "muito obrigado pelo 90k 🙏🙏🙏🔥",
"muito obrigado pelo 90k 🙏🙏🙏🔥"), authorMeta.avatar = c("https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1662059894232070~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=3jVCVxW73fDbv5a8uBjE1fMuJJ4%3D",
"https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1663890951712774~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=K0TDOlOzj9bS799Mj8oOwSbWO4w%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/3537e047a2d150a5a92818b60384bef8~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=OW8A5M8UcE%2FmxzDSrBf8prN1CdM%3D",
"https://p16-sign-sg.tiktokcdn.com/aweme/1080x1080/tos-alisg-avt-0068/d2023f10221a1d54c397daba7ccc0d6b.jpeg?x-expires=1645729200&x-signature=InxZURrUyON59BteEQh7bRb%2BwUk%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/6101bb4cfb128c83b13fca38fd8ca287~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=sLrJEDFV9A5tNGjcfpwxyj7dGYw%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/64e95501c830600a62821559501e07db~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=WjHD2HdtncdadQ7RzCgrHHNjtD4%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e30c6d0e954ec431cbb9aafaaf04dd8a~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=ExL8tsDlKLdjCQEVIaSuRPGkHjI%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=fyUaERy2FytRbrfrwvoONCfvzok%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=fyUaERy2FytRbrfrwvoONCfvzok%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=aGj0%2BhUt%2B3IUSfSDhxaokf%2BqACY%3D"
), authorMeta.following = c(36L, 91L, 86L, 2091L, 17L, 103L,
19L, 0L, 0L, 0L), authorMeta.fans = c(23L, 54L, 61L, 1741L, 5L,
9L, 14900L, 103800L, 103800L, 103800L), authorMeta.heart = c(87L,
536L, 5L, 9168L, 2L, 67L, 149400L, 1800000L, 1800000L, 1800000L
), authorMeta.video = c(13L, 90L, 1L, 78L, 1L, 7L, 45L, 1388L,
1388L, 1388L), authorMeta.digg = c(27L, 101L, 772L, 6976L, 429L,
203L, 202L, 1964L, 1964L, 1964L), musicMeta.musicId = c(6808524996944628736,
6814115937994755072, 6817770512362654720, 6945455736818371584,
6949634983900351488, 6970340831324605440, 6971908113897098240,
6973073959780731904, 6.973112023635e+18, 6973333140853115904),
musicMeta.musicName = c("som original", "som original", "som original",
"som original", "som original", "som original", "som original",
"som original", "som original", "som original"), musicMeta.musicAuthor = c("Aguiar Sillva Barbei",
"Tik Toker", "Lennon Rikelme", "Fernando Medeiros", "user9898887549048",
"diverticity", "Erick Rosário", "Ramon Santos", "Ramon Santos",
"Ramon Santos"), musicMeta.musicOriginal = c(TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), musicMeta.musicAlbum = c("",
"", "", "", "", "", "", "", "", ""), musicMeta.playUrl = c("https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1662238588713990.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1663603269018645.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/1664496548264966.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6945455944255998726.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6949635075508144902.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6970340898207025925.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6971908181308099334.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6973074061354191622.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6973112153297849093.mp3",
"https://sf16-ies-music-va.tiktokcdn.com/obj/musically-maliva-obj/6973333227930929925.mp3"
), musicMeta.coverThumb = c("https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1662059894232070~c5_100x100.jpeg?x-expires=1645729200&x-signature=a1nedaPq0w3fUNs5D22xou27Z%2Bc%3D",
"https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1594805258216454~c5_100x100.jpeg?x-expires=1645729200&x-signature=i2VoIQdaLgOIlElF4mtFV9fj36E%3D",
"https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1663882871894021~c5_100x100.jpeg?x-expires=1645729200&x-signature=w2LXI2Vx7B8hNRu%2FkMzKzJG81K8%3D",
"https://p16-sign-sg.tiktokcdn.com/aweme/100x100/tos-alisg-avt-0068/d2023f10221a1d54c397daba7ccc0d6b.jpeg?x-expires=1645729200&x-signature=wkmBrklJdcU39hh9FxjCIyoMMqI%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/6101bb4cfb128c83b13fca38fd8ca287~c5_100x100.jpeg?x-expires=1645729200&x-signature=I4CPAUy9pAnJNEodE%2FrRXNvG5zY%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/64e95501c830600a62821559501e07db~c5_100x100.jpeg?x-expires=1645729200&x-signature=PnoiAzDZ0qjn5gcXmgGpA12Fhww%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e30c6d0e954ec431cbb9aafaaf04dd8a~c5_100x100.jpeg?x-expires=1645729200&x-signature=ycXJmPSP%2BoyeTy9Pu%2FB6O8gCqHM%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_100x100.jpeg?x-expires=1645729200&x-signature=%2FDtsgOj9hhwtvWxTcFU9xfzalZw%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_100x100.jpeg?x-expires=1645729200&x-signature=%2FDtsgOj9hhwtvWxTcFU9xfzalZw%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_100x100.jpeg?x-expires=1645729200&x-signature=%2FDtsgOj9hhwtvWxTcFU9xfzalZw%3D"
), musicMeta.coverMedium = c("https://p77-sign-va.tiktokcdn.com/musically-maliva-obj/1662059894232070~c5_720x720.jpeg?x-expires=1645729200&x-signature=On0S4nK%2Bj0cj%2Bgc7Zj12gNThUTw%3D",
"https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1594805258216454~c5_720x720.jpeg?x-expires=1645729200&x-signature=vCTDjooZXVQIrMnqUEATBgA2IkY%3D",
"https://p77-sign-va.tiktokcdn.com/musically-maliva-obj/1663882871894021~c5_720x720.jpeg?x-expires=1645729200&x-signature=rJiFs4s%2BruqpkZniOSH52THHdZI%3D",
"https://p16-sign-sg.tiktokcdn.com/aweme/720x720/tos-alisg-avt-0068/d2023f10221a1d54c397daba7ccc0d6b.jpeg?x-expires=1645729200&x-signature=dBlHfEjQmyY6bcTKbN1ZFM%2FweFs%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/6101bb4cfb128c83b13fca38fd8ca287~c5_720x720.jpeg?x-expires=1645729200&x-signature=VXZNIjK%2F8Pb76ae6T1OEopppdQU%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/64e95501c830600a62821559501e07db~c5_720x720.jpeg?x-expires=1645729200&x-signature=PmEV2A4ZH60bT4aqD3gKfw7TCW8%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e30c6d0e954ec431cbb9aafaaf04dd8a~c5_720x720.jpeg?x-expires=1645729200&x-signature=1kuaJwOm%2BqqiJx7AsQszNy2NMr8%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_720x720.jpeg?x-expires=1645729200&x-signature=OveZTX%2BR936jcxq1B%2BwRtYZ4J6E%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_720x720.jpeg?x-expires=1645729200&x-signature=OveZTX%2BR936jcxq1B%2BwRtYZ4J6E%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_720x720.jpeg?x-expires=1645729200&x-signature=OveZTX%2BR936jcxq1B%2BwRtYZ4J6E%3D"
), musicMeta.coverLarge = c("https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1662059894232070~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=3jVCVxW73fDbv5a8uBjE1fMuJJ4%3D",
"https://p16-sign-va.tiktokcdn.com/musically-maliva-obj/1594805258216454~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=DSd1ljPdAH68x0r%2Fmc%2Fu12ZJZRo%3D",
"https://p77-sign-va.tiktokcdn.com/musically-maliva-obj/1663882871894021~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=xpRL3daRlDn9LNFeSFcvA0AZGws%3D",
"https://p16-sign-sg.tiktokcdn.com/aweme/1080x1080/tos-alisg-avt-0068/d2023f10221a1d54c397daba7ccc0d6b.jpeg?x-expires=1645729200&x-signature=InxZURrUyON59BteEQh7bRb%2BwUk%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/6101bb4cfb128c83b13fca38fd8ca287~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=sLrJEDFV9A5tNGjcfpwxyj7dGYw%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/64e95501c830600a62821559501e07db~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=WjHD2HdtncdadQ7RzCgrHHNjtD4%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e30c6d0e954ec431cbb9aafaaf04dd8a~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=ExL8tsDlKLdjCQEVIaSuRPGkHjI%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=fyUaERy2FytRbrfrwvoONCfvzok%3D",
"https://p77-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=fyUaERy2FytRbrfrwvoONCfvzok%3D",
"https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/b4fab700030364d677fcfff56d7aa97d~c5_1080x1080.jpeg?x-expires=1645729200&x-signature=aGj0%2BhUt%2B3IUSfSDhxaokf%2BqACY%3D"
), musicMeta.duration = c(60L, 10L, 14L, 24L, 18L, 59L, 14L,
180L, 180L, 180L), covers.default = c("https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/cba99e4cfab94a30932daf9bd8a46aa9?x-expires=1645664400&x-signature=HmbzlKuZcnhJJdJTDpujB9JElMs%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/e9bbf48d5fff4f399c1568090067e4c9?x-expires=1645664400&x-signature=vi4vhiZA6dRelsrXz6oUYmEqRek%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/271443a40840420abf0ecd036e93b0c4?x-expires=1645664400&x-signature=mqthAEBfkyi56%2Fu8MC0xJbi4omA%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/539c578051b043d8889a0e82b32a214c?x-expires=1645664400&x-signature=zBv3io%2BZd%2Bj%2Bj8Dtqh8TDGf%2FT4E%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/306c760b089741f7bbb2dbaddc714c31?x-expires=1645664400&x-signature=HcAc%2FRN0dV57JmGwQxbU%2BrDpp1E%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/e987bd46d1ad48258264bf8847588f3e?x-expires=1645664400&x-signature=26NvQDYhNN48exwTgCchKFZ%2FH6Y%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/aab8becb2c4d4e5292446c470f33f186?x-expires=1645664400&x-signature=shVdO9EvuLLxjqbNdep4WRoUeMs%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/e60326c0b2fb40a986bec1a1128123f7?x-expires=1645664400&x-signature=eGdid0FIXehKUfSTny5S%2FEWgf%2B8%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/10bd7e951b39441292b3364c374ce0e8?x-expires=1645664400&x-signature=C7ehfu%2FaHzAbPOOp4WBjZwxzsrY%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/9b5285ab683a4c928c2fd19a1f1fcad4?x-expires=1645664400&x-signature=Ia%2BnIAVQYYhboyQ84afNrkOSfRE%3D"
), covers.origin = c("https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/88a5033dfd6f411a9f233455685fa975_1585235839?x-expires=1645664400&x-signature=ChSD93ExjeuP0Bl4Mppiug%2F%2BVAI%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/483d9a6ae7fd4ae4a307c8f4b2cede68_1586563171?x-expires=1645664400&x-signature=Kat8K7YUp4skHR4Dg143lkFUwBo%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/25836970e87040739a72ee538bdaba99_1589240164?x-expires=1645664400&x-signature=%2FNA63Ve%2BEndyFYZJjiHLix3Xa7w%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/b14fa4a08ce74d618ad8a2a426282c84_1617114990?x-expires=1645664400&x-signature=J27jTvMFfhY0ue%2FFETdOcj9zWtU%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/f8a1e34f99e549cf879e0d579dc0707d_1618091022?x-expires=1645664400&x-signature=ub%2F3iB0ZeprBm6%2Fa%2B0IQbpXHLiQ%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/b9f7d74e798c4e6bbc6a0c562853497d_1622908973?x-expires=1645664400&x-signature=wRsztCSJ9SnNU8H4VjnHgZ3gZbM%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/bac4272ae8b14ca38e5fedfc1dfc40ce_1623273879?x-expires=1645664400&x-signature=yadqVt9uR3RPNBCE72YLMtG3ROE%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/558cec2e9a184db590a07a4405ed5702_1623545323?x-expires=1645664400&x-signature=Q9hSOOQoKd8nO8K73yPYVudm4iQ%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/fb68eb9a289d4828a7371a2f7a178f2d_1623554205?x-expires=1645664400&x-signature=l1k4xFcTaDSEIL2VOPwxUhQeNX0%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/b1a0e437d39b440ea0e405112949d220_1623605646?x-expires=1645664400&x-signature=vz13KzRITsWUyseBduWTOz2xZ4E%3D"
), covers.dynamic = c("https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/1c3ce2c68cff4f0982410301f60f0246_1585235840?x-expires=1645664400&x-signature=U%2FbcCJuu9u8T%2FmfARMAPO1fntPM%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/82136e8de6ef4febb646a98a292437a0_1586563170?x-expires=1645664400&x-signature=%2FPKHw0L2fLSUjMe5DsqjEKcuoSo%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/d44ba90030974009bf0d7beb44ca8386_1589240164?x-expires=1645664400&x-signature=CiGmFb54%2BLBSpY5eNHyz8%2Frvdv4%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/26f3c1c442b24d6cb7644ece3f54efd0_1617114990?x-expires=1645664400&x-signature=JUMoVTx7I4aPnwJVd1zv%2FZ%2BREPE%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/16308aa2d9724d9196a1cce526394eb2_1618091023?x-expires=1645664400&x-signature=RsVbM%2F5afCuWHtDLG%2BC1le9XadA%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/9e83a88c4cc348139ff6960234609216_1622908972?x-expires=1645664400&x-signature=HS4axvDTaDG4hAydkhreGSOkrqg%3D",
"https://p77-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/acfd4f691fff44dc9bd9a01380404701_1623273879?x-expires=1645664400&x-signature=39iKVMxfom1RA7ahLnnxEDj%2BBW4%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/4a0c1930f9ce4809ae44ef25405a4370_1623545322?x-expires=1645664400&x-signature=SpLVaS5vDUGxTWj%2BfKlKJva%2F20A%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/0d653827737745a8a006b2cc7ffd9640_1623554208?x-expires=1645664400&x-signature=C93vK7%2BNxFufYmDbNVJd7QdF0pI%3D",
"https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/ccfa2a83ae1d48e091a637413f7eb7f7_1623605649?x-expires=1645664400&x-signature=zXwlq3sMW0xAVNdMryTY0rDUCUc%3D"
), videoUrl = c("https://v16-webapp.tiktok.com/38ac26a15637fe281520b4fe9fb95434/6216dacb/video/tos/useast2a/tos-useast2a-pve-0068/f4e27ded4ea64efca5f18e1a5d8393dd/?a=1988&br=2570&bt=1285&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=2&er=&ft=XOQ9-3._nz7TheyLUDXq&l=202202231908300101921662190507E861&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M3g2cTtqOWhmczMzODczM0ApNmY4NzY8aTxmNztnPDVmOmdpYy9vZV5eYXJfLS1fMTZzczBfNDExNjVfNi4uLWJeYWI6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/86c8384953c1838b24b4908a5e4f1291/6216da8f/video/tos/useast2a/tos-useast2a-ve-0068c003/47def1dbd3b24722ac7fa683975e355f/?a=1988&br=2470&bt=1235&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=3&er=&ft=XOQ9-3._nz7Th2yLUDXq&l=2022022319082701019103203909060E21&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M2t4bWVveHdqdDMzaDczM0ApN2Y3ZmlmPGU7N2lkNzRmM2djbjBxY25uNjVfLS02MTZzcy4yYWExL15jYDVfX14yXmI6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/324b378f81c3556ebf50cbcd2c377b5e/6216da99/video/tos/useast2a/tos-useast2a-ve-0068c001/30287829751d482f815a0d7ca95c7bbd/?a=1988&br=1318&bt=659&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=3&er=&ft=XOQ9-3._nz7Th2yLUDXq&l=2022022319082701019103203909060E21&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=ajU3czhpPDx4dDMzZzczM0ApNDU4NTc3Z2QzN2hlMzszNWdrL3EzL2ZnLnBfLS02MTZzc2AuLzBgMDYtNC0uLmAzMGE6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/1e9995549209307bfa123aea504b8fe8/6216daa5/video/tos/useast2a/tos-useast2a-pve-0068/2bb71ae377de438cba8316d317ca572e/?a=1988&br=1416&bt=708&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=2&er=&ft=XOQ9-3._nz7Th0yLUDXq&l=202202231908290101921662190507E745&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=MzZzeTM8dW9tNDMzNzczM0ApOjZnZzY3ZWVmNzppOzM2OGdzNWpjbTU1YmVgLS1kMTZzcy9jLS40Ni8zMTIuM2AwX2A6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/5a37234b8ce3450d432ebc076799778d/6216da9e/video/tos/useast2a/tos-useast2a-ve-0068c003/c8ca04f8887f43739ff6164d01677c4a/?a=1988&br=1440&bt=720&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=3&er=&ft=XOQ9-3._nz7ThzyLUDXq&l=202202231908280102231230141108A10D&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=anhmb3E7dXAzNDMzNzczM0ApaDhmNWRoOztlN2VoaTRpaWdvajVsM2wvbG1gLS1kMTZzcy9fYi82XzY1Xi1fX181LjM6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/c37cc04b74d23c7072ac20f090566a37/6216dac8/video/tos/useast2a/tos-useast2a-ve-0068c002/2043d6424b2d40bd8c8067ba6c560530/?a=1988&br=1384&bt=692&cd=0%7C0%7C0%7C0&ch=0&cr=0&cs=0&dr=0&ds=3&er=&ft=XOQ9-3._nz7Th0yLUDXq&l=202202231908290101921662190507E745&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=MzZ1eHZpb3VzNTMzNzczM0ApNTc8OmVnO2VkN2lkNjpoaWdrMDQ0ZGQwcHFgLS1kMTZzcy4uYy4zYWNjYzQyYzMwYDU6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/6e1fded31f24294541cc6d269ec98dad/6216da96/video/tos/useast2a/tos-useast2a-pve-0068/9ada809b0c424b5ebb51385cda626c84/?a=1988&br=1528&bt=764&cd=0%7C0%7C1%7C0&ch=0&cr=0&cs=0&cv=1&dr=0&ds=3&er=&ft=XOQ9-3._nz7ThGyLUDXq&l=202202231908230102230790121703D465&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M25wOjs1NXNtNjMzNzczM0ApaGQ5Njw2OjtnN2Y3Z2ZpZ2dhcS0ybzYvLy1gLS1kMTZzczIwY18tYy8xLmMuNDVjLi46Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/ccb06d3c99f07676e58957a16c0c45eb/6216db32/video/tos/useast2a/tos-useast2a-ve-0068c004/ca0670f6ce1f473583cd082de3472250/?a=1988&br=1060&bt=530&cd=0%7C0%7C1%7C0&ch=0&cr=0&cs=0&cv=1&dr=0&ds=3&er=&ft=XOQ9-3._nz7ThVyLUDXq&l=202202231908140101901860440C08645A&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M2V4M21rdXNvNjMzNzczM0ApNThkZTM7OTw5NzZnNjY2OWczMGluaWkzNS9gLS1kMTZzcy1eMV81LzZiLS4tYi8xLV86Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/4cd95bfd3e5f6615a0a82397b4bc8047/6216db32/video/tos/useast2a/tos-useast2a-ve-0068c004/58edeec6ee0a4681b02e7372657fbc3c/?a=1988&br=1108&bt=554&cd=0%7C0%7C1%7C0&ch=0&cr=0&cs=0&cv=1&dr=0&ds=3&er=&ft=XOQ9-3._nz7ThVyLUDXq&l=202202231908140101901860440C08645A&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M29wczRrazhxNjMzNzczM0ApZzc8PDk4ZjtpNzo4ZTo5aWcyL2ZqMTUyYy9gLS1kMTZzc2FiY142NDI1LS42LzM2YDA6Yw%3D%3D&vl=&vr=",
"https://v16-webapp.tiktok.com/478c09e780bccef0f118a1b011401f5e/6216db35/video/tos/useast2a/tos-useast2a-ve-0068c002/1df136f0b22e4a32b91deb41eda134aa/?a=1988&br=690&bt=345&cd=0%7C0%7C1%7C0&ch=0&cr=0&cs=0&cv=1&dr=0&ds=3&er=&ft=XOQ9-3._nz7ThOyLUDXq&l=2022022319081701022307215816072093&lr=tiktok_m&mime_type=video_mp4&net=0&pl=0&qs=0&rc=M3g7Z2ZzMzQ3NjMzNzczM0ApNTg2ODwzaGQ3NzczO2c2NGdrZjFqcHM1LjBgLS1kMTZzc2JeNTQuXmEzMi82MS1iYjE6Yw%3D%3D&vl=&vr="
), videoUrlNoWaterMark = c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA), videoApiUrlNoWaterMark = c(NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA), videoMeta.height = c(480L, 1024L, 1024L,
480L, 576L, 1024L, 1024L, 1024L, 1024L, 1024L), videoMeta.width = c(848L,
576L, 576L, 848L, 1024L, 576L, 576L, 576L, 576L, 576L), videoMeta.duration = c(60L,
4L, 14L, 24L, 18L, 59L, 14L, 180L, 180L, 180L), diggCount = c(2L,
6L, 5L, 17L, 2L, 3L, 33L, 30200L, 23900L, 663L), shareCount = c(0L,
0L, 0L, 9L, 0L, 0L, 0L, 1540L, 468L, 37L), playCount = c(30L,
57L, 74L, 385L, 23L, 24L, 2783L, 930500L, 430600L, 34600L
), commentCount = c(0L, 0L, 0L, 0L, 0L, 0L, 1L, 224L, 205L,
16L), downloaded = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE), mentions = c("[]", "[]", "[]",
"[]", "[]", "[]", "[]", "[\"#luizguilhermeol2\"]", "[\"#vinicius\"]",
"[]"), hashtags = c("[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"56170\",\"name\":\"mentira\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1661865863689221\",\"name\":\"lulaxbolsonaro\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1648865153779717\",\"name\":\"bolsonaro2022\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"42164\",\"name\":\"foryou\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1518647\",\"name\":\"fory\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1105452\",\"name\":\"fyyy\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"48919866\",\"name\":\"golpista\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"37986936\",\"name\":\"obrigadogalera\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"71910226\",\"name\":\"flamengooooo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1653550338924549\",\"name\":\"paravocefo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1688242636665861\",\"name\":\"dublagem19\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1699304938756101\",\"name\":\"flamengosergipe\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"44804\",\"name\":\"copaamerica\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"4296838\",\"name\":\"flamengo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1650748975425541\",\"name\":\"flamengolibertadores\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"5064773\",\"name\":\"eriksen\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1650748975425541\",\"name\":\"flamengolibertadores\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"4296838\",\"name\":\"flamengo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"44804\",\"name\":\"copaamerica\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1699304938756101\",\"name\":\"flamengosergipe\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1688242636665861\",\"name\":\"dublagem19\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"83884\",\"name\":\"neymar\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"45874915\",\"name\":\"globol\",\"title\":\"\",\"cover\":\"\"}]",
"[{\"id\":\"83884\",\"name\":\"neymar\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"5064773\",\"name\":\"eriksen\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1662240138893317\",\"name\":\"globolixoo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1650748975425541\",\"name\":\"flamengolibertadores\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1688242636665861\",\"name\":\"dublagem19\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1699304938756101\",\"name\":\"flamengosergipe\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"44804\",\"name\":\"copaamerica\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"88764338\",\"name\":\"foryoupage\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"30873973\",\"name\":\"paravoce\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1663903392662534\",\"name\":\"globolixooo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"4296838\",\"name\":\"flamengo\",\"title\":\"\",\"cover\":\"\"},{\"id\":\"1105452\",\"name\":\"fyyy\",\"title\":\"\",\"cover\":\"\"}]"
), effectStickers = c("[]", "[{\"id\":\"333023\",\"name\":\"Humor de feriado\"}]",
"[]", "[]", "[]", "[]", "[]", "[]", "[]", "[]")), row.names = c(NA,
10L), class = "data.frame")
UpdateII removed previous solutions:
library(dplyr)
library(tidyr)
df %>%
mutate(id = row_number()) %>%
separate_rows(hashtags, sep = '\",\"name\":\"') %>%
separate_rows(hashtags, sep = '\",\"title\"') %>%
filter(str_detect(hashtags, '^[\\w]')) %>%
group_by(id) %>%
summarise(hashtags = toString(hashtags), .groups = "drop") %>%
select(-id)
hashtags
<chr>
1 globolixoo
2 globolixoo
3 globolixoo
4 globolixoo
5 globolixoo
6 globolixoo, mentira
7 lulaxbolsonaro, globolixoo, bolsonaro2022, foryou, fory, fyyy, golpista, obrigadogalera
8 flamengooooo, paravocefo, dublagem19, flamengosergipe, copaamerica, flamengo, flamengolibertado…
9 globolixoo, flamengolibertadores, flamengo, copaamerica, flamengosergipe, dublagem19, neymar, g…
10 neymar, eriksen, globolixoo, flamengolibertadores, dublagem19, flamengosergipe, copaamerica, fo…
I'm analysing real-estate sales for some N. American cities and am using k-means clustering on the data. I have seven clusters and for each observation in the cluster I have the latitude, longitude, zipcode, and cluster_id. I'd like to plot this on a map to better visualize the clusters - I'm not sure what such a plot is called - Choropleth? Polygon?
Most of the examples are using geoJSON files but I only have a data.frame object from my k-means clustering.
Actual data:
https://www.kaggle.com/threnjen/portland-housing-prices-sales-jul-2020-jul-2021
Sample data:
> dput(dt[runif(n = 10,min = 1,max = 25000)])
structure(list(id = c(23126L, 15434L, 5035L, 19573L, NA, 24486L,
NA, 14507L, 3533L, 20192L), zipcode = c(97224L, 97211L, 97221L,
97027L, NA, 97078L, NA, 97215L, 97124L, 97045L), latitude = c(45.40525436,
45.55965805, 45.4983139, 45.39398956, NA, 45.47454071, NA, 45.50736618,
45.52812958, 45.34381485), longitude = c(-122.7599182, -122.6500015,
-122.7288742, -122.591217, NA, -122.8898392, NA, -122.6084061,
-122.91745, -122.5948334), lastSoldPrice = c(469900L, 599000L,
2280000L, 555000L, NA, 370000L, NA, 605000L, 474900L, 300000L
), lotSize = c(5227L, 4791L, 64904L, 9147L, NA, 2178L, NA, 4356L,
2613L, 6969L), livingArea = c(1832L, 2935L, 5785L, 2812L, NA,
1667L, NA, 2862L, 1844L, 742L), cluster_id = c(7, 7, 2, 7, NA,
4, NA, 7, 7, 4)), row.names = c(NA, -10L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x7faa8000fee0>)
I've followed the example on https://gist.github.com/josecarlosgonz/8565908 to try and create a geoJSON file to be able to plot this data but without success.
I'm not using markers because I have ~25,000 observations - it would be difficult to plot them all and the file would take forever to load.
EDIT:
observations by zipcode:
> dput(dat[, .N, by = .(`address/zipcode`)][(order(`address/zipcode`))])
structure(list(`address/zipcode` = c(7123L, 97003L, 97004L, 97005L,
97006L, 97007L, 97008L, 97009L, 97015L, 97019L, 97023L, 97024L,
97027L, 97030L, 97034L, 97035L, 97038L, 97045L, 97056L, 97060L,
97062L, 97068L, 97070L, 97078L, 97080L, 97086L, 97089L, 97113L,
97123L, 97124L, 97132L, 97140L, 97201L, 97202L, 97203L, 97204L,
97205L, 97206L, 97209L, 97210L, 97211L, 97212L, 97213L, 97214L,
97215L, 97216L, 97217L, 97218L, 97219L, 97220L, 97221L, 97222L,
97223L, 97224L, 97225L, 97227L, 97229L, 97230L, 97231L, 97232L,
97233L, 97236L, 97239L, 97266L, 97267L), N = c(1L, 352L, 9L,
252L, 421L, 1077L, 357L, 1L, 31L, 2L, 4L, 159L, 239L, 525L, 640L,
548L, 1L, 1064L, 5L, 353L, 471L, 736L, 6L, 403L, 866L, 913L,
8L, 5L, 1113L, 776L, 3L, 543L, 219L, 684L, 463L, 1L, 57L, 809L,
189L, 216L, 688L, 510L, 504L, 330L, 318L, 177L, 734L, 195L, 832L,
305L, 276L, 589L, 688L, 716L, 286L, 83L, 1307L, 475L, 77L, 150L,
382L, 444L, 290L, 423L, 430L)), row.names = c(NA, -65L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x7f904781a6e0>)
I used the kaggle data on a simple laptop (i3 8th gen) to generate a ggplot2 object, with cluster IDs randomly sampled and transform this via the ggplotly() function ... the resulting plotly object seems OK to work with for analysis but I do not know your performance requirements:
library(dplyr)
library(ggplot2)
library(plotly)
library(rnaturalearth) # here we get the basic map data from
# read in data from zip, select minimal number of columns and sample cluster_id
df <- readr::read_csv(unzip("path_to_zip/portland_housing.csv.zip"))%>%
dplyr::select(az = `address/zipcode`, latitude, longitude) %>%
dplyr::mutate(cluster_id = sample(1:7, n(), replace = TRUE))
# get the map data
world <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")
# build the ggplot2 object (note that I use rings as shapes and alpha parameter to reduce the over plotting
plt <- ggplot2::ggplot(data = world) +
ggplot2::geom_sf() +
ggplot2::geom_point(data = df, aes(x = longitude, y = latitude, color = factor(cluster_id)), size = 1, shape = 21, alpha = .7) +
ggplot2::coord_sf(xlim = c(-124.5, -122), ylim = c(45, 46), expand = FALSE)
# plot it:
plt
# plotly auto transform from ggplot2 object
plotly::ggplotly(plt)
EDIT
To include a map you can use for example the ggmap package instead of the map data from rnaturalearth... I will only display the plotly result:
library(ggmap)
# https://stackoverflow.com/questions/23130604/plot-coordinates-on-map
sbbox <- ggmap::make_bbox(lon = c(-124.5, -122), lat = c(45, 46), f = .1)
myarea <- ggmap::get_map(location=sbbox, zoom=10, maptype="terrain")
myarea <- ggmap::ggmap(myarea)
plt2 <- myarea +
ggplot2::geom_point(data = df, mapping = aes(x = longitude, y = latitude, color = factor(cluster_id)), shape = 21, alpha = .7)
plotly::ggplotly(plt2)
There are many other approaches concerning the map data, like using the mapbox-api
I am using plot.ly within r to display a time series in which I have dates on the X axis (see code below). I would also like to highlight the weekends, most likely using a darker background. I know that I can set a background colour using layout, but AFAIK this applies to all the plot area, not a particular region.
Is there any way to use a different background colour for weekends in an horizontal axis with dates like in the image below?
library(plotly)
df <- read.csv("https://raw.githubusercontent.com/datadista/datasets/master/COVID%2019/nacional_covid19.csv")
plot_ly(data = df) %>%
add_trace(x = ~ fecha,
y = ~ casos,
type = "scatter",
mode = "lines+markers",
name = "Contagios detectados") %>%
layout(title = "My title",
legend = list(x = 0.1, y = 0.9),
hovermode = "compare")
This is the dataframe:
> tail(df)
fecha casos altas fallecimientos ingresos_uci hospitalizados
32 2020-03-27 64059 9357 4858 4165 36293
33 2020-03-28 72248 12285 5690 4575 40630
34 2020-03-29 78797 14709 6528 4907 43397
35 2020-03-30 85195 16780 7340 5231 46617
36 2020-03-31 94417 19259 8189 5607 49243
37 2020-04-01 102136 22647 9053 5872 51418
> dput(df)
structure(list(fecha = structure(1:37, .Label = c("2020-02-25",
"2020-02-26", "2020-02-27", "2020-02-28", "2020-02-29", "2020-03-01",
"2020-03-02", "2020-03-03", "2020-03-04", "2020-03-05", "2020-03-06",
"2020-03-07", "2020-03-08", "2020-03-09", "2020-03-10", "2020-03-11",
"2020-03-12", "2020-03-13", "2020-03-14", "2020-03-15", "2020-03-16",
"2020-03-17", "2020-03-18", "2020-03-19", "2020-03-20", "2020-03-21",
"2020-03-22", "2020-03-23", "2020-03-24", "2020-03-25", "2020-03-26",
"2020-03-27", "2020-03-28", "2020-03-29", "2020-03-30", "2020-03-31",
"2020-04-01"), class = "factor"), casos = c(3L, 10L, 16L, 32L,
44L, 66L, 114L, 135L, 198L, 237L, 365L, 430L, 589L, 999L, 1622L,
2128L, 2950L, 4209L, 5753L, 7753L, 9191L, 11178L, 13716L, 17147L,
19980L, 24926L, 28572L, 33089L, 39673L, 47610L, 56188L, 64059L,
72248L, 78797L, 85195L, 94417L, 102136L), altas = c(NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 23L, 135L, 183L, 189L,
189L, 517L, 517L, 530L, 1028L, 1081L, 1107L, 1585L, 2125L, 2575L,
3355L, 3794L, 5367L, 7015L, 9357L, 12285L, 14709L, 16780L, 19259L,
22647L), fallecimientos = c(NA, NA, NA, NA, NA, NA, NA, NA, 1L,
3L, 5L, 8L, 17L, 17L, 35L, 47L, 84L, 120L, 136L, 288L, 309L,
491L, 598L, 767L, 1002L, 1326L, 1720L, 2182L, 2696L, 3434L, 4089L,
4858L, 5690L, 6528L, 7340L, 8189L, 9053L), ingresos_uci = c(NA,
NA, NA, NA, NA, NA, NA, NA, 7L, 9L, 11L, NA, NA, 68L, 100L, 142L,
190L, 272L, 293L, 382L, 432L, 563L, 774L, 939L, 1141L, 1612L,
1785L, 2355L, 2636L, 3166L, 3679L, 4165L, 4575L, 4907L, 5231L,
5607L, 5872L), hospitalizados = c(NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3215L,
5717L, NA, 10542L, 13282L, 15554L, 18374L, 22762L, 26960L, 31912L,
36293L, 40630L, 43397L, 46617L, 49243L, 51418L)), .Names = c("fecha",
"casos", "altas", "fallecimientos", "ingresos_uci", "hospitalizados"
), class = "data.frame", row.names = c(NA, -37L))
And this is the output plot:
The idea I have here is adding polygons for weekends, which would be similar to different backgrounds for weekends.
library(plotly)
library(dplyr)
library(tidyr)
#Creating a dataset for polygons with weekend dates
data.frame(fecha=as.Date(df1$fecha), day=weekdays(as.Date(df1$fecha))) %>%
filter(day %in% c("Saturday", "Sunday")) %>%
pivot_wider(names_from = day, values_from = fecha) %>%
unnest() -> df2
df1 %>%
mutate(fecha = as.Date(fecha)) %>%
plot_ly(data = .) %>%
add_trace(x = ~ fecha,
y = ~ casos,
type = "scatter",
mode = "lines+markers",
name = "Contagios detectados") %>%
layout(title = "My title",
legend = list(x = 0.1, y = 0.9),
hovermode = "compare") -> p
for (i in 1:nrow(df2)) {
p <- add_polygons(p, x = c(df2[[i, "Saturday"]], df2[[i, "Saturday"]],
df2[[i, "Sunday"]], df2[[i, "Sunday"]]),
y = c(0, max(df1$casos), max(df1$casos), 0),
hoverinfo = "none", color = I("blue"), showlegend = F,
hoveron = "points", opacity = 0.5)
}
p
The code I used and the result can be seen in the image below. The main problem is that the title doesn't appear in the center and the x and y labels don't appear at all. How do I fix this?
The graph and code
You should upload your code as a snippet and your data so we can reproduce this on our own machines easily...
Take the example below. You can recreate the data set and then run the code immediately.
Using ggtitle, xlab, ylab you can plot the text and center it with theme.
If this does not help you have the wrong print / render settings.
balloon <- data.table(structure(list(Genera = c("Prevotella", "Treponema", "Fusobacterium","Selenomonas", "Veillonella", "Porphyromonas", "Streptococcus","Leptotrichia", "Aggregatibacter", "Succiniclasticum"), S1 = c(97L,28L, 11L, 40L, 5L, 13L, 10L, 24L, 0L, 16L), S3 = c(5370L, 3760L,5551L, 2087L, 533L, 873L, 1330L, 5877L, 1213L, 44L), S4 = c(7892L,8004L, 11017L, 19712L, 5115L, 2695L, 7451L, 13611L, 301L, 2557L), S5 = c(23L, 79L, 30L, 7L, 0L, 34L, 0L, 2L, 2L, 0L), S6 = c(8310L,3379L, 38058L, 1133L, 2506L, 17811L, 12103L, 403L, 668L, 3L),S2 = c(7379L, 14662L, 10085L, 148L, 1502L, 5222L, 1010L,2463L, 4790L, 28L), S7 = c(6238L, 18977L, 2674L, 2198L, 27L,2999L, 174L, 1197L, 5268L, 5L), S8 = c(20019L, 18674L, 15306L,1472L, 1898L, 9600L, 1683L, 2221L, 3435L, 1109L), S9 = c(153L,12L, 23L, 36L, 15L, 15L, 6L, 41L, 0L, 30L), S10 = c(20103L,29234L, 10857L, 2869L, 4923L, 14206L, 1415L, 4574L, 649L,2160L)), .Names = c("Genera", "S1", "S3", "S4", "S5", "S6","S2", "S7", "S8", "S9", "S10"), class = c("data.table", "data.frame"), row.names = c(NA, -10L)))
library(ggplot2)
library(reshape2)
library(data.table)
balloon<-fread("Downloads/balloon.csv")
balloon
balloon_melted<-melt(balloon)
head(balloon_melted)
p <- ggplot(balloon_melted, aes(x =variable, y = Genera))
p+
geom_point( aes(size=value))+
theme(panel.background=element_blank(),
panel.border = element_rect(colour = "blue", fill=NA, size=1)) +
ggtitle("Pretty title") +
xlab("x lab label") +
ylab("y lab label") +
theme(plot.title = element_text(hjust = 0.5))
I am trying to graph expected values and actual values, over time. I have some data that I'd like to get all on one graph. I am still pretty new to R, I keep getting stuck.
So far I have been able to get what I want on separate graphs, or if I get them all together, I can't seem to get it to do what I want.
I am almost there, but I'd like to have the points (points are expected values) connected with a dashed line. I tried adding a LOESS line a few different ways (one is hashed in my code), but I keep getting errors.
I am still new to R (and coding in general), but I know there has to be a way to do this besides building up the plot manually. However, every example I try will do something that I want, but I can't seem to get everything to work at once. I am starting to understand what each thing does, but sometimes I get lost in what works with what.
Error in xy.coords(x, y, xlabel, ylabel) : 'x' is a list, but does
not have components 'x' and 'y'
Error: Don't know how to add RHS to a theme object
My plot: (without links connected)
My Dataset
Year,SC_CE_5AGG,SC_ACA,TA_CE_5AGG,TA_ACA,OA_CE_5AGG,OA_ACA,CO_CE_5AGG,CO_ACA
2005,8,12,5,0,140,100,23,23
2006,,13,,0,,100,,25
2007,,13,,0,,102,,37
2008,,14,,0,,104,,36
2009,,16,,3,,104,,35
2010,10,17,6,4,179,106,29,36
2011,,20,,7,,111,,36
2012,,23,,7,,116,,33
2013,,22,,10,,118,,37
2014,,23,,12,,107,,40
2015,12,23,8,14,229,112,37,46
2016,,25,,14,,119,,56
2017,,28,,13,,120,,60
2018,,,,,,,,
2019,,,,,,,,
2020,16,,10,,292,,48,
2025,20,,20,,372,,61,
My code
setwd("C:Users/X/Documents/PROJECTS/R_RcW/Data")
install.packages("ggplot2")
install.packages("GGally")
library(ggplot2)
library(GGally)
ALL <- read.csv(file="Rcw_data.csv", header = TRUE)
#To plot multiple lines, (for a small number of variables) you can use build up the plot manually yourself
ggplot(data=ALL, aes(Year)) +
geom_line(aes(y = SC_ACA, colour = "Shoal Creek")) +
lines(scatter.smooth(aes(y = SC_CE_5AGG, colour = "Shoal Creek"))) +
geom_line(aes(y = TA_ACA, colour = "Talladega")) +
lines(scatter.smooth(aes(y = TA_CE_5AGG, colour = "Talladega"))) +
geom_line(aes(y = OA_ACA, colour = "Oakmulgee")) +
lines(scatter.smooth(aes(y = OA_CE_5AGG, colour = "Oakmulgee"))) +
geom_line(aes(y = CO_ACA, colour = "Conecuh")) +
lines(scatter.smooth(aes(y = CO_CE_5AGG, colour = "Conecuh"))) +
#lines(lowess(SC_CE_5AGG), col="Shoal Creek") + # lowess line (x,y)
#lines(lowess(TA_CE_5AGG), col="Talladega") + # lowess line (x,y)
#lines(lowess(OA_CE_5AGG), col="Oakmulgee") + # lowess line (x,y)
#lines(lowess(CO_CE_5AGG), col="Conecuh") # lowess line (x,y)
theme_classic() +
ggtitle("Active clusters of Red-cockaded Woodpeckers") +
theme(plot.title = element_text(hjust = 0.5)) +
labs(colour="District") +
theme(legend.title.align=0.5) +
theme(panel.border = element_rect(colour = "black", fill=NA, size=)) +
scale_x_continuous(limits=c(2005, 2025), breaks=c(2005,2010,2015,2020,2025)) +
xlab("Year") + ylab("Number of active clusters")
I think you will be better off reshaping your data to long format something like:
library(tidyverse)
library(reshape2)
data
structure(list(Year = c(2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2019L,
2020L, 2025L), SC_CE_5AGG = c(8L, NA, NA, NA, NA, 10L, NA, NA,
NA, NA, 12L, NA, NA, NA, NA, 16L, 20L), SC_ACA = c(12L, 13L,
13L, 14L, 16L, 17L, 20L, 23L, 22L, 23L, 23L, 25L, 28L, NA, NA,
NA, NA), TA_CE_5AGG = c(5L, NA, NA, NA, NA, 6L, NA, NA, NA, NA,
8L, NA, NA, NA, NA, 10L, 20L), TA_ACA = c(0L, 0L, 0L, 0L, 3L,
4L, 7L, 7L, 10L, 12L, 14L, 14L, 13L, NA, NA, NA, NA), OA_CE_5AGG = c(140L,
NA, NA, NA, NA, 179L, NA, NA, NA, NA, 229L, NA, NA, NA, NA, 292L,
372L), OA_ACA = c(100L, 100L, 102L, 104L, 104L, 106L, 111L, 116L,
118L, 107L, 112L, 119L, 120L, NA, NA, NA, NA), CO_CE_5AGG = c(23L,
NA, NA, NA, NA, 29L, NA, NA, NA, NA, 37L, NA, NA, NA, NA, 48L,
61L), CO_ACA = c(23L, 25L, 37L, 36L, 35L, 36L, 36L, 33L, 37L,
40L, 46L, 56L, 60L, NA, NA, NA, NA)), .Names = c("Year", "SC_CE_5AGG",
"SC_ACA", "TA_CE_5AGG", "TA_ACA", "OA_CE_5AGG", "OA_ACA", "CO_CE_5AGG",
"CO_ACA"), class = "data.frame", row.names = c(NA, -17L))
All %>%
melt(id="Year") %>%
na.omit() %>%
mutate(est =factor(grepl("5AGG", variable))) %>%
ggplot(aes(Year, value, color=variable, lty=est)) +
geom_line() +
theme_classic() +
ggtitle("Active clusters of Red-cockaded Woodpeckers") +
theme(plot.title = element_text(hjust = 0.5)) +
labs(colour="District") +
theme(legend.title.align=0.5) +
theme(panel.border = element_rect(colour = "black", fill=NA, size=)) +
scale_x_continuous(limits=c(2005, 2025),
breaks=c(2005,2010,2015,2020,2025)) +
xlab("Year") + ylab("Number of active clusters")
grepl was used to define estimated values.