Re: [R] Could "incomplete final line found" be more serious than a warning?

2012-05-22 Thread Zhou Fang
If you look at the new file in raw mode, you'll see that it's chock full of ASCII nuls, while the old file has none. This is probably what's giving you the problems, because R does not allow strings containing embedded nul characters. (I believe this is because Nul in strings is pretty dangerous in

Re: [R] “For” calculation is so slow

2012-05-22 Thread Zhou Fang
I'm not sure what you are trying to prove with that example - the loopless versions are massively faster, no? I don't disagree that loops are sometimes unavoidable, and I suppose sometimes loops can be faster when the non-loop version e.g. breaks your memory budget, or performs tons of needless co

Re: [R] “For” calculation is so slow

2012-05-22 Thread Zhou Fang
For loops are really, really slow in R. In general, you want to avoid them like the plague. If you absolutely must insist on using them in large, computationally intense and complex code, consider implementing the relevant parts in C, say, and calling that from R. Staying within R, you can probabl

Re: [R] Remove a number from a vector

2012-05-11 Thread Zhou Fang
Better yet, remove the which altogether, and it'll run a slight bit faster and maybe look a little neater. x <- x[x!="bobo"] -- View this message in context: http://r.789695.n4.nabble.com/Remove-a-number-from-a-vector-tp851865p4626413.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] registry vulnerabilities in R

2012-05-10 Thread Zhou Fang
What about using a Portable Apps style packaging of R? That might solve some of the issues. -- View this message in context: http://r.789695.n4.nabble.com/registry-vulnerabilities-in-R-tp4619217p4623388.html Sent from the R help mailing list archive at Nabble.com. ___

[R] Seek() on windows - safe use cases?

2012-05-08 Thread Zhou Fang
So, I'm maintaining some else's code, which is as always, a fun thing. One feature of this code is the use of the 'seek' command. In ?seek: We have found so many errors in the Windows implementation of file positioning that users are advised to use it only at their own risk, and

Re: [R] What is the most cost effective hardware for R?

2012-05-08 Thread Zhou Fang
How many data points do you have? -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-most-cost-effective-hardware-for-R-tp4617155p4617187.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mail

[R] Binary operators in packages and documentation?

2009-11-25 Thread Zhou Fang
the NAMESPACE file, right? The question I was wondering was what the appropriate way to document this operator is. i.e. What should I put in the \usage section, etc? 'Writing R Extensions' doesn't seem to see much about this, but maybe I'm m

Re: [R] Replace is leaking?

2009-05-27 Thread Zhou Fang
Oh hang on, I've figured it out. Rounding error, doh. Somewhere along the line I got lazy and took the weighted average of two values that are equal. as.integer truncates, so, yeah. Never mind. Zhou Fang __ R-help@r-project.org mailing list

[R] Replace is leaking?

2009-05-27 Thread Zhou Fang
ested in a R workspace to reproduce this, email me. This is running in R 2.9. Zhou Fang __ R-help@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 provi

[R] Scaled MPSE as a test for regressors?

2009-03-23 Thread Zhou Fang
to me. You get a number between zero and one out of it, with 1 the solution for constant fits. Anyone seen anything like this, or know anything about properties? Has it got a name? Zhou Fang __ R-help@r-project.org mailing list https://stat.ethz.

[R] Bias correction for random forests?

2009-03-11 Thread Zhou Fang
n' actually does? Or what the justification for it is? Or when it would be necessary? Is there a paper I can look at? And is the feature likely to emerge from 'experimental' any time soon? Zhou Fang __ R-help@r-project.org mailin

Re: [R] Fast ave for sorted data?

2009-02-15 Thread Zhou Fang
Thanks! That does exactly what I want. (Heck, maybe this should be included as a default sorted alternative to ave.) I was thinking of doing it another way using cumsums, but maybe this method is faster. Zhou __ R-help@r-project.org mailing list https:

