Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread Jun Shen
Thanks David.This is working perfectly! On Fri, Jul 29, 2016 at 9:00 PM, David Winsemius wrote: > > > On Jul 29, 2016, at 5:52 PM, David Winsemius > wrote: > > > > > >> On Jul 29, 2016, at 5:08 PM, Jun Shen wrote: > >> >

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread David Winsemius
> On Jul 29, 2016, at 5:52 PM, David Winsemius wrote: > > >> On Jul 29, 2016, at 5:08 PM, Jun Shen wrote: >> >> Thanks Jeff/David for the reply. I wasn't clear in the previous message. the >> problem of using na.omit is it will omit the whole

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread David Winsemius
> On Jul 29, 2016, at 5:08 PM, Jun Shen wrote: > > Thanks Jeff/David for the reply. I wasn't clear in the previous message. the > problem of using na.omit is it will omit the whole row where there is at > least one NA, even when some variables do have non-NA values.

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread Jun Shen
Thanks Jeff/David for the reply. I wasn't clear in the previous message. the problem of using na.omit is it will omit the whole row where there is at least one NA, even when some variables do have non-NA values. For example: let's define a new function N <- function(x) length(x[!is.na(x)]) test

Re: [R] font size in graphs...can R read Windows settings?

2016-07-29 Thread Duncan Mackay
Hi There are some System commands that grab a computers settings to suit your purpose but I do not know what they are. May be tikz or Java or python based packages will improve things but I do not know them at all Regards Duncan From: Dalthorp, Daniel

Re: [R] Reduce woes

2016-07-29 Thread Jeff Newmiller
Having experienced some frustration myself when I first started with R many years ago, I can relate to your apparent frustration. However, if you would like to succeed in using R I strongly recommend learning R and not trying to write Haskell or Erlang or C or Fortran or any other language when

Re: [R] I'm getting confused with notation and terminology in output from weibull parametric survival model from survreg()

2016-07-29 Thread Dalthorp, Daniel
The parameterization for Weibull in the 'survival' package corresponds to base R's dweibull, etc. suite as 1/scale --> shape and exp(coef[1]) --> scale On Fri, Jul 29, 2016 at 1:07 PM, Christopher W. Ryan wrote: > I'm trying to run a Weibull parametric survival model for

[R] I'm getting confused with notation and terminology in output from weibull parametric survival model from survreg()

