R - gtrends: ISO language code "en" or "en-BR" do not work?

Asked

Viewed 167 times

2

. Guys, I’m using gtrends and would like to get the "related_topics" in English (preferably "en-BR"), but the "hl" argument of the gtrends function is not returning to English. Without the argument, it returns the related topics in English. Would anyone have any hints? The code I’m using is

gtrend1 <- gtrends("Futebol", 
      geo = "BR",
      hl = "pt-BR",
      time = "2018-04-28 2018-05-04")
  • You’ve only tried "pt" without the BR?

  • tried yes. It also didn’t work. Returns as "NULL"

  • Is not pt_BR? With _, nay -.

  • Rui, grateful for the suggestion, but it’s not, no. Error: "hl %in% language_codes$code is not TRUE". I’m thinking maybe it’s some configuration of my computer.

  • With me it works, there is no error. Already tried to close the R and restart?

  • That’s funny. The argument hl = "pt-BR" doesn’t work for me either. In fact, the only hl that works for me is hl = "en", but then it returns the results only in English.

  • I confirm the problem with hl = "en-br". If I go on Trends, i see the result in English. But when I download the csv file, I get the same result as gtrendsR.

Show 2 more comments

1 answer

2

It seems that some users are having problems and others (like me) do not.
This answer should not solve the problem, it only serves to show which output I get.

library(gtrendsR)

gtrend1 <- gtrends("Futebol", 
      geo = "BR",
      hl = "pt-BR",
      time = "2018-04-28 2018-05-04")

gtrend1
#$`interest_over_time`
#                 date hits keyword geo gprop category
#1 2018-04-28 01:00:00   65 Futebol  BR   web        0
#2 2018-04-29 01:00:00  100 Futebol  BR   web        0
#3 2018-04-30 01:00:00   43 Futebol  BR   web        0
#4 2018-05-01 01:00:00   55 Futebol  BR   web        0
#5 2018-05-02 01:00:00   58 Futebol  BR   web        0
#6 2018-05-03 01:00:00   48 Futebol  BR   web        0
#7 2018-05-04 01:00:00   43 Futebol  BR   web        0
#
#$interest_by_country
#NULL
#
#$interest_by_region
#NULL
#
#$interest_by_dma
#NULL
#
#$interest_by_city
#NULL
#
#$related_topics
#NULL
#
#$related_queries
#NULL
#
#attr(,"class")
#[1] "gtrends" "list"

When I downloaded the file "multiTimeline.csv" and the li gave this:

fute <- read.csv("multiTimeline.csv", skip = 2)

str(fute)
#'data.frame':   52 obs. of  2 variables:
# $ Semana           : Factor w/ 52 levels "2017-05-14","2017-05-21",..: 1 2 3 4 5 6 7 8 9 10 ...
# $ futebol...Brasil.: int  53 55 51 61 64 63 58 61 69 68 ...

head(fute)
#      Semana futebol...Brasil.
#1 2017-05-14                53
#2 2017-05-21                55
#3 2017-05-28                51
#4 2017-06-04                61
#5 2017-06-11                64
#6 2017-06-18                63

Editing.

Following the @r_rabbit comment I tried without hl = "pt-BR" and some of the terms appear in English and others in Portuguese. It follows the code and the content of gtrend2$related_topics format dput.

gtrend2 <- gtrends("Futebol", 
      geo = "BR",
      time = "2018-04-28 2018-05-04")

gtrend2$related_topics <-
structure(list(subject = c("100", "24", "7", "7", "6", "6", "4", 
"3", "3", "2", "2", "2", "2", "2", "1", "1", "1", "1", "1", "1", 
"1", "+150%", "+70%", "+40%"), related_topics = c("top", "top", 
"top", "top", "top", "top", "top", "top", "top", "top", "top", 
"top", "top", "top", "top", "top", "top", "top", "top", "top", 
"top", "rising", "rising", "rising"), value = c("Soccer", "Vivo", 
"Santos FC", "São Paulo FC", "Player", "Footballer", "Futebol Interior", 
"Ball", "Association", "Botafogo de Futebol e Regatas", "Ball", 
"American football", "Team", "Football in Brazil", "Stadium", 
"Northeast Region, Brazil", "Santa Cruz Futebol Clube", "Campeonato Baiano", 
"Campeonato Paulista", "Brazil national football team", "FIFA", 
"FIFA", "Stadium", "Campeonato Baiano"), geo = c("BR", "BR", 
"BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", 
"BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR"
), keyword = c("Futebol", "Futebol", "Futebol", "Futebol", "Futebol", 
"Futebol", "Futebol", "Futebol", "Futebol", "Futebol", "Futebol", 
"Futebol", "Futebol", "Futebol", "Futebol", "Futebol", "Futebol", 
"Futebol", "Futebol", "Futebol", "Futebol", "Futebol", "Futebol", 
"Futebol"), category = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), row.names = c(NA, 
-24L), reshapeLong = list(varying = structure(list(value = "top"), v.names = "value", times = "top"), 
    v.names = "value", idvar = "id", timevar = "related_topics"), class = "data.frame")
  • Oi Rui. In the visualization you posted above, there is no "related_topics", which would be the element of interest. When I call it "en-BR" for the "hl" argument, it appears as NULL, when I call it without the argument, it appears correctly with the English terms. Did you find the terms of "related_topics" in English? Thanks for the help, thanks!

  • @r_rabbit I edited the answer with what was missing. As for the related_topics, I don’t know why but I didn’t copy it for the answer. As for the code without hl = "pt-BR", here goes only gtrend2$related_topics, complete is great.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.