How to pass multiple ids in batches and than merge it in RHow to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to make a great R reproducible exampleSimultaneously merge multiple data.frames in a listWhy is `[` better than `subset`?How can we make xkcd style graphs?Group by multiple columns in dplyr, using string vector inputFixing a multiple warning “unknown column”Passing column names through multiple functions with dplyrPassing multiple arguments to function in dplyr::summarise_if

Ethernet, Wifi and a little human psychology

geschafft or geschaffen? which one is past participle of schaffen?

Wrong Schengen Visa exit stamp on my passport, who can I complain to?

Help with wheel lock

Permutations in Disguise

What are the advantages and disadvantages of tail wheels that cause modern airplanes to not use them?

Python web-scraper to download table of transistor counts from Wikipedia

Why is belonging not transitive?

What is the source of "You can achieve a lot with hate, but even more with love" (Shakespeare?)

Exam design: give maximum score per question or not?

Make 2019 with single digits

Why does an orbit become hyperbolic when total orbital energy is positive?

Is it appropriate to CC a lot of people on an email

Why is the UK still pressing on with Brexit?

Asked to Not Use Transactions and to Use A Workaround to Simulate One

What does this line from The hobbit mean?

Is there any reason to concentrate on the Thunderous Smite spell after using its effects?

What is a "major country" as named in Bernie Sanders' Healthcare debate answers?

Bit one of the Intel 8080's Flags register

How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?

Answer Not A Fool, or Answer A Fool?

In what sequence should an advanced civilization teach technology to medieval society to maximize rate of adoption?

How can I use expandafter the expand the definition of this control sequence?

Why are some files not movable on Windows 10?



How to pass multiple ids in batches and than merge it in R


How to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)How to make a great R reproducible exampleSimultaneously merge multiple data.frames in a listWhy is `[` better than `subset`?How can we make xkcd style graphs?Group by multiple columns in dplyr, using string vector inputFixing a multiple warning “unknown column”Passing column names through multiple functions with dplyrPassing multiple arguments to function in dplyr::summarise_if






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have below mentioned dataframe in R.



DF1



ID Sales Cost Value
RTT-123 10 10000 15000
RTT-456 15 12000 17000
RTT-789 14 14000 19000


The dataframe containst almost ~30K unique Ids, while passing these ids to redshift using below mentioned query, I am getting error Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :



How to pass these Ids automatically in the batch of 2K ids while querying and then merge the output to one single data frame in R.



Query:



