Re: [R] 3d topographic map

2010-07-26 Thread Gene Leynes
This is an example that I have found to be very useful example, and one that I have adapted myself: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=1 On Sun, Jul 25, 2010 at 6:27 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 25, 2010, at 6:31 PM, sh...@ucar.edu wrote:

[R] Using command line --file or -f

2010-08-11 Thread Gene Leynes
*What I want to do: *Create a windows shortcut that will start the R gui **and** simultaneously source a file *What I have already tried: *This almost works, but it's not the interactive R GUI: R --no-save --sdi -file=C:\SomePath\example.R These open the R GUI, but doesn't recognize -f --f

Re: [R] Using command line --file or -f

2010-08-11 Thread Gene Leynes
without loading anything. There is probably something possible to get R files to open in R (either to edit or with a source command), but I have not found it yet. On Wed, Aug 11, 2010 at 3:37 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 11/08/2010 4:13 PM, Gene Leynes wrote: *What I want

Re: [R] change object name within for loop

2010-08-20 Thread Gene Leynes
The quick answer is to use a list. The most simple: outlist=list() for (i in 1:10){ outlist[[i]] = matrix(rnorm(100), 10, 10) } Same example, but with naming: outlist=list() for (i in 1:10){ outlist[[i]] = data.frame(loop_number=i, matrix(rnorm(100), 10, 10)) } now if you were to do

Re: [R] dimnames

2010-08-20 Thread Gene Leynes
It seems like a disastrous proposition to name anything try, because try is a key function used for error handling. Many functions use it internally, and I don't think you'd want to risk fouling up those mechanics! Even if it works, it's confusing to see that function being used as a variable

[R] Incremental ReadLines

2009-11-02 Thread Gene Leynes
I've been trying to figure out how to read in a large file for a few days now, and after extensive research I'm still not sure what to do. I have a large comma delimited text file that contains 59 fields in each record. There is also a header every 121 records This function works well for

Re: [R] Incremental ReadLines

2009-11-02 Thread Gene Leynes
and then read it in? It looks like you just want lines starting with numbers, so something like grep '^[0-9]\+' thefile.csv otherfile.csv should be much faster, and then you can just read in otherfile.csv using read.csv(). Best, Jim Gene Leynes wrote: I've been trying to figure

[R] How to pass a list of parameters into a function

2010-04-19 Thread Gene Leynes
Does anyone know how to pass a list of parameters into a function? for example: somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ ans=x1+x2+x3+x4+x5+x6+x7+x8+x9 return(ans) } somefun(1,2,3,4,5,6,7,8,9) # I would like this to work: temp=c(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)

Re: [R] How to pass a list of parameters into a function

2010-05-06 Thread Gene Leynes
, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Mon, Apr 19, 2010 at 5:58 PM, Gene Leynes gleyne...@gmail.comgleynes%...@gmail.com wrote: Does anyone know how to pass a list of parameters into a function? for example: somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ ans

Re: [R] Histogram probabilities 1 ????!!!

2009-12-02 Thread Gene Leynes
I find it useful to assign the histogram output to a variable and then manipulate it myself: For Example: x=hist(R, freq=FALSE, breaks=10) str(x) x$counts/sum(x$counts) On Wed, Dec 2, 2009 at 5:52 AM, guohao.hu...@gmail.com wrote: Y-axis in your code is ``Counts'' irrelevant to probabilities.

Re: [R] R and eclipse

2009-12-03 Thread Gene Leynes
I thought of your email when I ran across this link: http://romainfrancois.blog.free.fr/index.php?post/2009/09/02/R-capable-version-of-ant I think that you would have word your question more carefully for a longer response. Also, I use StatEt almost everyday. It works great with R. I have not

[R] apply is slower than for loop?

2010-07-09 Thread Gene Leynes
I thought the apply functions are faster than for loops, but my most recent test shows that apply actually takes a significantly longer than a for loop. Am I missing something? It doesn't matter much if I do column wise calculations rather than row wise ## Example of how apply is SLOWER than

Re: [R] apply is slower than for loop?