[R] Fast ave for sorted data?

2009-02-15 Thread Zhou Fang
very slow, and certainly not suited to my problem, where Y changes and X stays the same and I need to repeatedly recalculate the averaging of Y. Ave also does not take take advantage of the sorting of the data. So, is there an alternative? (Presumeably avoiding loops.) Thanks,

Re: [R] Finding a basis in a set of vectors

2009-02-06 Thread Zhou Fang
Ah ha, that does work. What do you mean it isn't robust, though? I mean, obviously linear dependency structures in general are not stable under small perturbations...? Or is it that it's platform dependent? Zhou On Fri, Feb 6, 2009 at 2:28 PM, Peter Dalgaard wrote: > Zhou Fang

[R] Finding a basis in a set of vectors

2009-02-06 Thread Zhou Fang
have the QR decomposition of the original X 'for free'. I know that it's possible to do this directly by looping over the columns and adding them, but at the very least, a solution without horrible slow loops would be nice. Any ideas welc

Re: [R] for/if loop

2009-01-28 Thread Zhou Fang
What are you trying to do with > for (pp in 1:pp+1){ ? Also, note that 1:rr+1 and 1:(rr+1) mean different things. Zhou __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-proj

Re: [R] How to compare two regression line slopes

2009-01-27 Thread Zhou Fang
raphs. The downside is that you might get lured into complacency... Zhou Fang PS: Your model equation isn't right. In both, we are also allowing the intercept to vary between groups. So really you want y = c + D.b0 + b1.x + D.b2.x __ R-help@r-proj

Re: [R] How to compare two regression line slopes

2009-01-27 Thread Zhou Fang
raphs. The downside is that you might get lured into complacency... Zhou Fang PS: Your model equation isn't right. In both, we are also allowing the intercept to vary between groups. So really you want y = c + D.b0 + b1.x + D.b2.x __ R-help@r-proj

[R] Pausing processing into an interactive session

2009-01-26 Thread Zhou Fang
Hi all, As a possibly silly request, is it possible to interactively pause a R-calculation and do a browser(), say, without browser or other debug handlers being explicitly included in the code? Imagine the following situation: You write up a big calculation for R to calculate. We are talking ho

Re: [R] Loading workspaces from the command line

2009-01-12 Thread Zhou Fang
t you wish to work on and start R normally. > No code is needed. > > On Mon, Jan 12, 2009 at 10:04 AM, Zhou Fang wrote: >> Ok, looks like I can do what I want with --args, commandArgs() and an >> appropiate .First. >> >> Thanks, >> >> Zhou >> >

Re: [R] Loading workspaces from the command line

2009-01-12 Thread Zhou Fang
; > -- David Winsemius > > On Jan 12, 2009, at 7:24 AM, Zhou Fang wrote: > >> That's not really what I meant by 'command line'. I meant, well, >> loading from e.g. a bash shell, not from within an interactive R >> session itself. >> >>

Re: [R] Loading workspaces from the command line

2009-01-12 Thread Zhou Fang
te: > See ?load > > On Mon, Jan 12, 2009 at 10:12 AM, Zhou Fang wrote: >> >> Hi, >> >> Is there any way to load workspaces (e.g. stuff from save.image) from >> the command line? I'm on Linux, and would find this very helpful. >> >> I'm gue

[R] Loading workspaces from the command line

2009-01-12 Thread Zhou Fang
ates), but I'm wondering if there's a better way. Zhou Fang __ R-help@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 comm

[R] Inserting blank lines into a file

2008-10-22 Thread Zhou Fang
Hi, Should be a quickie: I want to make a datafile in R for plotting in gnuplot (which has friendlier 3D plotting options, as far as I can tell). So, I want to create a file with contents along the lines of #File begins 0 0 10 0 13 10 0.2 2 10 1 0 10.12 1 1 5 1 2 10 2 0 10 2 1 1 2 2 10 It's p