df2<-paste0("SELECT ID,list1,list2, date1 FROM table1 b
WHERE b.ID IN (", paste(shQuote(DF1$ID , type = "sh"),collapse = ','),");")

output<-dbGetQuery(link,df2)









share|improve this question






























    2















    I have below mentioned dataframe in R.



    DF1



    ID Sales Cost Value
    RTT-123 10 10000 15000
    RTT-456 15 12000 17000
    RTT-789 14 14000 19000


    The dataframe containst almost ~30K unique Ids, while passing these ids to redshift using below mentioned query, I am getting error Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :



    How to pass these Ids automatically in the batch of 2K ids while querying and then merge the output to one single data frame in R.



    Query:



    df2<-paste0("SELECT ID,list1,list2, date1 FROM table1 b
    WHERE b.ID IN (", paste(shQuote(DF1$ID , type = "sh"),collapse = ','),");")

    output<-dbGetQuery(link,df2)









    share|improve this question


























      2












      2








      2








      I have below mentioned dataframe in R.



      DF1



      ID Sales Cost Value
      RTT-123 10 10000 15000
      RTT-456 15 12000 17000
      RTT-789 14 14000 19000


      The dataframe containst almost ~30K unique Ids, while passing these ids to redshift using below mentioned query, I am getting error Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :



      How to pass these Ids automatically in the batch of 2K ids while querying and then merge the output to one single data frame in R.



      Query:



      df2<-paste0("SELECT ID,list1,list2, date1 FROM table1 b
      WHERE b.ID IN (", paste(shQuote(DF1$ID , type = "sh"),collapse = ','),");")

      output<-dbGetQuery(link,df2)









      share|improve this question














      I have below mentioned dataframe in R.



      DF1



      ID Sales Cost Value
      RTT-123 10 10000 15000
      RTT-456 15 12000 17000
      RTT-789 14 14000 19000


      The dataframe containst almost ~30K unique Ids, while passing these ids to redshift using below mentioned query, I am getting error Error in .verify.JDBC.result(r, "Unable to retrieve JDBC result set for ", :



      How to pass these Ids automatically in the batch of 2K ids while querying and then merge the output to one single data frame in R.



      Query:



      df2<-paste0("SELECT ID,list1,list2, date1 FROM table1 b
      WHERE b.ID IN (", paste(shQuote(DF1$ID , type = "sh"),collapse = ','),");")

      output<-dbGetQuery(link,df2)






      r dplyr tidyverse






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 11:37









      Vector JXVector JX

      2472 silver badges15 bronze badges




      2472 silver badges15 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          Something like this (not tested), here we are using 1000 IDs at a time, adjust as per your needs:



          library(data.table) # rbindlist

          output <- rbindlist(
          lapply(
          # 1000 chunks
          split(DF1$ID, ceiling(seq_along(DF1$ID)/1000)),
          function(i)
          df2 <- paste0("SELECT ID,list1,list2, date1 FROM table1 b
          WHERE b.ID IN (",
          paste(shQuote(i , type = "sh"), collapse = ','),
          ");")
          dbGetQuery(link, df2)
          ))





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396644%2fhow-to-pass-multiple-ids-in-batches-and-than-merge-it-in-r%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            Something like this (not tested), here we are using 1000 IDs at a time, adjust as per your needs:



            library(data.table) # rbindlist

            output <- rbindlist(
            lapply(
            # 1000 chunks
            split(DF1$ID, ceiling(seq_along(DF1$ID)/1000)),
            function(i)
            df2 <- paste0("SELECT ID,list1,list2, date1 FROM table1 b
            WHERE b.ID IN (",
            paste(shQuote(i , type = "sh"), collapse = ','),
            ");")
            dbGetQuery(link, df2)
            ))





            share|improve this answer





























              0
















              Something like this (not tested), here we are using 1000 IDs at a time, adjust as per your needs:



              library(data.table) # rbindlist

              output <- rbindlist(
              lapply(
              # 1000 chunks
              split(DF1$ID, ceiling(seq_along(DF1$ID)/1000)),
              function(i)
              df2 <- paste0("SELECT ID,list1,list2, date1 FROM table1 b
              WHERE b.ID IN (",
              paste(shQuote(i , type = "sh"), collapse = ','),
              ");")
              dbGetQuery(link, df2)
              ))





              share|improve this answer



























                0














                0










                0









                Something like this (not tested), here we are using 1000 IDs at a time, adjust as per your needs:



                library(data.table) # rbindlist

                output <- rbindlist(
                lapply(
                # 1000 chunks
                split(DF1$ID, ceiling(seq_along(DF1$ID)/1000)),
                function(i)
                df2 <- paste0("SELECT ID,list1,list2, date1 FROM table1 b
                WHERE b.ID IN (",
                paste(shQuote(i , type = "sh"), collapse = ','),
                ");")
                dbGetQuery(link, df2)
                ))





                share|improve this answer













                Something like this (not tested), here we are using 1000 IDs at a time, adjust as per your needs:



                library(data.table) # rbindlist

                output <- rbindlist(
                lapply(
                # 1000 chunks
                split(DF1$ID, ceiling(seq_along(DF1$ID)/1000)),
                function(i)
                df2 <- paste0("SELECT ID,list1,list2, date1 FROM table1 b
                WHERE b.ID IN (",
                paste(shQuote(i , type = "sh"), collapse = ','),
                ");")
                dbGetQuery(link, df2)
                ))






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 11:48









                zx8754zx8754

                32.6k8 gold badges72 silver badges114 bronze badges




                32.6k8 gold badges72 silver badges114 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396644%2fhow-to-pass-multiple-ids-in-batches-and-than-merge-it-in-r%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현