2016-07-29 Thread Christopher W. Ryan
I'm trying to run a Weibull parametric survival model for recurrent event data, with subject-specific frailties, using survreg() in the survival package, and I'm having trouble understanding the output and its notation, and how that translates to some of the books I am using as references (DF

Re: [R] what happened to inside-r? [possibly OT]

2016-07-29 Thread David Winsemius
Been off the grid for the last year? MS bought Revolution R. Sent from my iPhone > On Jul 29, 2016, at 11:30 AM, Christopher W. Ryan > wrote: > > This might be a bit off-topic, but up until recently (a day or so ago?) I > loved using inside-r.org as a quick and easy

Re: [R] WordCloud Does not display in RMD File in R Studio

2016-07-29 Thread Shivi Bhatia
Hi Yihui, Seems like the issue was with the wordcloud. I used wordcloud2 and it worked handsomely. & thanks for suggesting wordcloud2 seems far better than wordcloud. tc. On Sat, Jul 30, 2016 at 12:00 AM, Shivi Bhatia wrote: > Thanks for the suggestion. even without png

Re: [R] WordCloud Does not display in RMD File in R Studio

2016-07-29 Thread Shivi Bhatia
Thanks for the suggestion. even without png isnt not working. I will check this new package. Thank you. On Fri, Jul 29, 2016 at 11:45 PM, Yihui Xie wrote: > Typically you don't need to open the png() device manually. Try > comment out that line. > > BTW, I'm not sure which

[R] what happened to inside-r? [possibly OT]

2016-07-29 Thread Christopher W. Ryan
This might be a bit off-topic, but up until recently (a day or so ago?) I loved using inside-r.org as a quick and easy way to access help pages on R commands. Took me to what I needed without any fuss. Now that URL redirects to the "Microsoft R Application Network"? Looks to be something

Re: [R] WordCloud Does not display in RMD File in R Studio

2016-07-29 Thread Yihui Xie
Typically you don't need to open the png() device manually. Try comment out that line. BTW, I'm not sure which wordcloud package you were using, but this one is the best one I have seen: https://github.com/Lchiffon/wordcloud2 Regards, Yihui -- Yihui Xie Web:

[R] WordCloud Does not display in RMD File in R Studio

2016-07-29 Thread Shivi Bhatia
Dear Team, I have created a text mining solution for one of my business owners. I am sharing with his using RMD via HTML. All is working ok however the WordCloud does not populate any output in RMD file. Few months back when this happened on R studio i searched and used dev.off() to shut down

Re: [R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread MacQueen, Don
For what it's worth (perhaps little...), I would normally do for (pn in pathnames) source(pn) It's clearer to read and won't return a strange value. I doubt there will be a noticeable difference in speed. It can easily be extended to be more informative, as in for (pn in pathnames) { cat('---

Re: [R] Reduce woes

2016-07-29 Thread Stefan Kruger
>> I still don't understand why you want Reduce to to lapply's >> job. Reduce maps many to one and lapply maps many to >> many. Say you want to map a function over a subset of a vector or list? With the generalised version of Reduce you map many-to-one, but the one can be a 'complex' structure.

Re: [R] metafor estimates using mods and subset do not match

2016-07-29 Thread Michael Dewey
Dear Kathryn I think that the author of metafor has addressed this http://www.metafor-project.org/doku.php/tips:comp_two_independent_estimates The other tips on that site are well worth reading too. On 29/07/2016 14:44, Morris, Kathryn wrote: I am running a meta-analysis using metafor and

Re: [R] metafor estimates using mods and subset do not match

2016-07-29 Thread Bert Gunter
I think you should consult with a local statistician. Generally speaking, statistical questions like this tend to be OT here, and you appear to be sufficiently confused about the statistical issues that online posts would not be sufficient. Cheers, Bert Bert Gunter "The trouble with having an

[R] Using lapply or mapply

2016-07-29 Thread Mehta, Gaurang
Hi Team, I am new to using apply function in R. I want to find out the empirical quantiles of all items in a list. ## Fitting Kernal Density function Emp_Marginals<-apply(M_Diff_Final,2,kde) ### Simulated variables

Re: [R] store result of loop in df

2016-07-29 Thread Bert Gunter
What's wrong with: result <- with(df, x/n) ? Do I misunderstand? (and what's the p = .065 or [[1]] have to do with the estimated prob, as you are not actually doing any test?) Finally, if you really do this sort of thing, ?mapply (and ?with) can be useful; e.g. you could have rewritten your

Re: [R] Reduce woes

2016-07-29 Thread William Dunlap via R-help
Reduce (like lapply) apparently uses the [[ operator to extract components from the list given to it. X[[i]] does not attach names(X)[i] to its output (where would it put it?). Hence your se To help understand what these functions are doing try putting print statements in your test functions: >

[R] metafor estimates using mods and subset do not match

2016-07-29 Thread Morris, Kathryn
I am running a meta-analysis using metafor and getting what seem to be conflicting results. #analysis with species moderator cropMeta.species<-rma(cropyi, cropvi, data=dataCropMeta, mods=~dataCropMeta$species - 1, method="HE") The output for the analysis using species as a moderator shows

Re: [R] problems reading XML type file from ishares website

2016-07-29 Thread Bos, Roger
Jeff, Thanks so much for your help. I feel pretty confident in saying that there is no way I could have figured out how to open that file (in R) by myself. It was hard enough to get the data I needed once I could read the file. In case anyone on the list is interested, here is a working

[R-es] Eliminar filas al principio y final de un .csv en R

2016-07-29 Thread c.escalante.c
Saludos, Joan. Dale una mirada a la biblioteca R llamada xlsconnect.  César Escalante Mensaje original De: r-help-es-requ...@r-project.org Fecha:07/28/2016 3:41 PM (GMT-04:00) A: r-help-es@r-project.org Asunto: Resumen de R-help-es, Vol 89, Envío 36 Envíe los mensajes

Re: [R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread Keith Jewell
I can't immediately see it in the help text but it seems that source returns a list with two named elements; value and visible. I surmise that it is returned using withVisible (qv). KJ On 29/07/2016 13:26, jim holtman wrote: Hard to tell without seeing the scripts. Do you have a matrix in

Re: [R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread Fox, John
Dear Frank, What you see isn't a "message" but the result returned by sapply(). The ?s indicate that sapply() didn't know what to do with the corresponding element. In an individual use of source(), the result, a 2-element list, is returned invisibly, so you don't see it. To see what's going

Re: [R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread jim holtman
Hard to tell without seeing the scripts. Do you have a matrix in your scripts that have "value" and "visible" as row names? You probably have some statement that is causing output and so the problem is "your" as to how to avoid the message. So look at your scripts to see if anything refers to

[R] Strange message after reading multiple scripts from one folder

2016-07-29 Thread Frank S.
Dear list, I have one folder named "scripts_JMbayes", wich contains 10 R scripts. I can read them properly by doing: > pathnames <- list.files(pattern="[.]R", path="Mydir/scripts_JMbayes", > full.names = TRUE) > sapply(pathnames, USE.NAMES = FALSE, FUN = source,) However, R generates the

Re: [R] cpquery problem

2016-07-29 Thread Marco Scutari
Hi Ross, first, I have a side question: is there a particular reason why you are using parse(eval()) in your queries? I know sometimes there is no other solution if you only use exported functions, but you should try not to. It makes for brittle code that breaks easily depending on how variables

Re: [R] [FORGED] store result of loop in df

2016-07-29 Thread Ivan Calandra
Le 29/07/2016 à 11:20, Rolf Turner a écrit : On 29/07/16 20:52, Alain D. via R-help wrote: Dear list, I have a dataframe df: df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60)) Now I want to run n=nrow binom.test() with x being the number of success and n the number of trials and

Re: [R] store result of loop in df

2016-07-29 Thread Ivan Calandra
Dear Alain, The problem is that you save the results of each iteration in df$VAR. So obviously, you overwrite df$VAR at each iteration. What you need to do it to create an empty vector that contains the right number of elements and then iteratively fill this list. You can then combine df

Re: [R] [FORGED] store result of loop in df

2016-07-29 Thread Rolf Turner
On 29/07/16 20:52, Alain D. via R-help wrote: Dear list, I have a dataframe df: df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60)) Now I want to run n=nrow binom.test() with x being the number of success and n the number of trials and then store the results as a new VAR in df. I tried

Re: [R] store result of loop in df

2016-07-29 Thread Jim Lemon
Hi Alain, You are probably storing the result, replicated five times, in df$VAR. Each cycle of the loop replaces the last value with the current value. If you really want the entire output of binom.test in the last column: multi.binom.test<-function(xs,ns) { reslist<-list() for(i in

Re: [R] store result of loop in df

2016-07-29 Thread Berend Hasselman
> On 29 Jul 2016, at 10:52, Alain D. via R-help wrote: > > Dear list, > > I have a dataframe df: > > df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60)) > > Now I want to run n=nrow binom.test() with x being the number of success and n > the number of trials and

Re: [R] Extract data

2016-07-29 Thread Jim Lemon
Hi Roslina, This may be what you want: sum_balok<- as.vector(by(aggbalok_2009_2014$x,aggbalok_2009_2014$year,sum,na.rm=TRUE)) cbind(year=2009:2014,sum_balok) I don't have the data for the other measures, but you could calculate the sums as you did below and then add them to the cbind arguments.

[R] store result of loop in df

2016-07-29 Thread Alain D. via R-help
Dear list, I have a dataframe df: df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60)) Now I want to run n=nrow binom.test() with x being the number of success and n the number of trials and then store the results as a new VAR in df. I tried for (i in 1:nrow(df)){

Re: [R] Reduce woes

2016-07-29 Thread Stefan Kruger
Jeremiah - neat - that's one step closer, but one small thing I still don't understand: > data <- list(one = c(1, 1), three = c(3), two = c(2, 2)) > r = Reduce(function(acc, item) { append(acc, setNames(length(item), names(item))) }, data, list()) > str(r) List of 3 $ : int 2 $ : int 1 $ :

Re: [R] Reducing execution time

2016-07-29 Thread sri vathsan
Hi, Thanks for the response. Unfortunately this did not solve my problem and may be the way I represented my data would be the problem. I am not sure that I can give a link for the data which will give a clear representation. If that is not a proper way, I have to follow my original method.

[R] cpquery problem

2016-07-29 Thread ross.chapman
Hi all I have a problem with the cpquery function in the bnlearn package. I have constructed a hybrid network (using a mix of continuous and discrete variables). The network is named "fitted". I am interested in predicting the probability of observing a value greater that a

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread David Winsemius
> On Jul 28, 2016, at 7:37 PM, Jun Shen wrote: > > Because in reality the NA may appear in one variable but not others. For > example for ID=1, CL may be NA but not for others, For ID=2, V1 may be NA > etc. To keep all the IDs and all the variables in one data frame, it's

Re: [R] EM algorithm for maximizing the likelihood of Multivariate Hawkes process

2016-07-29 Thread Jeff Newmiller
How did you try to find the answer before posting? Some possibilities might be go ogling [1] or perusing CRAN to find [2]... Note that HTML tends to mangle code... please follow the Posting Guide and send plain text email to this list. [1] http://bfy.tw/6y3o [2]