Re: [R] How do I extract single entries from a factor?

2014-11-22 Thread peter dalgaard
On 22 Nov 2014, at 08:12 , Aditya Singh aps...@yahoo.com wrote: Dear Boris and R-Experts, I have a variable my_state which is a 2-letter character string telling which American state the user inputs. This I am do a if(identical(database entry,my_state)) to check for occurrences in the

[R] Generate random numbers under constrain

2014-11-22 Thread Ragia Ibrahim
Dear all, I use R 3.1.1 for Windows. kindly how can I generate n number of random numbers with probability from [0,1] and their sum must not be more than one thanks in advance Ragia [[alternative HTML version deleted]]

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Bert Gunter
Well, if their sum must be 1 they ain't random... But anyway... given n randnums - function(n) { Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Sat, Nov 22,

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Bert Gunter
(Hit send key by accident before I was finished ...) Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Sat, Nov 22, 2014 at 7:14 AM, Bert Gunter bgun...@gene.com

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Boris Steipe
These are contradictory requirements: either you have n random numbers from the interval [0,1), then you can't guarantee anything about their sum except that it will be in [0,n). Or you constrain the sum, then your random numbers cannot be random in [0,1). You could possibly scale the random

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Ranjan Maitra
I don't understand this discussion at all. n random numbers constrained to have sum =1 are still random. They are not all independent. That said, the original poster's question is ill=formed since there can be multiple distributions these random numbers come from. best wishes, Ranjan On

Re: [R] Generate random numbers under constrain

2014-11-22 Thread Boris Steipe
Of course they are random. But they can't all be randomly picked from [0,1). By scaling them, one is effectively scaling the interval from which they are picked. B. Nb: the scaling procedure will work for any probability distribution. On Nov 22, 2014, at 10:54 AM, Ranjan Maitra

Re: [R] Bootstrap CIs for weighted means of paired differences

2014-11-22 Thread i.petzev
On 21 Nov 2014, at 19:18, David Winsemius dwinsem...@comcast.net wrote: On Nov 21, 2014, at 6:52 AM, ivan wrote: I am aware of the fact that bootstrapping produces different CIs with every run. I still believe that there is a difference between both types of procedures. My

Re: [R] Bootstrap CIs for weighted means of paired differences

2014-11-22 Thread i.petzev
Ok, thanks for the suggestions. I will look into that. And you are absolutely right that I should have been more clear about what type of weighting I want. So to clarify: I run time series regressions of returns of company i on two different sets of explanatory variables. Then I extract the

Re: [R] Help with Time

2014-11-22 Thread Raghuraman Ramachandran
Hi Boris/ David Many thanks for the kind assistance. I will try following your codes. Time has always been a slippery subject to me! Cheers On Sat, Nov 22, 2014 at 12:59 AM, David Winsemius dwinsem...@comcast.net wrote: On Nov 21, 2014, at 3:19 PM, David Winsemius wrote: On Nov 21, 2014,

Re: [R] How do I extract single entries from a factor?

2014-11-22 Thread Chel Hee Lee
xx - as.factor(c(AL, AK, CA, FL)) xx [1] AL AK CA FL Levels: AK AL CA FL as.character(xx) [1] AL AK CA FL I hope this helps. Chel Hee Lee On 14-11-22 01:12 AM, Aditya Singh wrote: Dear Boris and R-Experts, I have a variable my_state which is a 2-letter character string telling which

Re: [R] Formula with dynamic number of variables

2014-11-22 Thread Sven E. Templer
# fixed formula part: f - dat ~ a0 * exp(-S*(x - 250)) + K # convert to character f - as.character(f) # component: C - (p0*exp(-0.5*((x-p1)/p2)^2)) # number of components (defined randomly): n - sample(1:3, 1) C - rep(C, n) # collapse: C - paste(C, collapse = +) # combine f - paste(f[2], f[1],

Re: [R] Generate random numbers under constrain

2014-11-22 Thread David Winsemius
In the 2 and 3 vector case it is possible do define a fairly simple sampling space where this is possible. Consider the unit square where the sample space is the area where x+y 1. It generalizes to 3 dimensions with no difficulty. x= (0:100)/100 y= (0:100)/100 z=outer(x,y, function(x,y)

[R-es] Problemas con tm

2014-11-22 Thread juan(uned)
Estimados compañeros tengo un problema con la librería tm o con windows 8.1 o con algo que no controlo. Hace tiempo con windows 7 y una versión anterior de R ejecutaba este código: library(tm) data(crude) crude - tm_map(crude, tolower) tdm-TermDocumentMatrix(crude) y sin problemas me creaba

Re: [R-es] Problemas con tm

2014-11-22 Thread Isidro Hidalgo Arellano
Hola, Juan: Además de lo que te indica Carlos, ¿es posible que tengas un RStudio sin actualizar a la última versión? Si no recuerdo mal, el paquete tm daba problemas en alguna versión reciente de RStudio y tenía algo que ver con algún cambio en R. Pero lo solucionaron... Yo empezaría por ahí, si

Re: [R-es] Problemas con tm

2014-11-22 Thread juan(uned)
Muchísimas gracias Carlos, como siempre tan rápido y eficaz. Efectivamente funciona incluyendo esa función, que justo en versiones anteriores no hacía falta. Saludos, Juan El 22/11/2014 a las 22:23, Carlos Ortega escribió: Hola Juan, En la ayuda de la función tm_map() (versión 0.6 del