yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
255 stars 52 forks source link

Problem in using formatR package #50

Closed jholtman closed 8 years ago

jholtman commented 8 years ago

Here is the lines in a file that are causing the problem. I just highlight and copy the statements and then call tidy_source and get the error:

> tidy_source()
Error in base::parse(text = code, keep.source = FALSE) : 
  <text>:1:15: unexpected '['
1: qry_lookup <- [
                  ^

Enter a frame number, or 0 to exit   

1: tidy_source()
2: tidy_block(text, width.cutoff, arrow && length(grep("=", text)))
3: parse_only(text)
4: base::parse(text = code, keep.source = FALSE)

Here is the sessionInfo:

sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] formatR_1.3

loaded via a namespace (and not attached):
[1] tools_3.2.3
jholtman commented 8 years ago

Somehow the message got sent before I included the following statement that was causing the problem:

qry_lookup <- "SELECT DISTINCT
                itm.BAS_CON_UPC_NO,
               itm.PMY_CAS_UPC_NO,
               itm.DSD_WHS_FL,
               itm.BAS_CON_DSC_TX,
               itm.FYT_PMY_DPT_CD,
               itm.FYT_REC_DPT_CD,
               itm.FYT_SUB_DPT_CD,
               itm.FYT_COM_CD,
               itm.FYT_SUB_COM_CD,
               itm.PMY_ORD_ETY_NO,
               itm.SHF_ALC_QY,
               itm.SHF_MIN_QY,
               itm.CAS_CON_CNT_QY,
               itm.CON_ACV_FL,
               itm.BAS_CON_ACV_CD,
               COALESCE(cat.CAT_ID, substring(itm.PMY_ORD_ETY_NO,1,2)) AS CAT_ID
              FROM dbo.CAO_Item_new AS itm
              LEFT JOIN dbo.CAO_Catalog AS cat
                ON itm.CON_UPC_NO = cat.CON_UPC_NO
              LEFT JOIN  dbo.CAO_Schedule AS scd 
                ON scd.BIL_DIV_NO = itm.MGT_DIV_NO
               AND scd.STO_NO = itm.FAC_NO
               AND scd.CAT_ID = COALESCE(cat.CAT_ID, substring(itm.PMY_ORD_ETY_NO,1,2))
              WHERE itm.FAC_NO = '00945'
                AND scd.CAT_ID IS NOT NULL"
yihui commented 8 years ago

That is due to a bug in base R: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16354 I'll see if I can find a workaround on my side.

jholtman commented 8 years ago

Thanks for tracking it down. I will look for a fix in the future.

Jim Holtman Data Munger Guru

What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.

On Mon, Mar 21, 2016 at 3:00 PM, Yihui Xie notifications@github.com wrote:

That is due to a bug in base R: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16354 I'll see if I can find a workaround on my side.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/yihui/formatR/issues/50#issuecomment-199425695

yihui commented 8 years ago

Should be fixed now. Thanks!