R how to print different types of variables into one txt file Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to flush output of print function?How do I hide an element when printing a web page?Print a file skipping first X lines in BashHow to use HTML to print header and footer on every printed page of a document?How to print objects of class using print()?The difference between sys.stdout.write and print?How to print to stderr in Python?Print string and variable contents on the same line in RPass R object name as argument in shellSelectively Import only Json data in txt file into R.

AppleTVs create a chatty alternate WiFi network

Flash light on something

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

How to compare two different files line by line in unix?

Would it be easier to apply for a UK visa if there is a host family to sponsor for you in going there?

Why are my pictures showing a dark band on one edge?

Girl Hackers - Logic Puzzle

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

Can a sorcerer use careful spell on himself?

What does 丫 mean? 丫是什么意思?

Is CEO the "profession" with the most psychopaths?

Karn the great creator - 'card from outside the game' in sealed

Deconstruction is ambiguous

Putting class ranking in CV, but against dept guidelines

How were pictures turned from film to a big picture in a picture frame before digital scanning?

Crossing US/Canada Border for less than 24 hours

The test team as an enemy of development? And how can this be avoided?

How many time has Arya actually used Needle?

Significance of Cersei's obsession with elephants?

Why weren't discrete x86 CPUs ever used in game hardware?

In musical terms, what properties are varied by the human voice to produce different words / syllables?

What would you call this weird metallic apparatus that allows you to lift people?

What is the meaning of 'breadth' in breadth first search?

Is multiple magic items in one inherently imbalanced?



R how to print different types of variables into one txt file



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to flush output of print function?How do I hide an element when printing a web page?Print a file skipping first X lines in BashHow to use HTML to print header and footer on every printed page of a document?How to print objects of class using print()?The difference between sys.stdout.write and print?How to print to stderr in Python?Print string and variable contents on the same line in RPass R object name as argument in shellSelectively Import only Json data in txt file into R.



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








0















I have a lm model, a numeric vector from vif function, and some character variables.



gvmodel<-gvlma(lmFit)
VIF<-sqrt(vif(lmFit))
Str1<-"Original R-square=".567"
Str2<-"Cross-validated R-Square=.123"


I would like to print content of all into one single txt file. I tried cat and capture.output.



cat(gvmodel,VIF,Str1, file="E:/.../text.txt")
capture.output(paste(gvmodel,VIF,...,sep=""),file="E:/.../text.txt")


Obviously this did not work. Anyone how to print them into a single txt file? Thanks










share|improve this question
























  • Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

    – brettljausn
    Mar 22 at 11:11











  • Sorry that was just a typo here

    – davidzxc574
    Mar 23 at 14:05

















0















I have a lm model, a numeric vector from vif function, and some character variables.



gvmodel<-gvlma(lmFit)
VIF<-sqrt(vif(lmFit))
Str1<-"Original R-square=".567"
Str2<-"Cross-validated R-Square=.123"


I would like to print content of all into one single txt file. I tried cat and capture.output.



cat(gvmodel,VIF,Str1, file="E:/.../text.txt")
capture.output(paste(gvmodel,VIF,...,sep=""),file="E:/.../text.txt")


Obviously this did not work. Anyone how to print them into a single txt file? Thanks










share|improve this question
























  • Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

    – brettljausn
    Mar 22 at 11:11











  • Sorry that was just a typo here

    – davidzxc574
    Mar 23 at 14:05













0












0








0








I have a lm model, a numeric vector from vif function, and some character variables.



gvmodel<-gvlma(lmFit)
VIF<-sqrt(vif(lmFit))
Str1<-"Original R-square=".567"
Str2<-"Cross-validated R-Square=.123"


I would like to print content of all into one single txt file. I tried cat and capture.output.



cat(gvmodel,VIF,Str1, file="E:/.../text.txt")
capture.output(paste(gvmodel,VIF,...,sep=""),file="E:/.../text.txt")


Obviously this did not work. Anyone how to print them into a single txt file? Thanks










share|improve this question
















I have a lm model, a numeric vector from vif function, and some character variables.



gvmodel<-gvlma(lmFit)
VIF<-sqrt(vif(lmFit))
Str1<-"Original R-square=".567"
Str2<-"Cross-validated R-Square=.123"


I would like to print content of all into one single txt file. I tried cat and capture.output.



cat(gvmodel,VIF,Str1, file="E:/.../text.txt")
capture.output(paste(gvmodel,VIF,...,sep=""),file="E:/.../text.txt")


Obviously this did not work. Anyone how to print them into a single txt file? Thanks







r printing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 14:06







davidzxc574

















asked Mar 22 at 11:02









davidzxc574davidzxc574

9110




9110












  • Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

    – brettljausn
    Mar 22 at 11:11











  • Sorry that was just a typo here

    – davidzxc574
    Mar 23 at 14:05

















  • Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

    – brettljausn
    Mar 22 at 11:11











  • Sorry that was just a typo here

    – davidzxc574
    Mar 23 at 14:05
















Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

– brettljausn
Mar 22 at 11:11





Str1<-""Original R-square=".567" should be Str1 <- "Original R-square=.567" What error message is R throwing?

– brettljausn
Mar 22 at 11:11













Sorry that was just a typo here

– davidzxc574
Mar 23 at 14:05





Sorry that was just a typo here

– davidzxc574
Mar 23 at 14:05












2 Answers
2






active

oldest

votes


















1