2010-07-09 Thread Gene Leynes
I should add that I'm using R 2.10.1 on a Windows 7 machine, thanks! On Fri, Jul 9, 2010 at 3:11 PM, Gene Leynes gleyne...@gmail.comgleynes%...@gmail.com wrote: I thought the apply functions are faster than for loops, but my most recent test shows that apply actually takes a significantly

Re: [R] apply is slower than for loop?

2010-07-10 Thread Gene Leynes
worthwhile for me to optimize, so thank you for the detailed response and for the benchmark syntax. On Sat, Jul 10, 2010 at 8:44 AM, Allan Engelhardt all...@cybaea.com wrote: On 09/07/10 21:19, Duncan Murdoch wrote: On 09/07/2010 4:11 PM, Gene Leynes wrote: I thought the apply functions

[R] Dock graphs when using R in Eclipse with StatET plug In

2010-02-17 Thread Gene Leynes
Does anyone know how to dock graphics windows in Eclipse when using the StatET plug-in for R? Right now every time I make a graph it pops up as a separate window, which takes up too much real estate. By the way, if you have not tried the StatET thing, you should. It's really nice, and I'm sure

Re: [R] plot circular histogram

2010-02-20 Thread Gene Leynes
This might give you some ideas: http://addictedtor.free.fr/graphiques/thumbs.php Some examples that jumped out at me for your application: *Circular density estimate *http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=121 *Wind rose diagram

Re: [R] productivity tools in R?

2009-07-02 Thread Gene Leynes
I have recently discovered the playwith library, which is great for creating complex lattice objects. If you start with a simple lattice plot then modify it using playwith, you can export the code to produce the spiffed up plot. I noticed this function at the bottom of the xyplot

Re: [R] productivity tools in R?

2009-07-02 Thread Gene Leynes
I have recently discovered the playwith library, which is great for creating complex lattice objects. If you start with a simple lattice plot then modify it using playwith, you can export the code to produce the spiffed up plot. I noticed this function at the bottom of the xyplot documentation in

[R] How to replace NAs in a vector of factors?

2009-07-21 Thread Gene Leynes
# Just when I thought I had the basic stuff mastered # This has been quite perplexing, thanks for any help ## Here's the example: db1=data.frame( olditems=c('soup','','','','nuts'), prices=c(4.45, 3.25, 4.42, 2.25, 3.98)) db2=data.frame(

Re: [R] list of lm() results

2009-07-21 Thread Gene Leynes
I found that it was easiest to just pull out the parts I want with an apply loop. Here I am regressing a bunch of equity returns on some index returns and just keeping the coefficients: EqCoefQ1 = apply(retEqQ1,2, function(x) summary(lm(x~retIndexQ1))$coefficients) On Tue, Jul 21, 2009

Re: [R] How to replace NAs in a vector of factors?

2009-07-22 Thread Gene Leynes
,..: 4 1 5 2 3 $ prices : num 4.45 3.25 4.42 2.25 3.98 Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gene Leynes Sent: Wednesday, 22 July 2009 10:39 AM To: r-help

Re: [R] Cross-validation - lift curve

2009-03-13 Thread Gene Leynes
This may be somewhat useful, but I might have more later. http://florence.acadiau.ca/collab/hugh_public/index.php?title=R:CheckBinFit (the code below is copied from the URL above) CheckBinFit - function(y,phat,nq=20,new=T,...) { if(is.factor(y)) y - as.double(y) y - y-mean(y) y[y0] -

Re: [R] R equivalent to MATLAB's whos Command?

2009-03-20 Thread Gene Leynes
I have found the gdata library quite helpful: library(gdata) ll() ll(dimensions=TRUE) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] constrOptim workaround for L-BFGS-B or Box Constraints

2009-03-25 Thread Gene Leynes
This is not so much a question as a contribution, but comments are welcome. Comments: 1) thank you very much to Paul Smith in the post https://stat.ethz.ch/pipermail/r-help/2008-March/157249.html This is intended to build on that example with something more complex than a 2x2 set

[R] get optim results into a model object

2009-04-07 Thread Gene Leynes
Hello all, I have an optimization routine that is giving me good results, but the results are not in the nice model format like lm. How can I get optim results into a model so that I can use the clever 'fitted', 'residuals', and 'summary' functions? Using optim is the only way that I was able to

