Get variables names from a data frame in a vectorHow to join (merge) data frames (inner, outer, left, right)Grouping functions (tapply, by, aggregate) and the *apply familyDrop data frame columns by nameR: losing column names when adding rows to an empty data frameHow to succinctly write a formula with many variables from a data frame?Convert the values in a column into row names in an existing data frame in RConvert a row of a data frame to vectorConvert Named Character Vector to data.frameDynamically select data frame columns using $ and a vector of column namesInsert alternating vectors into data frame

What stroke width Instagram is using for its icons and how to get same results?

c++ what does , means after if

iMac 27" 2017 memory upgrade question

Why was Thor doubtful about his worthiness to Mjolnir?

Run script for 10 times until meets the condition, but break the loop if it meets the condition during iteration

How to make a language evolve quickly?

Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?

"Right on the tip of my tongue" meaning?

Is it a bad idea to replace pull-up resistors with hard pull-ups?

Drawing lines to nearest point

Unable to execute two commands in Startup Applications

What to do if SUS scores contradict qualitative feedback?

How to compact two the parabol commands in the following example?

Why was castling bad for white in this game, and engine strongly prefered trading queens?

Smallest Guaranteed hash collision cycle length

Can you book a one-way ticket to the UK on a visa?

Why didn't Aeroflot Flight 1492 dump its fuel first?

Why can't RGB or bicolour LEDs produce a decent yellow?

Is the schwa sound consistent?

Meaning of「〜てみたいと思います」

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

The CompuTaria Quest - A young Wizard's journey

How can I answer high-school writing prompts without sounding weird and fake?

How could a Lich maintain the appearance of being alive without magic?



Get variables names from a data frame in a vector


How to join (merge) data frames (inner, outer, left, right)Grouping functions (tapply, by, aggregate) and the *apply familyDrop data frame columns by nameR: losing column names when adding rows to an empty data frameHow to succinctly write a formula with many variables from a data frame?Convert the values in a column into row names in an existing data frame in RConvert a row of a data frame to vectorConvert Named Character Vector to data.frameDynamically select data frame columns using $ and a vector of column namesInsert alternating vectors into data frame






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I can obtain the names of my variables of a data frame with the command "names (df)". It gives say:



#[1] "V1" "V2" "V3"


But I would like to obtain a vector, something like this:



c("V1", "V2", "V3")


Is this possible in R?



Thanks in advance for your response



Richard










share|improve this question



















  • 1





    I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

    – Stéphane Laurent
    Mar 23 at 11:30











  • Thank you very much. It's exactly that I need !

    – R. Ladwein
    Mar 23 at 11:37

















0















I can obtain the names of my variables of a data frame with the command "names (df)". It gives say:



#[1] "V1" "V2" "V3"


But I would like to obtain a vector, something like this:



c("V1", "V2", "V3")


Is this possible in R?



Thanks in advance for your response



Richard










share|improve this question



















  • 1





    I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

    – Stéphane Laurent
    Mar 23 at 11:30











  • Thank you very much. It's exactly that I need !

    – R. Ladwein
    Mar 23 at 11:37













0












0








0








I can obtain the names of my variables of a data frame with the command "names (df)". It gives say:



#[1] "V1" "V2" "V3"


But I would like to obtain a vector, something like this:



c("V1", "V2", "V3")


Is this possible in R?



Thanks in advance for your response



Richard










share|improve this question
















I can obtain the names of my variables of a data frame with the command "names (df)". It gives say:



#[1] "V1" "V2" "V3"


But I would like to obtain a vector, something like this:



c("V1", "V2", "V3")


Is this possible in R?



Thanks in advance for your response



Richard







r vector names






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 11:56









NelsonGon

4,8864934




4,8864934










asked Mar 23 at 11:28









R. LadweinR. Ladwein

63




63







  • 1





    I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

    – Stéphane Laurent
    Mar 23 at 11:30











  • Thank you very much. It's exactly that I need !

    – R. Ladwein
    Mar 23 at 11:37












  • 1





    I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

    – Stéphane Laurent
    Mar 23 at 11:30











  • Thank you very much. It's exactly that I need !

    – R. Ladwein
    Mar 23 at 11:37







1




1





I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

– Stéphane Laurent
Mar 23 at 11:30





I'm not sure to understand. names(df) is the vector c("V1", "V2", "V3"). If you want to print c("V1", "V2", "V3"), you can do dput(names(df)).

– Stéphane Laurent
Mar 23 at 11:30













Thank you very much. It's exactly that I need !

– R. Ladwein
Mar 23 at 11:37





Thank you very much. It's exactly that I need !

– R. Ladwein
Mar 23 at 11:37












1 Answer
1






active

oldest

votes


















0














It is possible and you can just make a new vector with the names like this:



x <- names(df)


..and the names will be stored in vector x






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%2f55313255%2fget-variables-names-from-a-data-frame-in-a-vector%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














    It is possible and you can just make a new vector with the names like this:



    x <- names(df)


    ..and the names will be stored in vector x






    share|improve this answer



























      0














      It is possible and you can just make a new vector with the names like this:



      x <- names(df)


      ..and the names will be stored in vector x






      share|improve this answer

























        0












        0








        0







        It is possible and you can just make a new vector with the names like this:



        x <- names(df)


        ..and the names will be stored in vector x






        share|improve this answer













        It is possible and you can just make a new vector with the names like this:



        x <- names(df)


        ..and the names will be stored in vector x







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 11:39









        OkaOka

        77229




        77229





























            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%2f55313255%2fget-variables-names-from-a-data-frame-in-a-vector%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

            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

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해