如何解决 parse(text = text, keep.source = FALSE) 中的错误:创建 Dataframe 时

How to resolve Error in parse(text = text, keep.source = FALSE) : when creating a Dataframe

我正在尝试使用胶水包创建数据框

previous_month<-sum(June_count$Tranx_count)
recent_month<-sum(July_count$tranx_count)
formula =(recent_month-previous_month)/previous_month
formula<-scales::percent(formula)

#creating dataframe
robo<-data.frame(" " = c("last_2_month:","Recent Month:", "% Increase:"),
                 " " = c("previous_month","recent_month","formula"))



#adding variable to the dataframe using glue package   
    robo<-data.frame(" " = c(glue::glue("{last_2_month:}"),glue::glue("{Recent Month:}"), "% Increase:"),
                     " " = c(glue::glue("{previous_month}"),glue::glue("{recent_month}"),
                             glue::glue("{formula}")))

但我收到以下错误,谁能帮我解决以下错误

h
  <text>:2:0: unexpected end of input
1: last_2_month:
   ^

我找到了问题的解决方案

在我之前的脚本中

previous_month<-sum(June_count$Tranx_count)
recent_month<-sum(July_count$tranx_count)
formula =(recent_month-previous_month)/previous_month
formula<-scales::percent(formula)

#creating dataframe
robo<-data.frame(" " = c("last_2_month:","Recent Month:", "% Increase:"),
                 " " = c(" "," "," "))

#adding variable to the dataframe using glue package   
    robo<-data.frame(" " = c(glue::glue("{last_2_month:}"),glue::glue("{Recent Month:}"), "% Increase:"),
                     " " = c(glue::glue("{previous_month}"),glue::glue("{recent_month}"),
                             glue::glue("{formula}")))

使用胶水库,冒号不应该在大括号中,这就是我出现错误的原因。

在我编辑脚本的那一刻,它运行得非常好。请参阅下面新编辑的脚本

previous_month<-sum(June_count$Tranx_count)
recent_month<-sum(July_count$tranx_count)
formula =(recent_month-previous_month)/previous_month
formula<-scales::percent(formula)

#creating dataframe
robo<-data.frame(" " = c("last_2_month:","Recent Month:", "% Increase:"),
                 " " = c(" "," "," "))



#adding variable to the dataframe using glue package   
    robo<-data.frame(" " = c(glue::glue("{last_2_month}"),glue::glue("{Recent Month}"), "% Increase:"),
                     " " = c(glue::glue("{previous_month}"),glue::glue("{recent_month}"),
                             glue::glue("{formula}")))