Re: [R] [PS] Switching entries in vector in by groups of two

2008-06-27 Thread Ben Fairbank
Perhaps xnew <- x[1:length(x)+c(1,-1)] will do it. Ben Fairbank -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Friday, June 27, 2008 9:11 AM To: r-help@r-project.org Subject: [PS] [R] Switching entries in vector in by gro

[R] The Green Book and its relevance to R

2008-06-20 Thread Ben Fairbank
"S programming"?), would be most recommended as the next book for one who would move beyond advanced beginner status? (Programming experience in Fortran, APL, Python, small-system assembly language, but not C). Ben Fairbank San Antonio, Texas [EMAIL PROTECTED]

[R] Can plot() be used for multiple plots?

2008-05-28 Thread Ben Fairbank
cumulative distribution to the first one. Any suggestion would be very welcome. x1 <- sort(rnorm(1000,50,10)) x2 <- sort(rnorm(1000,40,8)) plot(x1,1:length(x1)/length(x1),type="l") plot(x2,1:length(x2)/length(x2),type="l") grid(col = "black") Ben Fair

Re: [R] [PS] Re: vlookup in R

2008-03-24 Thread Ben Fairbank
Quite right, there is an optional 4th argument, and the table must be sorted ascending on the first column in Excel. Thus these functions only approximately duplicate the Excel functions (improve on them IMHO). BTW, I pasted the wrong formula in my reply; though it works, simpler is ID <- 4

Re: [R] [PS] vlookup in R

2008-03-24 Thread Ben Fairbank
Another way: If x is a two column matrix, as suggested by Henrique D., IDValue 1 7 0.000656733 2 6 0.201764789 3 1 0.671113391 4 10 -0.739727826 5 9 -1.111310154 6 5 -0.859455833 7 2 -1.408229877 8 8 0.993126295 9 3 -0.171906808 10 4 -0.140107677 And you are loo

Re: [R] [PS] rmultinomial() function

2008-03-19 Thread Ben Fairbank
Mary -- The dmultinomial function (try ?Multinomial, noting that it is an upper case M) has a "log" option, which, if set to TRUE, returns logarithms of probabilities, but that is for computing probabilities, not generating samples. Perhaps the "long" you referred to is a misprint for "log?" In

Re: [R] [PS] How to manipulate data according to groups ?

2008-03-13 Thread Ben Fairbank
Look at ?tapply, based on your description, it is what you want. Ben -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ng Stanley Sent: Thursday, March 13, 2008 9:25 AM To: r-help Subject: [PS] [R] How to manipulate data according to groups ? Hi, I have

Re: [R] [PS] Re: a more elegant way to get percentages? (now R books)

2008-03-13 Thread Ben Fairbank
Monica -- There has been a virtual population explosion of R books in recent years and we all have our favorites. You may wish to pick one oriented toward your specialty, but the absolute minimum lowest common denominator (by which I mean that it has the ground zero essential information that all

Re: [R] [PS] Generating a new matrix using rbinom and a matrix of probabilities.

2008-03-11 Thread Ben Fairbank
it rands), then do comparisons, thus, draws <- 0 + (rands < probs) Ben Fairbank -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Economics Guy Sent: Tuesday, March 11, 2008 10:16 AM To: [EMAIL PROTECTED] Subject: [PS] [R] Generating a new matrix

Re: [R] [PS] discrete variable

2008-03-02 Thread Ben Fairbank
Try table(), with the name of your vector inside the parentheses. Ben -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pete Dorothy Sent: Sunday, March 02, 2008 2:27 PM To: r-help@r-project.org Subject: [PS] [R] discrete variable Hello, I am sorry for a

Re: [R] [PS] Column sums from a data frame (without the headers)

2008-02-29 Thread Ben Fairbank
as.vector(col.Sums()) Ben -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Horn Sent: Friday, February 29, 2008 11:03 AM To: [EMAIL PROTECTED] Subject: [PS] [R] Column sums from a data frame (without the headers) Does anyone know how to get a vecto

[R] Optimization when only binary variables can be manipulated?

2008-02-29 Thread Ben Fairbank
ar not to cover this situation. Can any of the R optimization packages handle optimization when the manipulated variables are binary and numerous? With thanks for any suggestions, Ben Fairbank Technical Director Sinclair Customer Metrics [EMAIL PROTECTED] [[alternative

[R] "hist" combines two lowest categories -- is there a workaround?

2008-01-30 Thread Ben Fairbank
Version 2.5.0, Windows XP professional Ben Fairbank [[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 http://www.R-project.org/posting-g

Re: [R] [PS] Different results in calculating SD of 2 numbers

2008-01-16 Thread Ben Fairbank
And another problem, in addition to the points made by others, is that the formula for the SD gives a biased estimate (it underestimates it) of the population SD for small n when sampling from a normal distribution. When n is about twelve or so or more, the bias can usually be ignored (it is about