Re: [R] Sequences

2009-04-07 Thread Gene Leynes
Not sure what you're trying to accomplish, but I think the index values are off. the first element of s is 1, not 0 Here's something that works: s-rep(0,207) s-as.vector(s) s[0]-0 lambs=rep(rnorm(207)*1000) for (i in 1:(length(lambs)-1)){ s[i]-s[i+1]-mean(lambs) } On Tue, Apr 7, 2009

Re: [R] get optim results into a model object

2009-04-07 Thread Gene Leynes
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gene Leynes Sent: Tuesday, April 07, 2009 12:17 PM To: r-help@r-project.org Subject: [R] get optim results into a model object Hello all, I have an optimization routine that is giving me good

Re: [R] Constrained, multiple response statistics

2009-04-08 Thread Gene Leynes
This sounds very similar to what I've been working on, but I'm not sure without an example. My solution has been to use an optimization that normalizes inside the objective function. The betas that are provided by optim are not normalized, however since they were normalized inside the objective

Re: [R] how to randomly eliminate half the entries in a vector?

2009-02-17 Thread Gene Leynes
This is my first help post, hope it works! Just check out the sample function At the command line type: ?sample I think it will be pretty clear from the documentation. On Tue, Feb 17, 2009 at 9:13 PM, Esmail Bonakdarian esmail...@gmail.comwrote: (sorry if this is a duplicate-problems with

Re: [R] portable R editor

2009-03-03 Thread Gene Leynes
After (too much) research, I've settled on SciTE, which is an open source editor. I really wanted emacs to work, but the crazy keyboard shortcuts were killing me. For SciTE to work, it takes a little work. First open the global options file and change #import r to import r to enable R syntax

Re: [R] Example scripts for R Manual

2009-08-11 Thread Gene Leynes
Have you tried running the examples? Eg: example(lm) On Monday, August 10, 2009, Peng Yu pengyu...@gmail.com wrote: Some examples in the manual are not in the context. In order to use such examples, the users have to set up the variables in the examples. Adding accompany scripts to the manuals

Re: [R] paste first row string onto every string in column

2009-08-13 Thread Gene Leynes
I'm also a newbie, but I've been getting loads of utility out of the grep function and it's cousin gsub. Using asterisks are tricky because * often means anything of any length in a search pattern (e.g. delete *.* means delete all your files!). To find the literal * using grep you would need to

[R] where did ggplot go?

2009-09-04 Thread Gene Leynes
This must be explained somewhere, but I've been searching for a couple of hours and not found it. What happened to ggplot? It appears to be missing on CRAN, except in the archives. http://cran.r-project.org/web/packages/ggplot/index.html Has ggplot2 replaced ggplot? I was trying to run some

[R] Tom Short's R cheat sheet

2011-07-08 Thread Gene Leynes
I noticed that there is a newer version of Tom Short's cheat sheet than the version currently posted on CRAN. Personally I like the newer version, but maybe keeping the old version is deliberate. Anyway, I was wondering if there's someone that I can notify that can update the content. New

[R] Can you save an installed library to an .RData file?

2011-07-21 Thread Gene Leynes
It occurred to me that it would be nice to be able to save a library that I have installed an loaded into my workspace for easy sharing. I suppose it might not work if someone's on a different version of R, but usually since the library is just a collection of functions, it seems plausible that

Re: [R] Can you save an installed library to an .RData file?

2011-07-21 Thread Gene Leynes
Duncan, Makes perfect sense, thank you very much. Gene On Thu, Jul 21, 2011 at 10:46 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 21/07/2011 11:37 AM, Gene Leynes wrote: It occurred to me that it would be nice to be able to save a library that I have installed an loaded into my

[R] apply is making me crazy...

2011-07-27 Thread Gene Leynes
I have tried a lot of ways around this, but I can't find a way to make apply work in a generalized way because it causes a failure whenever reduces the dimensions of its output. The following example is easier to understand than the question. I wish it had a drop=TRUE/FALSE option like the [

Re: [R] ?plot: Add an example on how to plot functions to the help of `plot`.

2011-07-27 Thread Gene Leynes
Paul, I agree completely. I didn't come at this with a programming background, and I never noticed the other plot links, or understood their importance. The plot help page was one of the first help pages I ever looked at and I remember that It was totally confusing. In fact, help pages like

Re: [R] for loop help

2011-07-27 Thread Gene Leynes
I'm not sure what you're doing... but here are some tips about the parts I can understand. 1) you don't need to use which as much. This works fine: stnID - stnid[!duplicated(stnid)] 2) which works within a for loop 3) Do you realize that stnID is shorter after you removed duplicates? I

Re: [R] apply is making me crazy...

2011-07-27 Thread Gene Leynes
LastColumn = ncol(mat) print(mat[2,LastColumn]) } On Wed, Jul 27, 2011 at 5:45 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 27, 2011, at 6:22 PM, Gene Leynes wrote: I have tried a lot of ways around this, but I can't find a way to make apply work in a generalized way

Re: [R] apply is making me crazy...

2011-07-28 Thread Gene Leynes
, the result has length 0 but not necessarily the ‘correct’ dimension.” I just wish that it had an option to do return an array of dimension c(n, dim(X)[MARGIN]) if n = 1 On Wed, Jul 27, 2011 at 8:25 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 27, 2011, at 7:44 PM, Gene Leynes wrote

Re: [R] apply is making me crazy...

2011-07-28 Thread Gene Leynes
a drop=TRUE option in apply! Thanks again, Gene On Thu, Jul 28, 2011 at 12:05 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 28, 2011, at 12:31 PM, Gene Leynes wrote: (As I mentioned in my other reply to Dennis, I think I'll stick with for loops, but I wanted to respond

Re: [R] apply is making me crazy...

2011-07-28 Thread Gene Leynes
) matrix(rnorm(10 * x), ncol = x)) csfun - function(m) { if(ncol(m) == 1L) {return(m)} else { t(as.matrix(apply(m, 1, cumsum))) } } lapply(exampGood, csfun) lapply(exampBad, csfun) HTH, Dennis On Wed, Jul 27, 2011 at 3:22 PM, Gene Leynes gleyne...@gmail.com wrote: I have tried

Re: [R] apply is making me crazy...

2011-07-28 Thread Gene Leynes
be a disaster. On Thu, Jul 28, 2011 at 2:45 PM, David Winsemius dwinsem...@comcast.netwrote: On Jul 28, 2011, at 3:13 PM, Gene Leynes wrote: Very clever (as usual)… It works, but since I wanted to switch the rows and columns, which would require this: answer.slightly.clumsy = lapply

Re: [R] Animated gif or something similar in R?

2011-07-28 Thread Gene Leynes
It seems like you have two questions, one about color rendering, and another about making animations. For the second question : I've found the animation package useful in similar situations, where I want to share results with non-R users who want a static visualization. By using animation you

Re: [R] Animated gif or something similar in R?

2011-07-29 Thread Gene Leynes
I wasn't at my normal computer yesterday, so I didn't run the example. I thought rgl was one of those color palette generator packages. So, my suggestion of using animation was completely off base (oops). But I did notice two other things: 1) your color column changes from a factor to a

Re: [R] Plotting question

2011-08-01 Thread Gene Leynes
plot(1:10, pch=letters[1:10]) On Mon, Aug 1, 2011 at 4:44 AM, Andrew McCulloch amccu...@yahoo.co.ukwrote: Hi, I use R to draw my graphs. I have 100 points on a simple xy-plot. The points are distinguished by a third variable which is categorical with 10 levels. I have been plotting x

Re: [R] General indexing in multidimensional arrays

2011-08-01 Thread Gene Leynes
What do you think about this? apply(data, 3, '[', indices) On Mon, Aug 1, 2011 at 4:38 AM, Jannis bt_jan...@yahoo.de wrote: Dear R community, I have a general question regarding indexing in multidiemensional arrays. Imagine I have a three dimensional array and I only want to extract on

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
for) and not to replace subsets with other values. I used them, however, to program a rather akward function to do that. Seems I found one of the few aspects where Matlab actually is slightly easier to use than R. Thanks for your help! Jannis On 08/01/2011 05:50 PM, Gene Leynes wrote: What do

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
for your help! Jannis On 08/01/2011 05:50 PM, Gene Leynes wrote: What do you think about this? apply(data, 3, '[', indices) On Mon, Aug 1, 2011 at 4:38 AM, Jannisbt_jan...@yahoo.de wrote: Dear R community, I have a general question regarding indexing in multidiemensional arrays

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
is slightly easier to use than R. Thanks for your help! Jannis On 08/01/2011 05:50 PM, Gene Leynes wrote: What do you think about this? apply(data, 3, '[', indices) On Mon, Aug 1, 2011 at 4:38 AM, Jannisbt_jan...@yahoo.de wrote: Dear R community, I have a general

