Referencing column names in data table =:Select / assign to data.table when variable names are stored in a character vectorHow to sort a dataframe by multiple column(s)Referencing a column vector in a data frame within a loopDrop data frame columns by nameChanging column names of a data frameLoop through columns in a data.table and transform those columnsdata.table vs dplyr: can one do something well the other can't or does poorly?dplyr - mutate: use dynamic variable namesget numeric column values in data table in rIn R produce a running count in column based on previous column with numeric valuesSubtract two data.tables

Better random (unique) file name

Did William Shakespeare hide things in his writings?

Bringing coumarin-containing liquor into the USA

Do intermediate subdomains need to exist?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

Is conquering your neighbors to fight a greater enemy a valid strategy?

Passwordless authentication - how invalidate login code

Chilling juice in copper vessel

Multi-user CRUD: Valid, Problem, or Error?

Wearing special clothes in public while in niddah- isn't this a lack of tznius?

Why do we need a bootloader separate from our application program in microcontrollers?

Who goes first? Person disembarking bus or the bicycle?

In the Seventh Seal why does Death let the chess game happen?

Shipped package arrived - didn't order, possible scam?

Find max number you can create from an array of numbers

Wouldn't putting an electronic key inside a small Faraday cage render it completely useless?

Why did Super-VGA offer the 5:4 1280*1024 resolution?

Is this car delivery via Ebay Motors on Craigslist a scam?

Park the computer

Why no parachutes in the Orion AA2 abort test?

What is the shape of the upper boundary of water hitting a screen?

How to reclaim personal item I've lent to the office without burning bridges?

How many Jimmys can fit?

Why isn't 10.0.0.0/8 used instead of 192.168.0.0/16 for private addresses?



Referencing column names in data table =:


Select / assign to data.table when variable names are stored in a character vectorHow to sort a dataframe by multiple column(s)Referencing a column vector in a data frame within a loopDrop data frame columns by nameChanging column names of a data frameLoop through columns in a data.table and transform those columnsdata.table vs dplyr: can one do something well the other can't or does poorly?dplyr - mutate: use dynamic variable namesget numeric column values in data table in rIn R produce a running count in column based on previous column with numeric valuesSubtract two data.tables






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








1















I'm running a loop in which two numeric columns are created based on some data. These two column names are generated by the part of the loop they are in. So for example, the first two columns are df$loop1.1 and df$loop1.2 and then in the following loop they'd be df$loop2.1 and df$loop2.2



I need to create a third column that is based off of those two columns like so:



df[, divisioncol := loop1.1 / loop1.2]


However, I'm getting the error



 non-numeric argument to binary operator


Any suggestions?



Solved:



 df[, divisioncol := get(loop1.1)/get(loop2.2)]









share|improve this question



















  • 1





    If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

    – Frank
    Mar 25 at 20:58


















1















I'm running a loop in which two numeric columns are created based on some data. These two column names are generated by the part of the loop they are in. So for example, the first two columns are df$loop1.1 and df$loop1.2 and then in the following loop they'd be df$loop2.1 and df$loop2.2



I need to create a third column that is based off of those two columns like so:



df[, divisioncol := loop1.1 / loop1.2]


However, I'm getting the error



 non-numeric argument to binary operator


Any suggestions?



Solved:



 df[, divisioncol := get(loop1.1)/get(loop2.2)]









share|improve this question



















  • 1





    If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

    – Frank
    Mar 25 at 20:58














1












1








1








I'm running a loop in which two numeric columns are created based on some data. These two column names are generated by the part of the loop they are in. So for example, the first two columns are df$loop1.1 and df$loop1.2 and then in the following loop they'd be df$loop2.1 and df$loop2.2



I need to create a third column that is based off of those two columns like so:



df[, divisioncol := loop1.1 / loop1.2]


However, I'm getting the error



 non-numeric argument to binary operator


Any suggestions?



Solved:



 df[, divisioncol := get(loop1.1)/get(loop2.2)]









share|improve this question
















I'm running a loop in which two numeric columns are created based on some data. These two column names are generated by the part of the loop they are in. So for example, the first two columns are df$loop1.1 and df$loop1.2 and then in the following loop they'd be df$loop2.1 and df$loop2.2



I need to create a third column that is based off of those two columns like so:



df[, divisioncol := loop1.1 / loop1.2]


However, I'm getting the error



 non-numeric argument to binary operator


Any suggestions?



Solved:



 df[, divisioncol := get(loop1.1)/get(loop2.2)]






r data.table






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 21:00







Justin

















asked Mar 25 at 20:46









JustinJustin

223 bronze badges




223 bronze badges







  • 1





    If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

    – Frank
    Mar 25 at 20:58













  • 1





    If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

    – Frank
    Mar 25 at 20:58








1




1





If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

– Frank
Mar 25 at 20:58






If you are passing the column names, maybe wrap in get, like get(loop1.1) / get(loop1.2) stackoverflow.com/q/12391950

– Frank
Mar 25 at 20:58













1 Answer
1






active

oldest

votes


















0














Your error is caused by a non-numeric argument to a binary operator. The binary operator here is the function /, which is division. This means that either loop1.1 or loop1.2 contains a non-numeric value. Verify this by typing typeof(df$loop1.1) and typeof(df$loop1.2)






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/3.0/"u003ecc by-sa 3.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%2f55346163%2freferencing-column-names-in-data-table%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














    Your error is caused by a non-numeric argument to a binary operator. The binary operator here is the function /, which is division. This means that either loop1.1 or loop1.2 contains a non-numeric value. Verify this by typing typeof(df$loop1.1) and typeof(df$loop1.2)






    share|improve this answer



























      0














      Your error is caused by a non-numeric argument to a binary operator. The binary operator here is the function /, which is division. This means that either loop1.1 or loop1.2 contains a non-numeric value. Verify this by typing typeof(df$loop1.1) and typeof(df$loop1.2)






      share|improve this answer

























        0












        0








        0







        Your error is caused by a non-numeric argument to a binary operator. The binary operator here is the function /, which is division. This means that either loop1.1 or loop1.2 contains a non-numeric value. Verify this by typing typeof(df$loop1.1) and typeof(df$loop1.2)






        share|improve this answer













        Your error is caused by a non-numeric argument to a binary operator. The binary operator here is the function /, which is division. This means that either loop1.1 or loop1.2 contains a non-numeric value. Verify this by typing typeof(df$loop1.1) and typeof(df$loop1.2)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 20:49









        Corey LevinsonCorey Levinson

        3253 silver badges12 bronze badges




        3253 silver badges12 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%2f55346163%2freferencing-column-names-in-data-table%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권, 지리지 충청도 공주목 은진현