Sink() works. Sink a txt file path and name, run any command that produces text outputs and they will be captured in the txt file. And finally sink() to close.



 sink("E:/.../Sink.txt")
gvmodel
sqrt(vif(ModeName))
sink()





share|improve this answer






























    0














    In your code gvmodel<-gvlma(lmFit) produces gvlma object. It cannot be directly printed to .txt file as such. You can transform it first to characters using as.character() option:



    gvmodel<-gvlma(lmFit)
    gvmodel <- as.character(gvmodel)


    The result is printable for example with cat. So if you put all this together:



    gvmodel<-gvlma(lmFit)
    gvmodel <- as.character(gvmodel)
    VIF<-sqrt(vif(lmFit))
    Str1<-"Original R-square=.567"
    Str2<-"Cross-validated R-Square=.123" # NB the corrected quotation marks

    cat(gvmodel,VIF,Str1, file="yourfile.txt",sep="t")





    share|improve this answer

























    • Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

      – davidzxc574
      Mar 25 at 2:18











    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%2f55298221%2fr-how-to-print-different-types-of-variables-into-one-txt-file%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Sink() works. Sink a txt file path and name, run any command that produces text outputs and they will be captured in the txt file. And finally sink() to close.



     sink("E:/.../Sink.txt")
    gvmodel
    sqrt(vif(ModeName))
    sink()





    share|improve this answer



























      1














      Sink() works. Sink a txt file path and name, run any command that produces text outputs and they will be captured in the txt file. And finally sink() to close.



       sink("E:/.../Sink.txt")
      gvmodel
      sqrt(vif(ModeName))
      sink()





      share|improve this answer

























        1












        1








        1







        Sink() works. Sink a txt file path and name, run any command that produces text outputs and they will be captured in the txt file. And finally sink() to close.



         sink("E:/.../Sink.txt")
        gvmodel
        sqrt(vif(ModeName))
        sink()





        share|improve this answer













        Sink() works. Sink a txt file path and name, run any command that produces text outputs and they will be captured in the txt file. And finally sink() to close.



         sink("E:/.../Sink.txt")
        gvmodel
        sqrt(vif(ModeName))
        sink()






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 10:25









        davidzxc574davidzxc574

        9110




        9110























            0














            In your code gvmodel<-gvlma(lmFit) produces gvlma object. It cannot be directly printed to .txt file as such. You can transform it first to characters using as.character() option:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)


            The result is printable for example with cat. So if you put all this together:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)
            VIF<-sqrt(vif(lmFit))
            Str1<-"Original R-square=.567"
            Str2<-"Cross-validated R-Square=.123" # NB the corrected quotation marks

            cat(gvmodel,VIF,Str1, file="yourfile.txt",sep="t")





            share|improve this answer

























            • Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

              – davidzxc574
              Mar 25 at 2:18















            0














            In your code gvmodel<-gvlma(lmFit) produces gvlma object. It cannot be directly printed to .txt file as such. You can transform it first to characters using as.character() option:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)


            The result is printable for example with cat. So if you put all this together:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)
            VIF<-sqrt(vif(lmFit))
            Str1<-"Original R-square=.567"
            Str2<-"Cross-validated R-Square=.123" # NB the corrected quotation marks

            cat(gvmodel,VIF,Str1, file="yourfile.txt",sep="t")





            share|improve this answer

























            • Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

              – davidzxc574
              Mar 25 at 2:18













            0












            0








            0







            In your code gvmodel<-gvlma(lmFit) produces gvlma object. It cannot be directly printed to .txt file as such. You can transform it first to characters using as.character() option:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)


            The result is printable for example with cat. So if you put all this together:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)
            VIF<-sqrt(vif(lmFit))
            Str1<-"Original R-square=.567"
            Str2<-"Cross-validated R-Square=.123" # NB the corrected quotation marks

            cat(gvmodel,VIF,Str1, file="yourfile.txt",sep="t")





            share|improve this answer















            In your code gvmodel<-gvlma(lmFit) produces gvlma object. It cannot be directly printed to .txt file as such. You can transform it first to characters using as.character() option:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)


            The result is printable for example with cat. So if you put all this together:



            gvmodel<-gvlma(lmFit)
            gvmodel <- as.character(gvmodel)
            VIF<-sqrt(vif(lmFit))
            Str1<-"Original R-square=.567"
            Str2<-"Cross-validated R-Square=.123" # NB the corrected quotation marks

            cat(gvmodel,VIF,Str1, file="yourfile.txt",sep="t")






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 22 at 12:33

























            answered Mar 22 at 12:22









            OkaOka

            73729




            73729












            • Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

              – davidzxc574
              Mar 25 at 2:18

















            • Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

              – davidzxc574
              Mar 25 at 2:18
















            Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

            – davidzxc574
            Mar 25 at 2:18





            Thanks for the advice. I transformed gvmodel into character and it was printed out like this: lm(formula = Murder ~ ., data = DataTraining) Murder ~ Population + Illiteracy + Income + Frost c(Alabama = 4.04095098567961, Arizona = -1.50265504165748, California = -0.0650525845054262, Colorado = 1.54774873568549, Connecticut = -3.61072262553982... Residuals and effects of every observation was printed without changing line.

            – davidzxc574
            Mar 25 at 2:18

















            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%2f55298221%2fr-how-to-print-different-types-of-variables-into-one-txt-file%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권, 지리지 충청도 공주목 은진현