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;
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
add a comment |
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
Str1<-""Original R-square=".567"
should beStr1 <- "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
add a comment |
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
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
r printing
edited Mar 23 at 14:06
davidzxc574
asked Mar 22 at 11:02
davidzxc574davidzxc574
9110
9110
Str1<-""Original R-square=".567"
should beStr1 <- "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
add a comment |
Str1<-""Original R-square=".567"
should beStr1 <- "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
add a comment |
2 Answers
2
active
oldest
votes
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()
add a comment |
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")
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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()
add a comment |
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()
add a comment |
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()
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()
answered Mar 25 at 10:25
davidzxc574davidzxc574
9110
9110
add a comment |
add a comment |
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")
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
add a comment |
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")
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
add a comment |
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")
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")
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Str1<-""Original R-square=".567"
should beStr1 <- "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