Henrik Bengtsson | 1 Jun 2009 01:32
Picon

Re: IP-Address

Not really, just the old saying that any piece of code can be made
twice as fast (which often holds true recursively). /Henrik

On Sun, May 31, 2009 at 1:58 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk <at> idi.ntnu.no> wrote:
> wow! :)
>
> vQ
>
> Henrik Bengtsson wrote:
>> library(gsubfn)
>> library(gtools)
>> library(rbenchmark)
>>
>> n <- 10000
>> df <- data.frame(
>>   a = rnorm(n),
>>   b = rnorm(n),
>>   c = rnorm(n),
>>   ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
>> )
>>
>> res <- benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL,
>>   peda = {
>>     connection <- textConnection(as.character(df$ip))
>>     o <- do.call(order, read.table(connection, sep='.'))
>>     close(connection)
>>     df[o, ]
>>   },
>>
(Continue reading)

Juliet Hannah | 1 Jun 2009 01:37
Picon

Re: How to set a filter during reading tables

There are several things you can tell read.table to make it faster.

First, as mentioned, setting colClasses helps. I think telling read.table how
many rows and columns there are also helps.

When this was not sufficient,  I've had to do the data processing
using Python, Perl, or awk.

If that had not been convenient I would have tried the sqldf solution that was
mentioned.

That covers all the options I'm familiar with. I'm also curious about other ways
to selectively read in rows in R. Let me know what ends up working.

On Sun, May 31, 2009 at 2:17 PM,  <guox <at> ucalgary.ca> wrote:
> Since there are many rows, using read.table we spent too much on reading
> in rows that we do not want. We are wondering if there is a way to read
> only rows that we are interested in. Thanks,
>
> -james
>> I think you can use readLines(n=1) in loop to skip unwanted rows.
>>
>> On Mon, Jun 1, 2009 at 12:56 AM,  <guox <at> ucalgary.ca> wrote:
>>> Thanks, Juliet.
>>> It works for filtering columns.
>>> I am also wondering if there is a way to filter rows.
>>> Thanks again.
>>> -james
>>>
>>>> One can use colClasses to set which columns get read in. For the
(Continue reading)

David Winsemius | 1 Jun 2009 01:48
Picon

Re: 'options=utils::recover' not working in .Rprofile or within R


On May 31, 2009, at 12:22 AM, Duncan Murdoch wrote:

> David Winsemius wrote:
>> You are wiping out all of the default options with that approach.
>>
>>
> Actually, I think it hid the options() function.

Since I was doing this at the RGui and became concerned that it  
appeared I no longer had any options, I restarted.  Could I have saved  
time by just executing rm(options)?

>
>> Try (after restarting R to get the other options back to what they   
>> should be):
>>
>> op=options()                   # so you can reset back to baseline
>> options(error=utils::recover)  # do not think the "utils::" is needed
>>
>
> Not if you run it in the console, but it is needed in .Rprofile.

Because it might be executed before the loading of the default packages?

--

-- 
David
>  Saving the old option could be done as
>
> olderror <- options(error=utils::recover)
(Continue reading)

Stavros Macrakis | 1 Jun 2009 03:20
Picon
Favicon
Gravatar

Re: Error:non-numeric argument in my function

On Sun, May 31, 2009 at 6:10 PM, jim holtman <jholtman <at> gmail.com> wrote:

> Message is very clear:
>
> > 1 * 'a'
> Error in 1 * "a" : non-numeric argument to binary operator

Though the user should have been able to figure this out, perhaps the error
message could be improved? After all, it is not the fact that the operator
is *binary* that implies that its argument must be numeric, but that it is
*arithmetic*. The binary operator %in%, for example, takes non-numeric
arguments.

Suggested replacement error message:

     non-numeric argument to arithmetic operator

               -s

	[[alternative HTML version deleted]]

Grześ | 1 Jun 2009 01:05
Picon

Re: Error:non-numeric argument in my function


Thanks jholtman!
But I'm not sure what and where I should change my code... :(
wekt_n = ndf[i,]
wekt_n_ok = wekt_n[!is.na(wekt_n)]
If before this line I should change "wekt_n_ok"  as numeric? but if I wrote 
as.numeric(wekt_n_ok) it's also not correct  

and  I also don't understand why "wekt_n_ok" is not numeric?

--

-- 
View this message in context: http://www.nabble.com/Error%3Anon-numeric-argument-in-my-function-tp23807218p23807873.html
Sent from the R help mailing list archive at Nabble.com.

