简体   繁体   中英

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

I'm trying to create a data frame with a glue package

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}")))

but I'm getting the error below, can anyone help me resolve this error below

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

I was able to find the solution to the problem

in my previous script below

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}")))

using glue library, the colon is not supposed to be in the curly bracket which is the reason why I was having the error stated.

the moment I edited the script, it works perfectly fine..see the newly edited script below

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}")))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM