Re: [R] stfrtime function not returning proper results through sqldf package in R

2016-09-15 Thread Jeff Newmiller
This question is missing pieces... the example is incomplete. -- Sent from my phone. Please excuse my brevity. On September 15, 2016 9:35:45 PM PDT, Manohar Reddy wrote: >Hi , > > > >I have data something looks like below (or PFA), but when I’m >extracting >month using *strftime* function th

[R] stfrtime function not returning proper results through sqldf package in R

2016-09-15 Thread Manohar Reddy
Hi , I have data something looks like below (or PFA), but when I’m extracting month using *strftime* function through *sqldf* library ,it’s returning below results but it’s not returning exact results ,it supposed to return 05,05,05,06,06,06.Can anyone please guide me how to do that with *s

Re: [R] Visualizing and clustering one half of a symmetric matrix

2016-09-15 Thread Peter Langfelder
Do not set the upper (or lower) triangle to NA. Simply supply the full matrix to pheatmap. I am not an expert on pheatmap but looking at the manual you should supply clustering_distance_rows = "none", clustering_distance_cols = "none" or something like that to make pheatmap interpret the matrix as

[R] Visualizing and clustering one half of a symmetric matrix

2016-09-15 Thread Khan, Saad M. (MU-Student)
Hi all, I have a distance matrix (symmetric) which looks somewhat like this (only a small portion shown) ENSG0101413 ENSG0176884 ENSG0185532 ENSG0106829 ENSG0101413 1.000 1.000 1.000 1.000 ENSG0176884 0.328

Re: [R] NaN Log-lik value in EM algorithm (fitting Gamma mixture model)