Gabor Grothendieck | 1 Jun 2009 04:38
Picon

Re: grid.edit() for ggplot2

If you enter the code in this post first:
https://stat.ethz.ch/pipermail/r-help/2009-May/198791.html

then this post shows an example of how to do it with lattice:
https://stat.ethz.ch/pipermail/r-help/2009-May/199146.html

but I think there is a bug in grid since similar code does
not seem to work with your example of grid graphics
generated by ggplot2.

On Sun, May 31, 2009 at 9:01 AM, baptiste auguie <ba208 <at> exeter.ac.uk> wrote:
> Dear all,
>
>
> I'm trying to access and modify grobs in a ggplot2 plot. The basic idea for
> raw Grid objects I understand from Paul Murrell's R graphics book, or this
> page of examples,
>
> http://www.stat.auckland.ac.nz/~paul/grid/copygrob/copygrobs.R
>
> However I can't figure out how to apply this to a ggplot (basically I don't
> know how to write a syntactically correct gPath),
>
>
> p <- # minimal example
> qplot(0,0)+ annotate("text",0,0,label="test")
>
> g <- # store the plot as a grob
> ggplotGrob(p)
>
(Continue reading)

jim holtman | 1 Jun 2009 04:45
Picon

Re: Error:non-numeric argument in my function

What you need to do is to see that is in 'wekt_n_ok' at that point in your
program.  You should be able to see it with str(wekt_n_ok) when the error
occurs.  You can also add a print statement in the loop to print out the
value before it is used with the binary operator.

It would help if you provided 'str' of the various objects you are using, or
maybe some reproducible code.  Somehow you are creating a non-numeric value
in your code; you need to debug it and check all the values before you use
them.

On Sun, May 31, 2009 at 7:05 PM, Grze¶ <gregorio99 <at> gmail.com> wrote:

>
> Thanks jholtman!
> But I'm not sure what and where I should change my code... :(
> wekt_n = ndf[i,]
> wekt_n_ok = wekt_n[!is.na(wekt_n)]
> If before this line I should change "wekt_n_ok"  as numeric? but if I wrote
> as.numeric(wekt_n_ok) it's also not correct
>
> and  I also don't understand why "wekt_n_ok" is not numeric?
>
> --
> View this message in context:
> http://www.nabble.com/Error%3Anon-numeric-argument-in-my-function-tp23807218p23807873.html
>  Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help <at> r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
(Continue reading)

Roslina Zakaria | 1 Jun 2009 05:04
Picon
Favicon

(no subject)

Hi R-users,

I try to use sn package but it give me the following message:

> install.packages(repos=NULL,pkgs="c:\\Tinn-R\\sn_0.4-12.zip")
Warning: package 'sn' is in use and will not be installed
updating HTML package descriptions

I did tried a few time to save the .zip file but it give me the same error message.

Thank you so much for any help given.

      
	[[alternative HTML version deleted]]

Ronggui Huang | 1 Jun 2009 05:42
Picon

Re: (no subject)

use _search()_ to see if the package is on the search path. If yes,
use _detach("package:sn",unload=TRUE)_ to detach it and then try to
install it again.

Ronggui

2009/6/1 Roslina Zakaria <zroslina <at> yahoo.com>:
> Hi R-users,
>
> I try to use sn package but it give me the following message:
>
>> install.packages(repos=NULL,pkgs="c:\\Tinn-R\\sn_0.4-12.zip")
> Warning: package 'sn' is in use and will not be installed
> updating HTML package descriptions
>
> I did tried a few time to save the .zip file but it give me the same error message.
>
> Thank you so much for any help given.
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help <at> r-project.org mailing list
> 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.
>

(Continue reading)

Mark Kimpel | 1 Jun 2009 07:26
Picon

Re: 'options=utils::recover' not working in .Rprofile or within R

options(error=utils::recover)

Does indeed work, at least with the new install of R-devel (to be 2.10.0)
that I am running right now. I was sure I checked this with 2.9.0 last
night, but I am probably mistaken.

One point, the ?options help page is misleading in that the example is "
Note that these need to
          specified as e.g. 'options=utils::recover' in startup files
          such as '.Rprofile'."

Since the use of "utils::" is a new requirement, I think stemming from when
utils is loaded, this help page should be corrected as the example is
confusing/incorrect.

So, stick with what is in the first line above and, for now, ignore the help
page.

Mark
------------------------------------------------------------
Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 399-1219  Home
Skype:  mkimpel

"The real problem is not whether machines think but whether men do." -- B.
(Continue reading)


Gmane