I'm using R under Linux. Since the help function in R can use the
program less to display text, I'd like to know if it is possible for a
user to do the same. It would be very helpful to be able to view large
objects (matrices/dataframes etc) using less. This is preferable to
redirecting output to f
On Fri, Mar 12, 2010 at 11:18, David Winsemius wrote:
>
> On Mar 12, 2010, at 11:15 AM, Ali Tofigh wrote:
>
>> I'm using R under Linux. Since the help function in R can use the
>> program less to display text, I'd like to know if it is possible for a
>>
After using pipe() to view output in less, the pipe becomes invalid:
$ p <- pipe("less")
$ capture.output(1:100, file=p)
$ p
Error in summary.connection(x) : invalid connection
$ close(p)
Error in close.connection(p) : invalid connection
Is this a bug? Other uses of pipe works differently:
$ p <
On Fri, Mar 12, 2010 at 14:27, Ted Harding wrote:
> However, all that was a long time ago. Check 'page' in your
> newer R!
Thanks for the tip. But I don't understand what page is supposed to
do. For example,
page(1:3)
simply displays the text string "1:3" in less. And if I do
x <- 1:3
page(x)
I would just get row indices:
row.indices <- as.vector(sapply(0:25 * 5 + 1, function(x)
{sort(sample(x:(x+4), 2))}))
new.data.fram <- your.data.frame[row.indices, ]
Cheers,
/Ali
On Fri, Mar 12, 2010 at 15:06, Hosack, Michael wrote:
> Fellow R users,
>
> I am stumped on what would seem to be som
Here is a suggestion:
tapply(mat[,2], as.factor(m[,1]), sum)
Cheers,
/Ali
On Fri, Mar 12, 2010 at 15:28, Juliet Ndukum wrote:
> mat is a matrix with X and Y values.
>> mat
> X Y
> [1,] 56 20
> [2,] 56 21
> [3,] 2 50
> [4,] 3 46
> [5,] 18 77
> [6,] 57 12
> [7,] 57 36
> [8,] 95 4
Assume you have a vector of characters x:
> x
[1] "a" "b" "a" "d" "d" "c"
I use a function that counts the number of times each string occurs in x:
> sapply(unique(x), function(s) {sum(x == s)})
a b d c
2 1 2 1
Is there a more efficient way of doing this?
Cheers,
/Ali
Hi,
when using the grid package, I've come across this weird behaviour
where a call to plot.new() will start a new page for a multi-page pdf,
but then the margins will somehow behave strangely for all but the
first page: here is some code:
pdf("test.pdf"); plot.new(); grid.rect(gp = gpar(fill="bl
ay well together. You probably want to use
> grid.newpage function instead.
>
> On Tue, Oct 9, 2012 at 1:26 PM, Ali Tofigh wrote:
>> Hi,
>>
>> when using the grid package, I've come across this weird behaviour
>> where a call to plot.new() will start a new pag
On Wed, Oct 17, 2012 at 4:08 PM, ilai wrote:
> On Wed, Oct 17, 2012 at 11:10 AM, Ali Tofigh wrote:
>>
>> my problem is that I usually have no choice but to mix grid and base
>> graphics.
>
> What does that have to do with the answer you got ? did you even try it ?
&g
What is the best way to detect whether or not a (potentially large)
matrix contains missing values (NAs) or not? I use
if (sum(is.na(x)) > 0) {...}
are there more efficient ways?
/Ali
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/l
t; On Oct 20, 2010, at 18:53, Ali Tofigh wrote:
>
>> What is the best way to detect whether or not a (potentially large)
>> matrix contains missing values (NAs) or not? I use
>>
>> if (sum(is.na(x)) > 0) {...}
>>
>> are there more efficient ways?
>>
>
Hi,
The maPalette() function (in the marray package) does not always
return the number of colors requested. More specifically, if a middle
color is given and the number of colors requested is odd, then
maPalette returns either one more or one less than the requested
number of colors:
maPalette(lo
Hi,
When I plot text and use cex to change the text size, I notice that the cex
multiplier is not exact. It looks as if the real size of text can take only
certain discrete values. Is there a workaround to get text to follow the cex
value more closely, or at least to be able to figure out what the
On Mon, Oct 24, 2011 at 06:10, Prof Brian Ripley wrote:
> On Mon, 24 Oct 2011, Uwe Ligges wrote:
>
>>
>>
>> On 23.10.2011 22:33, Ali Tofigh wrote:
>>>
>>> Hi,
>>>
>>> When I plot text and use cex to change the text size, I notice that
he predict.naiveBayes function, you currently do:
L <- exp(L)
L / sum(L) # this is what is returned
you can instead use
sapply(L, function(lp) {1 / sum(exp(L - lp))})
the above comes from the following equality:
x / (x + y + z) = 1 / (1 + exp(log(y) - log(x)) + exp(log(z) - log(x)))
This has been asked before, but I just cannot figure out why lapply
should behave this way given that R uses lazy evalution. Even after
reading (or at least trying to read) parts of the R language
definition.
> f <- function(x) {function() {x}}
> a <- list(f(1), f(2), f(3))
> a[[1]]() # as expecte
On Tue, Apr 24, 2012 at 16:57, Duncan Murdoch wrote:
>> I thought that
>> lapply calls f three times and returns a list with whatever f
>> returned. Is this not so?
>
> That is so. In each case, f creates a function that looks in its enclosing
> environment for the variable x to be returned.
>
>
4, 2012 at 18:37, Duncan Murdoch wrote:
> On 12-04-24 5:13 PM, Ali Tofigh wrote:
>>
>> On Tue, Apr 24, 2012 at 16:57, Duncan Murdoch
>> wrote:
>>>>
>>>> I thought that
>>>> lapply calls f three times and returns a list with whatever f
>&
19 matches
Mail list logo