Reputation: 1740
fit.iris.lm <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)
summary(fit.iris.lm)
This gives us the following output:
I'm looking for a way to copy/paste the coefficients table from R console to Excel by highlighting the table and then Ctrl+C/Ctrl+V-ing it into Excel.
However, upon pasting it into Excel, all the columns are condensed into a single column:
I am looking for a way to copy/paste this output into Excel with all columns (Estimate, Std. Error) retained instead of condensed in one column and I am specifically looking for a way to do this without using any R functions for exporting tables (like write_xlsx)
or any other similar functions - I just want to copy and paste it.
Upvotes: 4
Views: 2293
Reputation: 37641
You could also just clean this up on the Excel side. After you paste it in Excel, select the pasted text. On the "Data" tab on the ribbon, select "Text to Columns".
This will open a dialog box. Leave it at "Fixed Width" and click "Next".
This should give you a preview of the way that it will divide the columns. For your example, it was fine so just click "Finish".
You get the result I think you want.
Upvotes: 3
Reputation: 34501
You can't avoid using any function but if you just want something you can neatly paste you can use broom::tidy()
to convert the values into a tibble and clipr::write_clip()
to copy it to the clipboard.
library(broom)
library(clipr)
library(magrittr)
lm(Sepal.Length ~ Petal.Length + Petal.Width, iris) %>%
tidy() %>%
write_clip()
Pasted into Excel:
Upvotes: 4