2016-09-15 Thread William Dunlap via R-help
Does the data contain non-positive values? > out <- mixtools::gammamixEM(as.numeric(0:100), lambda = c(1, 1, 1)/3, verb = TRUE) iteration = 1 log-lik diff = NaN log-lik = NaN Error in while (diff > epsilon && iter < maxit) { : missing value where TRUE/FALSE needed Bill Dunlap TIBCO Software

Re: [R] NaN Log-lik value in EM algorithm (fitting Gamma mixture model)

2016-09-15 Thread Aanchal Sharma
I am using a function gammamixEM where it does it by default. I do not have the option to change it. Conceptually, what can make the algorithm not able to calculate likelihood value at all (and hence log-lik=Nan)? Is there sth wrong with the data? Under what conditions does it happen? On Wed, Sep

Re: [R] box type in Hmisc xYplot

2016-09-15 Thread David Winsemius
> On Sep 15, 2016, at 1:32 PM, David Winsemius wrote: > > >> On Sep 15, 2016, at 12:59 PM, Cade, Brian wrote: >> >> Does anyone know how to change the box type in Hmisc package function >> xYplot. I want only the left and bottom axes drawn, similar to what I >> would accomplish with bty="l"

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Jeff Newmiller
You are ignoring the warning issued when you load plyr after dplyr and then complaining. Simply reversing the sequence of library statements is sufficient to fix your example. I agree that it is not ideal and that using just one at a time is easier, but you can use both, and for now a lot of pa

Re: [R] box type in Hmisc xYplot

2016-09-15 Thread Cade, Brian
No even in xyplot() the scales argument is not eliminating plotting of the top and right graph axes. It is not the scale of the axes I want eliminated but the actual lines. But thank you for trying. Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave.,

Re: [R] box type in Hmisc xYplot

2016-09-15 Thread Bert Gunter
I do not know about xYplot, but the "scales" argument controls axes in xyplot. For example: scales = list(alternating = 1) would draw axes on left/bottom ... see ?xyplot for details and subtleties. Again, might not work for xYplot. Cheers, Bert Bert Gunter "The trouble with having an open min

Re: [R] box type in Hmisc xYplot

2016-09-15 Thread David Winsemius
> On Sep 15, 2016, at 12:59 PM, Cade, Brian wrote: > > Does anyone know how to change the box type in Hmisc package function > xYplot. I want only the left and bottom axes drawn, similar to what I > would accomplish with bty="l" argument in plot() function. bty= argument > did not do anything

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Frans Marcelissen
I never realised that nonsense results don’n bother experienced users….. Probably I am not experienced wiith my 6years of R professional work. I think your advise is incomplete: a %>% dplyr::group_by(groep) %>% dplyr::summarise(m=mean(v),n=dplyr::n()) Gives the same problems and makes the line ug

Re: [R] separate commands by semicolon

2016-09-15 Thread Adrian Dușa
On Thu, Sep 15, 2016 at 10:28 PM, William Dunlap wrote: > The most reliable way to split such lines is with parse(text=x). > Regular expressions don't do well with context-free grammars. > Oh, that's right of course. > as.character(parse(text = x)) [1] "foo <- \"3;4\"""bar <-

[R] box type in Hmisc xYplot

2016-09-15 Thread Cade, Brian
Does anyone know how to change the box type in Hmisc package function xYplot. I want only the left and bottom axes drawn, similar to what I would accomplish with bty="l" argument in plot() function. bty= argument did not do anything for me in xYplot(). Brian Brian S. Cade, PhD U. S. Geological

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Jeff Newmiller
The incorrect results are unfortunate and can trip up the inexperienced user, but this problem is straightforward to resolve if you explicitly specify which versions of the conflicting functions to use. The more interesting question I saw was whether the intent is to deprecate plyr, but so far t

Re: [R] separate commands by semicolon

2016-09-15 Thread William Dunlap via R-help
The most reliable way to split such lines is with parse(text=x). Regular expressions don't do well with context-free grammars. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Sep 15, 2016 at 12:08 PM, Adrian Dușa wrote: > Dear R-helpers, > > When parsing a text, I would like to separate co

[R] apply weight to a data frame

2016-09-15 Thread laura roncaglia
I am a beginner user of R. I am writing the master thesis using a data frame from a national survey. The data frame contains several variables, one of which contains the survey weights. I need to apply the survey weights to the data frame, in order to use the data frame with the plm package (I ne

[R] separate commands by semicolon

2016-09-15 Thread Adrian Dușa
Dear R-helpers, When parsing a text, I would like to separate commands written on the same line, by a semicolon. Something like: x <- "foo <- '3;4'; bar <- \"don't ; use semicolons\"" Ideally, that would translate to these two commands in a character vector of length 2: foo <- '3;4' bar <- "don'

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Christopher W. Ryan
Thank you Frans. This is exactly the sort of nuance that I want to learn about. --Chris Frans Marcelissen wrote: Hello Christopher and others : What cannot be stressed enough is: do not combine both packages, it gives errors and incorrect results! I will show that below ---

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Frans Marcelissen
Hello Christopher and others : What cannot be stressed enough is: do not combine both packages, it gives errors and incorrect results! I will show that below a<-data.frame(groep=1:4,v=1:40) library(dplyr) a %>% group_by(groep) %>% summarise(m

Re: [R] Better use of regex

2016-09-15 Thread Bert Gunter
Thanks for the reproducible example. Using regular expressions: sub(".*HS_(.).*", "\\1", dimInfo[grep("HS_",dimInfo)]) The grep() gets just the indices that contain "HS_" and the sub() picks up the character you want from the subvector indexed by them and replaces everything with it. Cheers, Be

Re: [R] Better use of regex

2016-09-15 Thread ruipbarradas
Hello, What about the following? ff <- dimInfo[grep('HS', dimInfo)] sub("^.*HS_([[:alnum:]]).*$", "\\1", ff) Hope this helps, Rui Barradas Citando Doran, Harold : I have produced a terribly inefficient piece of codes. In the end, it gives exactly what I need, but clumsily steps through m

Re: [R] Better use of regex

2016-09-15 Thread Bob Rudis
Base: Filter(Negate(is.na), sapply(regmatches(dimInfo, regexec("HS_(.{1})", dimInfo)), "[", 2)) Modernverse: library(stringi) library(purrr) stri_match_first_regex(dimInfo, "HS_(.{1})")[,2] %>% discard(is.na) They both use capture groups to find the matches and return ju

[R] Better use of regex

2016-09-15 Thread Doran, Harold
I have produced a terribly inefficient piece of codes. In the end, it gives exactly what I need, but clumsily steps through multiple steps which I'm sure could be more efficiently reduced. Below is a reproducible example. What I have to begin with is character vector, dimInfo. What I want to do

Re: [R] dplyr or plyr or both?

2016-09-15 Thread Bert Gunter
I see no reason to bother Hadley in the age of google. Search on "dplyr versus plyr" and read what you get! (on the first hit, even) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in h

Re: [R] dplyr or plyr or both?

2016-09-15 Thread ruipbarradas
Hello, Maybe you should ask the maintainer of both packages. maintainer("plyr") [1] "Hadley Wickham " maintainer("dplyr") [1] "Hadley Wickham " Hope this helps, Rui Barradas Citando Christopher W Ryan : I've set myself the task of learning about these packages, and about tidy data con

[R] dplyr or plyr or both?

2016-09-15 Thread Christopher W Ryan
I've set myself the task of learning about these packages, and about tidy data concepts. What is the relationship between plyr and dplyr? Does the latter replace the former (meaning I can concentrate on learning the latter)? Or is there ever a need to use functions from both (meaning I should lea

Re: [R] why data.frame, mutate package and not lists

2016-09-15 Thread Rolf Turner
On 15/09/16 14:04, S Ellison wrote: If you want to add variable to data.frame you have to use attach, detach. Right? I'd have said "not at all", not "not quite". attach and detach have almost exactly nothing to do with adding to a data frame. You can add to a data frame using dfrm$newvar <-

Re: [R] why data.frame, mutate package and not lists

2016-09-15 Thread S Ellison
>If you want > to add variable to data.frame you have to use attach, detach. Right? I'd have said "not at all", not "not quite". attach and detach have almost exactly nothing to do with adding to a data frame. You can add to a data frame using dfrm$newvar <- dfrm['newvar'] <- cbind(dfrm,