[R] copy/paste of large amount of code to terminal leads to scrambled/missing characters

2018-02-03 Thread Martin Batholdy via R-help
Dear R-users,

This question might not be restricted to R, but I hope that some might have 
experienced similar problems and could help me.

When using R, I usually work with a text-editor (textmate2) in which I prepare 
the script.
To execute code, I then copy and paste it to an R-session running in the 
terminal/shell (on Mac OS).

Unfortunately, when pasting too much code into the terminal (e.g. 60 lines), 
some characters are occasionally and randomly scrambled or missing.
For example "col <- ifelse(..." turns into "col < col < cse(…".

This happens very randomly, is difficult to predict, and while it only affects 
a hand full of characters in total, it leads to a lot of errors in the code 
execution along the way.
Apparently, it has to do with the buffer size and paste-speed of the terminal.

So far, I could not find any solution to the problem.

Therefore, I wanted to ask; 
Do others here use a similar workflow (i.e. having a text-editor for coding and 
using copy/paste to the terminal for code execution) and encountered similar 
problems with big chunks of code in the clipboard?
Are there any solutions for this problem, specifically for running R over the 
shell?

Thank you very much!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] draw borders of bars inside of the rectangles in a barplot

2018-05-21 Thread Martin Batholdy via R-help
Dear R-users,

I want to draw a barplot with beside=TRUE.
One halve of the bars are drawn with a border, while the other halve are drawn 
without a border (i.e. filled bars vs. non-filled bars next to each other).

Because borders are drawn around the bars, doing this leads to one halve of the 
bars being wider than the other halve, expanding across the 0-point of the 
y-axis.
This problem emerges especially with small figures and rather large border 
width.

Now my question:
Is there a way to draw the border inside of the bars instead of surrounding the 
bars? (similar to border-drawing options in graphics software, like photoshop 
or inkscape).


Here some example code:

x <- matrix(c(1:10), 2,5)
par(lwd = 5) 
barplot(x, beside=T, border=rep(c(NA, 'black'),5), space=c(0.08,1), 
col=rep(c('black', 'white'),5))



Thank you!
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] set par options once for entire R session

2015-06-23 Thread Martin Batholdy via R-help
Hi,

I would like to set plot-options via par() and keep them for all plots that are 
created thereafter.
Currently after each plot device the parameters I can set with par() are 
reseted to their default value, at least on a Mac (R 3.2.1).

Is there a way to define the parameters for plotting once at the beginning and 
then keep them for an entire R session?


Thank you!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] define absolute size in plots ... possible?

2015-06-24 Thread Martin Batholdy via R-help
Hi,

I would like to define the size for tick-marks, axis-titles, legends, drawing 
symbols etc. absolute,
meaning that regardless of the size of the plot device, the font-size / 
character size is the same.

Thus if I output my plot with pdf(width=5, height=5) or pdf(width=15, 
height=15), the font-size / symbol-size remains the same.


Is that possible in R?


Thank you!
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] define absolute size in plots ... possible?

2015-06-24 Thread Martin Batholdy via R-help
Hi,

> That's the default, isn't it?


I am sorry – one of my plots was actually set up with mfrow.
But the documentation actually explains the change in cex when using mfrow;

"In a layout with exactly two rows and columns the base value of "cex" is 
reduced by a factor of 0.83: if there are three or more of either rows or 
columns, the reduction factor is 0.66.”


On 24 Jun 2015, at 13:17 , Duncan Murdoch  wrote:

> On 24/06/2015 7:08 AM, Martin Batholdy via R-help wrote:
>> Hi,
>> 
>> I would like to define the size for tick-marks, axis-titles, legends, 
>> drawing symbols etc. absolute,
>> meaning that regardless of the size of the plot device, the font-size / 
>> character size is the same.
>> 
>> Thus if I output my plot with pdf(width=5, height=5) or pdf(width=15, 
>> height=15), the font-size / symbol-size remains the same.
>> 
>> 
>> Is that possible in R?
> 
> That's the default, isn't it?
> 
> You need to give some reproducible code and explain what you don't like
> about the results.
> 
> Duncan Murdoch
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] best way to globally set parameters for base graphics

2015-07-20 Thread Martin Batholdy via R-help
Hi,

I am looking for a way to modify the basic setup for any kind of plot.
(everything that is set with the par function – like margins, cex, las etc.)

I want to do this once – preferably across R sessions and not individually 
before every plot.


My first attempt was to add a par() with all my own defaults to the .Rprofile 
file.
This obviously does not work because par opens a new drawing device, applying 
its effect only to this device.

My next attempt was to write my own version of all basic plot functions (like 
plot, barplot etc.) adding a par() call within these functions.
This works but only if I draw a single plot. As soon as I want to use mfrow or 
layout to draw multiple plots side by side into one device this version also 
does not work, since each of these functions will open a new drawing device by 
themselves.


So, my question is;
Is there any way to globally define parameters given to par() so that they 
apply to all plots in (at least) an entire R-session?


Thank You!
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] best way to globally set parameters for base graphics

2015-07-20 Thread Martin Batholdy via R-help
Thanks for the reply.

It works fine for a single plot-call.
But as soon as I call layout() before plotting I again run into the problem 
that plots are not drawn into one graphic device but another one is opened for 
the second plot-call.


see here;


setHook("plot.new", function() 
par(bty='n', 
cex=0.8,
las=1, 
ann=F, 
lwd=2, 
mar=c(5, 4, 2, 1), 
oma=c(0,0,0,0), 
pch=19, 
xpd=T, 
cex.axis=0.85, 
mgp=c(2.5, 0.72, 0),
tcl=-0.4
)
)


layout(matrix(1:2, 1, 2, byrow=T))

plot(c(1,2,3))
plot(c(3,2,1))






On 20 Jul 2015, at 17:48 , Duncan Murdoch  wrote:

> On 20/07/2015 11:27 AM, Martin Batholdy via R-help wrote:
>> Hi,
>> 
>> I am looking for a way to modify the basic setup for any kind of plot.
>> (everything that is set with the par function – like margins, cex, las etc.)
>> 
>> I want to do this once – preferably across R sessions and not individually 
>> before every plot.
>> 
>> 
>> My first attempt was to add a par() with all my own defaults to the 
>> .Rprofile file.
>> This obviously does not work because par opens a new drawing device, 
>> applying its effect only to this device.
>> 
>> My next attempt was to write my own version of all basic plot functions 
>> (like plot, barplot etc.) adding a par() call within these functions.
>> This works but only if I draw a single plot. As soon as I want to use mfrow 
>> or layout to draw multiple plots side by side into one device this version 
>> also does not work, since each of these functions will open a new drawing 
>> device by themselves.
>> 
>> 
>> So, my question is;
>> Is there any way to globally define parameters given to par() so that they 
>> apply to all plots in (at least) an entire R-session?
> 
> I haven't played with it, but setting a "plot.new" hook (or
> "before.plot.new") might do it for you.  See ?plot.new.
> 
> It might be tricky, because some par() parameters (e.g. "mfrow")
> shouldn't be called before every plot.  You'd have to look at
> par("mfrow") to decide whether to call it or not.
> 
> Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] plot 2D matrix of RGB values

2016-01-08 Thread Martin Batholdy via R-help
Hi,

I have a 2 dimensional matrix with RGB values and would like to plot it as a 
two dimensional surface.

I am aware of functions like image() that plot a matrix of values as a grid of 
coloured rectangles.
But I can not directly feed in the specific color value for each of these 
rectangles, as far as I understand.

Is there an easy way to just take a matrix of color values and plot it in R?

Thank You!
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.