13

I am using a Jupyter notebook with an R kernel. When I print rectangular data, e.g., a matrix, it only shows me the first 10 and last 10 columns:

enter image description here

The same thing happens for data.frames, or any other object that is printed in an HTML table.

How do I change this setting?

Jonathan
  • 1,864
  • 17
  • 26

2 Answers2

24

Figured it out. You can set these in options():

options(repr.matrix.max.cols=50, repr.matrix.max.rows=100)

They default to cols=20 and rows=60.

Jonathan
  • 1,864
  • 17
  • 26
  • 1
    Why was this downvoted? It solved the problem. Maybe I should have posted a screenshot showing the problem resolved? – Jonathan Dec 22 '16 at 16:12
  • This is a good answer. Does anyone know how to change Jupyter's default so we don't have to include this in every script? – carbocation Nov 04 '19 at 03:16
  • @carbocation Maybe try putting them in a startup script? If you need tips on how to do that, try https://stackoverflow.com/questions/45818538/where-can-i-put-a-startup-script-in-jupyter. Note, I haven't tried this myself, just a suggestion. – Jonathan Nov 05 '19 at 12:15
  • @Ma Li that error looks like Python but this is a question about R. – Jonathan Jan 06 '22 at 19:50
-3

Jupiter truncates the output. But if you do

print(matrix(1:30, ncol=30))

or

df <- as.data.frame(matrix(1:30, ncol=30))
print(df)

you should get the full matrix or df output.

MarBlo
  • 4,195
  • 1
  • 13
  • 27
  • This does not answer the question at all. I wanted to know how to change the Jupyter HTML display, as shown in the included screenshot, and these answers produce a text display. – Jonathan Dec 22 '16 at 16:09
  • @Jonathan sorry, if this was not what you were looking for, but you have found your own answer to it anyhow. – MarBlo Dec 22 '16 at 17:09