0

After running the predict function for glm i get an output in the below format:

           1            2            3            4            5            6            7            8            9           10           11           12 
3.954947e-01 8.938624e-01 7.775473e-01 1.294646e-02 3.954947e-01 9.625746e-01 9.144256e-01 4.739872e-01 1.443219e-01 1.180850e-04 2.138978e-01 7.775473e-01 
          13           14           15           16           17           18           19           20           21           22           23           24 
5.425436e-03 2.069844e-04 2.723969e-01 4.739872e-01 9.144256e-01 1.091998e-01 2.070056e-02 5.114936e-01 1.443219e-01 5.922029e-01 7.578099e-02 8.937642e-01 
          25           26           27           28           29           30           31           32           33           34           35           36 
6.069970e-02 6.069970e-02 1.337947e-01 1.090992e-01 4.841467e-02 9.205547e-01 3.954947e-01 3.874915e-05 3.855242e-02 1.344839e-01 6.318574e-04 2.723969e-01 
          37           38           39           40           41           42           43           44           45           46           47           48 
7.400276e-04 8.593199e-01 6.666800e-01 2.069844e-04 8.161623e-01 4.916555e-05 3.060374e-02 3.402079e-01 2.256598e-03 9.363767e-01 6.116082e-01 3.940969e-03 
          49           50           51           52           53           54           55           56           57           58           59           60 
7.336723e-01 2.425257e-02 3.369967e-03 5.624262e-02 1.090992e-01 1.357630e-06 1.278169e-04 3.046189e-01 8.938624e-01 4.535894e-01 5.132348e-01 3.220426e-01 
          61           62           63           64           65           66           67           68           69           70           71           72 
3.366492e-03 1.357630e-06 1.014721e-01 1.294646e-02 9.144256e-01 1.636988e-02 2.070056e-02 1.012835e-01 5.000274e-03 8.165247e-02 1.357630e-06 8.033850e-03 

IS there any code by which I can get the complete output vertically or in an excel format? Thank you in advance!

Henrik
  • 65,555
  • 14
  • 143
  • 159
user3379326
  • 1
  • 1
  • 1

2 Answers2

1

The simplest way is to write a character separated value file using a comma as the delimiter:

[Acknowledge Roland's comment] write.csv(data.frame(predict(yourGLM)), "file.csv")

Excel reads these automatically, especially if you save the file with a .csv extension.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
1

If its just a matter of viewing it vertically first create the data:

# create test data
example(predict.glm)
pred <- predict(budworm.lg)

1) Separate R Window Use View to display it in a separate R window:

View(pred)

2) R Console to display it on the R console vertically:

data.frame(pred)

3) Browser to display it in the browser vertically:

library(R2HTML)
HTMLStart(); HTML(data.frame(pred)); w <- HTMLStop()
browseURL(w)

4) Excel to display it in Excel vertically using w we just computed:

shell(paste("start excel", w))
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341