[R] GAM Prediction

2011-08-10 Thread Gene Leynes
I'm looking for the best way to do the following: run a set of GAM models, and then make predictions with new data. My problem is the size of the gam model object, I would like to strip it down to the bare minimum of information needed to apply the model to new data. For example, if this

Re: [R] File Save As...

2011-03-16 Thread Gene Leynes
it as a file in base)... And there's probably not much benefit for me to know more beyond that. So, I'll be looking forward to 2.13! On Tue, Mar 15, 2011 at 3:37 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 15/03/2011 2:56 PM, Gene Leynes wrote: The getSrcFilename function

Re: [R] File Save As...

2011-04-13 Thread Gene Leynes
, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 13/04/2011 5:20 PM, Gene Leynes wrote: as of right now x = function(a) print(a) attr(x, srcref) returns NULL in 2.13, am I doing something wrong? There's a limitation to the debug information: it can't be attached to a function whose

Re: [R] File Save As...

2011-04-14 Thread Gene Leynes
2.13.0 RC (2011-04-11 r55409) On Wed, Mar 16, 2011 at 2:44 PM, Gene Leynes gleyne...@gmail.com wrote: Thanks for showing me the link to the code / your response / your work in general. It seems that the real magic is happening in the call to the function attributes, via the line attr(x

[R] having trouble with R CMD INSTALL

2011-04-18 Thread Gene Leynes
Hello, I was having trouble passing in command line options when doing an package install earlier. From An Introduction in R In addition, you can use25http://cran.r-project.org/doc/manuals/R-intro.html#fn-25options --arch=, --no-environ, --no-init-file, --no-site-file and --vanillabetween

Re: [R] Way OT: Anyone know where to get data on relationship between education and salary

2011-04-19 Thread Gene Leynes
This is an amazing website which would definitely have what you want, probably in many ways. *http://www.gapminder.org/* There are a wealth of data sources, and the GUI is very intuitive and interesting. I encourage you to view a few samples to get an idea of what you can do with the

Re: [R] having trouble with R CMD INSTALL

2011-05-03 Thread Gene Leynes
are talking about? Perhaps you can make it available for further inspection of this problem? Uwe Ligges On 19.04.2011 01:55, Gene Leynes wrote: Hello, I was having trouble passing in command line options when doing an package install earlier. From An Introduction in R In addition, you

[R] Using $ accessor in GAM formula

2011-05-05 Thread Gene Leynes
This is not mission critical, but it's bothering me. I'm getting inconsistent results when I use the $ accessor in the gam formula *In window #1:* library(mgcv) dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05)) str(dat) gam(dat$y~s(dat$x)) Error in eval(expr, envir, enclos) : object

Re: [R] Using $ accessor in GAM formula

2011-05-06 Thread Gene Leynes
Hmmm After reading that email four times, I think I see what you mean. Checking for variables within particular scopes is probably one of the most challenging things in R, and I would guess in other languages too. In R it's compounded by situations when you're writing a function to accept

[R] replacing elements of a zoo object

2011-08-29 Thread Gene Leynes
Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML

Re: [R] replacing elements of a zoo object

2011-08-29 Thread Gene Leynes
[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent Thank you for any insight On Mon, Aug 29, 2011 at 1:53 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 29, 2011, at 2:45 PM, Gene Leynes wrote: Why doesn't this work

Re: [R] replacing elements of a zoo object

2011-08-29 Thread Gene Leynes
I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011

Re: [R] replacing elements of a zoo object

2011-08-29 Thread Gene Leynes
correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause

Re: [R] replacing elements of a zoo object

2011-08-29 Thread Gene Leynes
(although I don't get the warning zoo was built under R 13.1 warning when I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I

[R] Possible to access a USB volume by name in windows

2011-09-06 Thread Gene Leynes
On the Mac it's pretty easy to get to a USB drive by name. For example the following command works if you have a USB drive named MYUSB setwd('/Volumes/MYUSB') Is there a way to do the same thing in Windows (without knowing the drive letter)? Thanks! [[alternative HTML version

Re: [R] heatmap

2011-09-06 Thread Gene Leynes
I wrote this function (borrowing heavily from an example from Longhow Lam) heatplot = function(x,y,z,bgcol=#777044,coltype='heat', ccex = 1.5, circles=TRUE, ...){ #browser() layout(matrix(c(1, 2, 3), nc=3), widths=c(7, 1, .5)) ## create the scatterplot withdifferent colors

Re: [R] Possible to access a USB volume by name in windows

2011-09-07 Thread Gene Leynes
, but the warnings (at least about not finding drives/bad exit status) should be ignorable. Cheers, Josh On Tue, Sep 6, 2011 at 2:56 PM, Gene Leynes gleyne...@gmail.com wrote: On the Mac it's pretty easy to get to a USB drive by name. For example the following command works if you have a USB

Re: [R] Can't load workspaces

2011-09-08 Thread Gene Leynes
Are you doing something in your profile.site file or loading a package that masks load? It seems that you're deparsing (or parsing, I can never remember which is which) the literal results of the load function. Does it work if you do this? save(a, file='a.RData') On Thu, Sep 8, 2011 at 12:24

Re: [R] Searching the console

2011-09-08 Thread Gene Leynes
searchhist = function(pattern){ histfile = tempfile() savehistory(histfile) myHist = readLines(file(histfile)) ret = myHist[grep(pattern, myHist)] return(ret) } searchhist('data') searchhist('^lm') searchhist('hist') On Thu, Sep 8, 2011 at 12:03 AM, andrewH

[R] Invisible doesn't exit function?

2011-09-19 Thread Gene Leynes
I thought that invisible works like return() However, it appears that it doesn't exit a function. Is it supposed to work this way? funInvisible = function(){ invisible(10) cat('I was not expecting this to print\n') cat('because it occurs after the invisible return\n') }

[R] Testing for arguments in a function

2011-09-26 Thread Gene Leynes
I don't understand how this function can subset by i when i is missing ## My function: myfun = function(vec, i){ ret = vec[i] ret } ## My data: i = 10 vec = 1:100 ## Expected input and behavior: myfun(vec, i) ## Missing an argument, but error is not caught! ## How is subsetting

Re: [R] Testing for arguments in a function

2011-09-26 Thread Gene Leynes
Alan and Duncan, or test them explicitly with missing(). If you want to do this automatically, then you shouldn't be using substrings and deparse, you should work at the language level. But I don't see the reason you want to do this... Absolutely. That wasn't the way I wanted to do it,

Re: [R] Testing for arguments in a function

2011-09-26 Thread Gene Leynes
, 2011 at 4:33 PM, Gene Leynes gley...@gmail.com wrote: Alan and Duncan, or test them explicitly with missing(). If you want to do this automatically, then you shouldn't be using substrings and deparse, you should work at the language level. But I don't see the reason you want to do

[R] Require

2011-01-12 Thread Gene Leynes
I think that the quietly argument in require isn't working require('JumboShrimp', quietly=TRUE) Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called 'JumboShrimp' By the way, the behavior is the same with options(warn=0)

Re: [R] R not recognized in command line

2011-01-12 Thread Gene Leynes
Although it could easily be user error, I never got Rpy or Rpy2 working an any sort of reliable way. However I did learn a couple of things about the Windows PATH First, (as others have mentioned) it's easiest to modify the PATH through the Windows GUI that comes up when you right click My

Re: [R] Require

2011-01-12 Thread Gene Leynes
. By the way, I wanted to suppress the confusing message generated by R, and put in a simple recommendation that the user should try installing the package. 2011/1/12 Uwe Ligges lig...@statistik.tu-dortmund.de On 12.01.2011 18:53, Gene Leynes wrote: I think that the quietly argument in require

Re: [R] How to disable using enter key to exit the browser in debugging mode

2011-01-12 Thread Gene Leynes
That also drives me crazy! I don't have that problem when I use the StatEt plug-in for Eclipse. Of course, using a new IDE is a big undertaking, but I can assure you: it's worth it! This is just one small benefit. On Wed, Jan 12, 2011 at 4:00 PM, Feng Li m...@feng.li wrote: Dear R, How can

Re: [R] aggredating date data

2011-01-12 Thread Gene Leynes
I like the zoo package, and there are several helpful examples. library(zoo) You can easily convert your data into a zoo object using I was actually just doing this using this function: LoadReturnData=function(x){ ret = read.csv(x) ret = zoo(ret[ , -1], as.Date(ret[ , 1]))

[R] PBSmodelling: Change the edit option of a widget

2011-01-13 Thread Gene Leynes
Is it possible to toggle the edit option of a widget? I would like to make it so that when a user clicks on a boolean (like use constraints) it will lock or unlock the field in which they would enter the constraints. I can imagine redrawing the whole GUI using a function attached to the boolean,

Re: [R] PBSmodelling: Change the edit option of a widget

2011-01-13 Thread Gene Leynes
For the benefit of others searching the help: I think you can change the state of widgets by using setWidgetState see ?setWidgetState in package:PBSmodelling -- Forwarded message -- From: Gene Leynes gleyne...@gmail.com gleynes%...@gmail.com Date: Thu, Jan 13, 2011 at 4:30 PM

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
I wish I had a better answer. There are two things that I know of that use a direct approach: The segmentation package seems to work well if you are doing a few fits, but I had problems when I tried running it on loads of data. It's a bit tricky to parametrize. When I tried investigating the

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
oh yes, and the structchange package. After a day of experimentation I couldn't figure out how to get the structchange package to work for my problems. Although it is probably user error on my part, the package seems to be specific to time series problems. Also, I think it needed regularly

Re: [R] How to disable using enter key to exit the browser in debugging mode

2011-01-15 Thread Gene Leynes
Regarding the issue of inserting a newline during debugging: If I remember correctly, this issue didn't happen in older versions of R. and it seems connected to some other issues. There generally seems to be something different with how the R Console is being rendered, and it doesn't seem to be

Re: [R] get list element names within lapply / sapply call

2011-01-15 Thread Gene Leynes
I one tried to write a function to do that, but it wasn't worth it / didn't work I found this to be a better solution: mynames = names(sapply(mylist, names)) for(nm in mynames){ print(mylist[nm]) # or do other stuff } You can use browser to look inside sapply, and the objects available

[R] ggplot - controlling point size

2011-01-25 Thread Gene Leynes
Can anyone illuminate the following for me? How can I get rid of the blue line in the key in the second plot? ## Create a simple data frame df=data.frame(x=1:1000, y=2*1:1000+rnorm(1000,sd=1000), type=sample(letters[1:2],1000, replace=TRUE)) ## Very nice! Almost what I want qplot(x, y,

Re: [R] ggplot - controlling point size

2011-01-25 Thread Gene Leynes
Thank you both, very much. Using the identity function I() is a very nice trick, but it still feels like a trick. Using ggplot makes the most sense to me. ggplot(df, aes(x=x, y=y, colour=factor(type))) + geom_point(size=1) + geom_smooth() Thank you very much for taking the time to

Re: [R] replace double backslash with singel backslash

2011-11-04 Thread Gene Leynes
I think that people are afraid to say You can't do that in R... But I think the real answer is: you can't do that in R. Although, it is helpful to understand Jeff's reply. I hadn't fully realized why this particular problem occurs before reading that. It's odd to me that // and / are both

[R] R Startup options (MDI and SDI)

2011-11-11 Thread Gene Leynes
Here's my setup: - I'm on a Windows machine (I don't have full admin rights) - I have a folder with an *.RData file and an .RProfile file - I want the user to be able to start R by double clicking on the *.RData file Can I specify the application start up options (like --no-save

Re: [R] Upgrade R?

2011-11-14 Thread Gene Leynes
I have had similar problems. I have several installations of R and now I have no control over which one opens when I try opening a RData file. The RGUI is registered more than once, but they all have the exact same appearance in the choose programs menu. It's become particularly annoying now

Re: [R] To Try or to TryCatch, I have tried to long

2011-12-06 Thread Gene Leynes
I think the problem is that it's only a warning and not an error. result_-list() for(i in 1:10){ if(inherits(try(sqrt(9-i),silent=TRUE),try-error)){ #If sqrt fails cat('fail',i,'\n') result_[[i]]-0 } else { #If sqrt succeeds cat('succeed',i,'\n') result_[[i]] -

[R] read.table performance

2011-12-06 Thread Gene Leynes
** Disclaimer: I'm looking for general suggestions ** I'm sorry, but can't send out the file I'm using, so there is no reproducible example. I'm using read.table and it's taking over 30 seconds to read a tiny file. The strange thing is that it takes roughly the same amount of time if the file is

Re: [R] To Try or to TryCatch, I have tried to long

2011-12-06 Thread Gene Leynes
OR an error pop up? Any ideas? Cheers -- *From:* gley...@gmail.com [mailto:gley...@gmail.com] *On Behalf Of *Gene Leynes *Sent:* Tuesday, December 06, 2011 10:27 AM *To:* ROLL Josh F *Cc:* r-help@r-project.org *Subject:* Re: [R] To Try or to TryCatch, I have tried

Re: [R] read.table performance

2011-12-06 Thread Gene Leynes
)). hopefully someone else will say something that does the trick. it seems odd to me as far as the difference in timings ? good luck. On Tue, Dec 6, 2011 at 1:55 PM, Gene Leynes gley...@gmail.com wrote: Mark, Thank you for the reply I neglected to mention that I had already set options

[R] RSPython installation

2011-12-07 Thread Gene Leynes
Does anyone know if Is there a way to manually install RSPython? I get this error when I try to run the script from my DOS prompt. V:\R CMD INSTALL -c C:/Users/gene.leynes/Downloads/RSPython_0.7-1.tar.gz * installing to library 'C:/Users/gene.leynes/Documents/R/win-library/2.13' * installing

Re: [R] curve fitted ... how to retreive data

2011-12-07 Thread Gene Leynes
For the components: result = predict(b, type=terms) For the total fit: result = predict(b) result = b$fitted.values On Wed, Dec 7, 2011 at 3:24 AM, Mintewab Bezabih mintewab.beza...@economics.gu.se wrote: Dear R users, I have now managed to fit the curve using the thin plate spline as

Re: [R] select integer intervals from a integer space

2011-12-07 Thread Gene Leynes
Possibly not the absolutely most efficient answer, but this is probably an answer nonetheless (David, hope I'm not encouraging bad behavior by replying.) isp - data.frame(begin=c(1,5,6,15,31,51,102), end=c(7,9,13,21,49,52,109)) isp ints = apply(isp, 1, function(x)seq(x[1],x[2])) ints ints =

Re: [R] RSPython installation

2011-12-07 Thread Gene Leynes
, 2011 at 11:28 AM, Gene Leynes gleyne...@gmail.com wrote: Does anyone know if Is there a way to manually install RSPython? I get this error when I try to run the script from my DOS prompt. V:\R CMD INSTALL -c C:/Users/gene.leynes/Downloads/RSPython_0.7-1.tar.gz * installing to library 'C

Re: [R] read.table performance

2011-12-07 Thread Gene Leynes
in a heavily virus-scanned system directory? -pd Michael 2011/12/7 Gene Leynes gley...@gmail.com: Peter, You're quite right; it's nearly impossible to make progress without a working example. I created an ** extremely simplified ** example for distribution. The real data has numeric

Re: [R] read.table performance

2011-12-08 Thread Gene Leynes
R. Michael Weylandt michael.weyla...@gmail.com Kopie r-help@r-project.org, Gene Leynes gley...@gmail.com P?edm?t Re: [R] read.table performance On Dec 7, 2011, at 22:37 , R. Michael Weylandt wrote: R 2.13.2 on Mac OS X 10.5.8 takes about 1.8s to read the file verbatim

  1   2   >