Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
警告:as.vector中出错:无法强制类型';环境';到类型为'的向量;字符';在有光泽的地板上跑步时,在R。我能做什么?_R_Ggplot2_Google Analytics_Google Analytics Api - Fatal编程技术网

警告:as.vector中出错:无法强制类型';环境';到类型为'的向量;字符';在有光泽的地板上跑步时,在R。我能做什么?

警告:as.vector中出错:无法强制类型';环境';到类型为'的向量;字符';在有光泽的地板上跑步时,在R。我能做什么?,r,ggplot2,google-analytics,google-analytics-api,R,Ggplot2,Google Analytics,Google Analytics Api,我试图通过获取Google Analytics数据在shiny上运行一个R程序,但我遇到了以下错误: 警告:as.vector中出错:无法将类型“environment”强制为类型“character”的向量 堆栈跟踪(最里面的第一个): 100:as.character.default 99:as.字符 98:标记列表 97:as.tags.default 96:as.标记 95:继承 94:isTag 93:重写标签 92:标记化 91:func 90:乐趣 89:lappy 88:乐趣 8

我试图通过获取Google Analytics数据在shiny上运行一个R程序,但我遇到了以下错误:

警告:as.vector中出错:无法将类型“environment”强制为类型“character”的向量

堆栈跟踪(最里面的第一个):
100:as.character.default
99:as.字符
98:标记列表
97:as.tags.default
96:as.标记
95:继承
94:isTag
93:重写标签
92:标记化
91:func
90:乐趣
89:lappy
88:乐趣
87:lappy
86:重写标签
85:标记化
84:func
83:重写标签
82:标记化
81:已找到的依赖项
80:resolveDependencies
79:lappy
78:processDeps
77:origRenderFunc
76:输出$viewid
1:runApp

我能做些什么来解决它?代码如下:


#server.r
图书馆(谷歌分析)
图书馆(古格勒乌瑟)
图书馆(dplyr)
图书馆(闪亮)
图书馆(shinydashboard)
ui.R中的服务器的
plotOutput()
需要一个plot对象,但您却为它提供了许多被动对象。server.R中的
renderPlot()
函数的结束对象必须是绘图

您还要求it完成许多已经具备可为您完成的功能的工作,例如创建帐户下拉列表以选择Google Analytics视图ID。此功能的工作版本可在上获得,如下所示:

在server.R中
你能给我解释一下吗。那是个错误。错误:重定向uri与请求中的重定向uri不匹配,与为OAuth客户端授权的重定向uri不匹配。要更新授权重定向URI,请访问:了解更多我们所知的请求详细信息。\我在运行上述代码时遇到此错误。。请帮助我您需要通过选项(shinny.port=1221)指定Shinny应用程序的端口,例如1221,然后将其放入重定向URL中-请参阅googleAuthR网站上的详细信息,但有时有效,有时无效。。而我闪亮的端口改变了。。昨天成功了。但今天又出现了同样的错误。请在全局配置文件中设置它,以便每次都使用相同的端口
#server.r
library(googleAnalyticsR)
library(googleAuthR)
library(dplyr)
library(shiny)
library(shinydashboard)

server <- function(session,input,output){
  output$histogram <- renderPlot({
    ga_auth()
    account_list <- ga_account_list()
    View(account_list)


    observe({

    print(input$accountname)
    x <- account_list$webPropertyName[account_list$accountName == input$accountname]
    updateSelectInput(session, "propertyname","Select your property of the above account",choices =  unique(x))
    })

    observe({

    print(input$propertyname)
    y <- c(account_list %>% filter(webPropertyName == input$propertyname) %>% select(viewName))
    updateSelectInput(session, "viewname","Select your view of the above account",choices = y)
    })

    observe({
    z <- c(account_list$viewId[account_list$viewName == input$viewname])
    updateTextInput(session, "viewid", "view ID of the selected table is:",value = z)

    }) 


output$viewid <- renderUI({

  #idd <- input$viewid
  #print(idd)

  temp_ga_data = google_analytics_4(viewId= input$viewid,date_range = c("2017-11-06","2017-11-10"),
                                   metrics = "sessions", dimensions = "date")

  ggplot(data = temp_ga_data, mapping = aes(date,sessions)) + geom_line()

})

})

}
#ui.r

library(shiny)
library(shinydashboard)
library(googleAnalyticsR) 
library(googleAuthR)
library(ggplot2) 
library(datasets)
library(dplyr)

ui <- fluidPage(

  titlePanel  (title = "Insight of pageviews"), 
    sidebarPanel (
      selectInput("accountname","Select your Analytics account",choices =  c(account_list$accountName), selected = account_list$accountName[1]),

      selectInput("propertyname","Select your property of the above account",choices = NULL),

      selectInput("viewname","Select your view of the above account",choices =  NULL),

      textInput("viewid", "view ID of the selected table is:","")

     # dateRangeInput("daterange3", "Date range:",
         #            start  = "2017-01-01",
          #           end    = "2017-12-31",
          #           min    = "2017-01-01",
          #           max    = "2017-12-31",
          #           format = "mm/dd/yy",
          #           separator = " - ")
    ),
    mainPanel(

        plotOutput("histogram"),
        textOutput("viewid")


    )


  )
library(googleAuthR)
library(googleAnalyticsR)
library(shiny)
library(highcharter)

function(input, output, session){

  ## Get auth code from return URL
  token <- callModule(googleAuth, "login")

  ga_accounts <- reactive({
    req(token())

    with_shiny(ga_account_list, shiny_access_token = token())

  })

  selected_id <- callModule(authDropdown, "auth_menu", ga.table = ga_accounts)

  gadata <- reactive({

    req(selected_id())
    gaid <- selected_id()
    with_shiny(google_analytics,
               id = gaid,
               start="2015-08-01", end="2017-08-02", 
               metrics = c("sessions"), 
               dimensions = c("date"),
               shiny_access_token = token())
  })

  output$something <- renderHighchart({

    ## only trigger once authenticated
    req(gadata())

    gadata <- gadata()

    ## creates a line chart using highcharts
    hchart(gadata, "line" , hcaes(x = date, y = sessions))

  })

}
library(googleAuthR)
library(googleAnalyticsR)
library(shiny)
library(highcharter)

shinyUI(
  fluidPage(
    googleAuthUI("login"),
    authDropdownUI("auth_menu"),
    highchartOutput("something")

  ))