I'm using tibble's glimpse function that prints output adjusted to RStudio's console width. To get the most descriptive output, I want RStudio's console width to be large (something like 180).
How do I set the width using code and not manually? getOption("width") or options("width")[[1]] returns the width, but I cannot set it to a value as that throws an error.
Edit: I've even tried setting width using options("width" = 180). This step although edits width parameter but does not expand RStudio's console.
To change the width option, use
options(width = 180)
Related
I'm using tibble's glimpse function that prints output adjusted to RStudio's console width. To get the most descriptive output, I want RStudio's console width to be large (something like 180).
How do I set the width using code and not manually? getOption("width") or options("width")[[1]] returns the width, but I cannot set it to a value as that throws an error.
Edit: I've even tried setting width using options("width" = 180). This step although edits width parameter but does not expand RStudio's console.
To change the width option, use
options(width = 180)
I prepared some bokeh plots to display as html.
To this end I prepared a gridplot containing the subplots, the legends and some headings. This all displays extremely nice in HTML and with sizing_mode='stretch_width' it's even kind of responsive.
webpage = gridplot([[header_col],[panel_grid_plot]], toolbar_location=None, sizing_mode='stretch_width')
show(webpage)
Now I also want to export this "webpage" to a PNG. To this end, I use
export_png(webpage, filename= png_filename, width=1800)
Unfortunately, the width parameter is ignored as the webpage is an object of type gridbox and not of type Plot. (This is checked in the bokeh/io/export.py in the method def get_layout_html())
The output is a png of a width of 800px which is kind of useless as the actual information is crushed (while the legends are nicely scaled):
Any ideas how to set the width of my PNG export to useful values?
Is there a way to convert a gridboxto a Plot?
Thanx!
You should've received a warning saying that the width argument will be ignored since you're passing into export_png something that's not a plot.
A way of achieving what you want:
webpage = gridplot(..., sizing_mode='stretch_width')
webpage.width = 1800
export_png(webpage)
In my package dndTree I use htmlwidgets to render drag-and-drop diagonal trees as implemented here. I changed the original code to be one big function makeTree(treeData,el) where treeData is JSON (created from jsonlite) and el is the element passed in from HTMLWidgets.
In the examples I saw online the way for setting the size of the d3 block was:
var width = el.getBoundingClientRect().width;
var height = el.getBoundingClientRect().height;
var tree = d3.layout.tree()
.size([height, width]);
This method worked fine for making the graph in the RStudio viewer and even popping it out to the browser. However, when using the included Shiny hooks, the el.getBoundingClientRect().height returned 0 (I checked with a console.log(height);). The width responded appropriately using the shiny hooks but I couldn't do anything to get the height to respond to inputs.
I took it a step further back and in the file dndTree.js in the initialize step I included a console log:
initialize: function(el, width, height) {
console.log(height);
return{}
}
which also returned a 0 for height.
Ultimately I added another argument to the function that makes the tree, fHeight which, if the bounding rectangle reports a height of 0 sets the height to fHeight. This isn't a good solution though because now there are two apparent height controllers but only one works and it only works when supplying the number of pixels as a number.
Why does the el element have a height of 0 when using the default shiny hooks?
This is my first attempt at using htmlwidgets and I'll be very honest that I've never written d3 from scratch. I've been taking working examples and trying to make it into a usable widget. My package code is on github (https://github.com/bmewing/df2hjson), but hopefully the relevant nuggets here are enough to identify my mistakes.
I'm setting the default device to PNG options(device="png").
For one plot, I can make a PNG in R with particular dimensions using png(...):
v <- 1:10
png("squared.png", width = 960, height = 480)
plot(v, v**2)
dev.off()
But I want to set the default height/width (just like I'm setting the default device) so that all plots come out with my desired height and width.
Ah, this is what I'm looking for:
options(device = function() png(width = 960))
The device argument should be
a character string giving the name of a function, or the function object itself, which when called creates a new graphics device of the default type for that session...
Using a function instead of the string "png" gives me the flexibility I need.
Why don't you re-define png? If you type png into the console, R will display the function code. You can copy and paste it into an R script, changing its defaults. Then, the autocomplete of the function arguments will still work.
So i have done an entire gwidget script which creates the GUI for running my scripts .
win <- gwindow("TITLE HERE",height=500,weight=500)
However it seems that whenever i maximize the window, or elongate the window size by dragging it, it breaks and the size doesn't fix anymore.
Any idea how to force the window to not be able to resize ? or a permanent way to fix the size.
Here is an image of my situation
http://imgur.com/cEtU773
I'm also using gwidgets and gwidgetscltk package
I think is not possible using gwidgets. You can set andle a "resize event or signal".
One alternative is to use RGtk2 (GTK+ 2.0):
library(RGtk2)
win <- gtkWindow("toplevel", show = FALSE)
gtkWidgetSetSizeRequest(win, 500, 500)
win$show()
gtkWindowSetResizable(win, FALSE)