Re: [R] combining two distributions

2014-12-08 Thread Alaios via R-help
Hi,thanks a lot for the answer. I think that my problem is before packages. I have a large amount of different datasets and I had a random look on their histograms. I know that some of them look like the combination I have explained (exponential+pareto, exponential+gamma) but I am not sure still

Re: [R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-08 Thread Richard M. Heiberger
yes of course, and the answer is latex() in the Hmisc package. Why were you excluding it? Details follow Rich The current release of the Hmisc package has this capability on Macintosh and Linux. For Windows, you need the next release 3.14-7 which is available now at github. ## windows needs the

Re: [R] Extract random effect variances from lmer (lme4) model

2014-12-08 Thread Ista Zahn
Perhaps as.data.frame(VarCorr(pcrpred)) ? Best, Ista On Mon, Dec 8, 2014 at 4:15 PM, GMAIL wrote: > I have a mer object that has fixed and random effects (lmer). > > How do I extract the variance or standard deviation estimates for the random > and fixed effects? Here is a simplified version

[R] Extract random effect variances from lmer (lme4) model

2014-12-08 Thread GMAIL
I have a mer object that has fixed and random effects (lmer). How do I extract the variance or standard deviation estimates for the random and fixed effects? Here is a simplified version of my question: pcrpred <- lmer(PCR ~ (1|TIME) + (1|ID), data = mydataPCRlong) pcrpred This gives a long

Re: [R] Finding unique elements faster

2014-12-08 Thread Gheorghe Postelnicu
2 ideas (haven't tried them): 1. if your data is in a data frame, did you try using the by function? Seems it would do the grouping for you. 2. Since you mention the cpu cores, you could use libraries like foreach and %dopar% or mcapply. I would try 1. and see if it provides a sufficient speed-u

[R] how to label countries in a map created with mapCountryData

2014-12-08 Thread paladini
Hello, I use the following code to draw a map of Europe. The colour of the countries depends on a value called "EPI2.0" in a data frame called epidata. epimap=joinCountryData2Map(epidata,joinCode="NAME",nameCountryColumn="Country",nameJoinColumn="Country") mapCountryData(epimap, nameColumnTo

Re: [R] Scatter plot for repeated measures

2014-12-08 Thread farnoosh sheikhi
Thank you all. That was very helpful.  Farnoosh On Saturday, December 6, 2014 7:41 PM, Chel Hee Lee wrote: It seems that you would like to make a spaghetti plot (in a longitudinal data analysis).  You can use the function 'interaction.plot()'. > with(my.df, interaction.plot(TIME

[R] Printing/Generating/Outputting a Table (Not Latex)

2014-12-08 Thread Kate Ignatius
Hi, I have a simple question. I know there are plenty of packages out there that can provide code to generate a table in latex. But I was wondering whether there was one out there where I can generate a table from my data (which ever way I please) then allow me to save it as a pdf? Thanks K.

Re: [R] MLE with parameters restricted to a defined range using bbmle

2014-12-08 Thread Ben Bolker
Rolf Turner auckland.ac.nz> writes: > > > I know nothing about the bbmle package and its mle2() function, but it > is a general truth that if you need to constrain a parameter to be > positive in an optimisation procedure a simple and effective approach is > to reparameterize using exp().

[R] combining two distributions

2014-12-08 Thread Alaios via R-help
Hi all,I am having some heavy tailed data and I am trying to think of the more appropriate package for the fitting.The canonical try should be something like exponential and pareto or exponential + gamma (or gamma + gamma with different shape parameters). I am trying to have one distribution tha

Re: [R] combining two distributions

2014-12-08 Thread Spencer Graves
Have you considered "distr" and related packages? If this does not solve your problem, have you considered searching with "findFn" in the "sos" package? If that still does not produce sufficient enlightenment, please try this list again with "commented, minimal, self-contained, r

Re: [R] Finding unique elements faster

2014-12-08 Thread Stefan Evert
On 8 Dec 2014, at 21:21, apeshifter wrote: > The last relic of the afore-mentioned for-loop that goes through all the > word pairs and tries to calculate some statistics on them is the following > line of code: >> typefreq.after1[i]<-length(unique(word2[which(word1==word1[i])])) > (where word1 a

Re: [R] Merging two data.frames

2014-12-08 Thread William Dunlap
Have you looked at the merge() function? Here is an example. I don't know if it resembles your problem. > M1 <- data.frame(V1=letters[1:3], V2=LETTERS[26:24], N1=101:103) > M2 <- data.frame(V1=letters[c(3,1,2,3,2)], V2=LETTERS[c(23,26,22,24,24)], N2=c(1003,1001,1002,1003,1002)) > merge(M

Re: [R] Finding unique elements faster

2014-12-08 Thread Jeff Newmiller
The data.table package might be of use to you, but lacking a reproducible example [1] I think I will leave figuring out just how to you. Being on Nabble you may not be able to see the footer appended to every message on this MAILING LIST. For your benefit, here it is: * R-help@r-project.org m

Re: [R] Merging two data.frames

2014-12-08 Thread Jeff Newmiller
Below... On Mon, 8 Dec 2014, David Lambert wrote: I have 2 data frames, M1[n,20] and M2[m,30]. What does this mean? It might be intended to convey matrix dimensions, but these are not matrices and that is not R syntax. If V1 and V2 are the same in both M1 and M2, then append V3-V30 from M

Re: [R] String manipulation

2014-12-08 Thread William Dunlap
Actually, the zero-length look-ahead expression is enough to get the job done: > strsplit(c(":sad", "happy:", "happy:sad", ":happy:sad:subdued:"), split="(?=:)", perl=TRUE) [[1]] [1] ":" "sad" [[2]] [1] "happy" ":" [[3]] [1] "happy" ":" "sad" [[4]] [1] ":" "happy" ":" "sad"

Re: [R] String manipulation

2014-12-08 Thread William Dunlap
strsplit(split=":") does almost what you want, but it omits the colons from the output. You can use perl zero-length look-ahead and look-behind operators in the split argument to get the colons as well: > strsplit(c(":sad", "happy:", "happy:sad"), split="(?<=:)|(?=:)", perl=TRUE) [[1]] [1] ":"

Re: [R] Making random values which are binary numbers

2014-12-08 Thread Duncan Murdoch
On 08/12/2014 6:25 AM, Frederic Ntirenganya wrote: Hi All, i would like to write a srcipt which ruturn the random numbers which are binary numbers. Example: The first group : 1 second : 0 third : 1010111100 in such away that i can make it

[R] String manipulation

2014-12-08 Thread Gang Chen
I want to do the following: if a string does not contain a colon (:), no change is needed; if it contains one or more colons, break the string into multiple strings using the colon as a separator. For example, "happy:" becomes "happy" ":" ":sad" turns to ":" "sad" and "happy:sad" changes to "h

[R] Making random values which are binary numbers

2014-12-08 Thread Frederic Ntirenganya
Hi All, i would like to write a srcipt which ruturn the random numbers which are binary numbers. Example: The first group : 1 second : 0 third : 1010111100 in such away that i can make iterartions. Frederic Ntirenganya Maseno University, Af

[R] combining two distributions

2014-12-08 Thread Alaios via R-help
(I am sorry if you have received this email twice but it does not look sent on my client) Hi all,I am having some heavy tailed data and I am trying to think of the more appropriate package for the fitting.The canonical try should be something like exponential and pareto or exponential + ga

[R] Finding unique elements faster

2014-12-08 Thread apeshifter
Dear all, for the past two weeks, I've been working on a script to retrieve word pairs and calculate some of their statistics using R. Everything seemed to work fine until I switched from a small test dataset to the 'real thing' and noticed what a runtime monster I had devised! I could reduce p

[R] My code needs improvement

2014-12-08 Thread Vassiliki Marinou
Hello! I am performing a sentiment analysis of 2.000 negative and positive reviews. I think my code needs improvement because I am getting accuracy 68 % and the running duration of the code is 20 minutes!! Please find below a part of the code. " # Read data from their directories pos <- Corpus(Di

[R] Merging two data.frames

2014-12-08 Thread David Lambert
I have 2 data frames, M1[n,20] and M2[m,30]. If V1 and V2 are the same in both M1 and M2, then append V3-V30 from M2 onto M1. Otherwise, continue searching for a match. M1 is complete for all V1 and V2. M2 is missing observations for V1 or V2, or both. I can't figure this one out, except

Re: [R] date time problem

2014-12-08 Thread Jeff Newmiller
You are still posting in HTML, and it is continuing to impede this conversation. Learn how to post in plain text before posting again. Gmail does have this option. You are not using dput, as previously asked, either. Read the web page I referenced to learn how to send R data unambiguously. Y

Re: [R] data frame cumulative row sum

2014-12-08 Thread Rolf Turner
On 08/12/14 21:18, Ragia Ibrahim wrote: Hi, Kindly I had a data frame looks like this x y 1 3 2 2 3 1 4 3 and I want to add column z that sum cumulativly like this x y z 1 3 3 2 2 5 3 1 6 4 3 9 how to do this? (1) Learn to use R. This is very basic; read some introductory material. Start wi

Re: [R] data frame cumulative row sum

2014-12-08 Thread Don McKenzie
my.data$z <- cumsum(my.data$y) Yes, the function you need is even in your message subject. > On Dec 8, 2014, at 12:18 AM, Ragia Ibrahim wrote: > > Hi, > Kindly I had a data frame looks like this > x y > 1 3 > 2 2 > 3 1 > 4 3 > and I want to add column z that sum cumulativly like this

Re: [R] data frame cumulative row sum

2014-12-08 Thread Rui Barradas
Hello, If your dataset is named 'dat', try dat$z <- cumsum(dat$y) Hope this helps, Rui Barradas Em 08-12-2014 08:18, Ragia Ibrahim escreveu: Hi, Kindly I had a data frame looks like this x y 1 3 2 2 3 1 4 3 and I want to add column z that sum cumulativly like this x y z 1 3 3 2 2 5 3 1 6 4

Re: [R] MLE with parameters restricted to a defined range using bbmle

2014-12-08 Thread Rolf Turner
I know nothing about the bbmle package and its mle2() function, but it is a general truth that if you need to constrain a parameter to be positive in an optimisation procedure a simple and effective approach is to reparameterize using exp(). I.e. represent xmin as exp(lxmin) (say) and use l

Re: [R] Passing data to t.test in loop

2014-12-08 Thread PIKAL Petr
Hi Is this what you want? by(data$time, list(data$size), function(x) t.test(x)) Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul > Johnston > Sent: Tuesday, December 02, 2014 10:17 AM > To: r-h...@lists.r-project.org > Subject: [R] Passing

Re: [R] vectorization of rolling function

2014-12-08 Thread Jeff Newmiller
Please don't post in HTML... you may not recognize it, but the receiving end does not necessarily (and in this case did not) look like the sending end, and the cleanup can impede answers you are hoping to get. In many cases, loops can be vectorized. However, near as I can tell this is an exam

Re: [R] vectorization of rolling function

2014-12-08 Thread Arnaud Duranel
Great, many thanks for your help Jeff. Apologies for the HTML format, I'll be more careful next time. Arnaud On 08/12/2014 08:25, Jeff Newmiller wrote: Please don't post in HTML... you may not recognize it, but the receiving end does not necessarily (and in this case did not) look like the send

[R] data frame cumulative row sum

2014-12-08 Thread Ragia Ibrahim
Hi, Kindly I had a data frame looks like this x y 1 3 2 2 3 1 4 3 and I want to add column z that sum cumulativly like this x y z 1 3 3 2 2 5 3 1 6 4 3 9 how to do this? Regards Ragia [[alternative HTML version deleted]] ___

[R] Revolutions blog: November 2014 Roundup

2014-12-08 Thread David Smith
Revolution Analytics staff and guests write about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles related

[R] MLE with parameters restricted to a defined range using bbmle

2014-12-08 Thread Bernardo Santos
Dear all, I am fitting models to data with mle2 function of the bbmle package.In specific, I want to fit a power-law distribution model, as defined here (http://arxiv.org/pdf/cond-mat/0412004v3.pdf), to data. However, one of the parameters - xmin -, must be necessarily greater than zero. What ca

[R] RODBC Error

2014-12-08 Thread Knut Krueger
There is a system wide installation for the university computer of r and Rcmdr (R-Commander) There a a few computer with the following message the user tries to open an excel sheet with R.Commander: (I assume the german message is from the german operating system win 7) > library(RODBC, pos=