Re: [R] Error in y - ymean : non-numeric argument to binary operator

2017-05-26 Thread Peter Langfelder
This is a bit of a shot in the dark since I haven't used randomForest in several years, but I seem to recall that running randomForest through the formula interface was asking for trouble... Try not using the formula interface and specify the x, y, xtest arguments directly. Peter On Fri, May 26,

[R] Error in y - ymean : non-numeric argument to binary operator

2017-05-26 Thread ddkssk 909
I am trying to do classification with Randomforest() . the class variable is nominal. But I get this error model1 <-randomForest(Cath~.,data=trainrf) Error in y - ymean : non-numeric argument to binary operator In addition: There were 26 warnings (use warnings() to see them) > model1 Error: objec

Re: [R] [R-SIG-Finance] getting a subset corresponding to a list element

2017-05-26 Thread Robert Harlow
Hi Michael, Try not to post twice - this is really more of a general R question. To answer the question, however, turn each element of your resultlist into an xts (or zoo) object so that you have a list of xts objects (called xtsList for example.) Then call do.call("merge", xtsList). Also, yo

[R] getting a subset corresponding to a list element

2017-05-26 Thread Michael Ashton
I'm not sure how to ask this with the proper terminology, but here goes: The BDH() function in RBLPAPI returns, for a list of symbols (e.g., 'SPX Index','RIY Index','IBM Equity') a list of closing prices. The problem is that the result is not a matrix or a dataframe, but a list. So, if I run th

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Hi David thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 4:51 PM, David L Carlson wrote: > How about? > > Trade <- xtabs(FLOW ~ iso_o + iso_d + year,

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 3:28 PM, S Ellison wrote: > > -Original Message- > > From: A M > Lavezzi > > > > I have data

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Hi Duncan thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 2:20 PM, Duncan Murdoch wrote: > On 26/05/2017 7:46 AM, A M Lavezzi wrote: > >> Dear R-User

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Hi Ulrik thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 2:17 PM, Ulrik Stervbo wrote: > Hi Mario, > > does acast from the reshape2 package help? > >

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Dear Sarah thank you very much. I used "crosstab" and it worked, xxx<-crosstab(dataTrade$iso_o,dataTrade$iso_d,dataTrade$FLOW,type="sum",na.rm=TRUE) All the best Mario On Fri, May 26, 2017 at 2:15 PM, Sarah Goslee wrote: > There are various ways to do this. It shouldn't take forever as a loop,

[R] Latin Hypercube Sampling when parameters are defined according to specific probability distributions

2017-05-26 Thread Nelly Reduan
Hello, I would like to perform a sensitivity analysis using a Latin Hypercube Sampling (LHS). Among the input parameters in the model, I have a parameter �dispersal distance� which is defined according to an exponential probability distribution. In the model, the user thus sets a default prob

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread David L Carlson
How about? Trade <- xtabs(FLOW ~ iso_o + iso_d + year, dta) Gives you a 3d table with FLOW as the cell entry. Then apply(Trade, 1:2, sum, na.rm=TRUE) Gives you a 2d table with the total flow David L. Carlson Department of Anthropology Texas A&M University -Original Message- From: R-h

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread S Ellison
> -Original Message- > From: A M > Lavezzi > > I have data on bilateral trade flows among countries in the following form: > > iso_o iso_d year FLOW > 1 ABW AFG 1985 NA > 2 ABW AFG 1986 NA > 3 ABW AFG 1987 NA > 4 ABW AFG 1988 NA > 5 ABW AFG 1989 NA > 6

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread Duncan Murdoch
On 26/05/2017 7:46 AM, A M Lavezzi wrote: Dear R-Users I have data on bilateral trade flows among countries in the following form: head(dataTrade) iso_o iso_d year FLOW 1 ABW AFG 1985 NA 2 ABW AFG 1986 NA 3 ABW AFG 1987 NA 4 ABW AFG 1988 NA 5 ABW AFG 1989

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread Ulrik Stervbo
Hi Mario, does acast from the reshape2 package help? dfa<- data.frame(iso_o = letters[c(1, 1:4)], iso_d = letters[6:10], year = c(1985, 1985, 1986, 1987, 1988), flow = c(1,2,3,4, NA)) reshape2::acast(dfa, iso_o ~ iso_d, fun.aggregate = sum, value.var = "flow") HTH Ulrik On Fri, 26 May 2017 at 1

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread Sarah Goslee
There are various ways to do this. It shouldn't take forever as a loop, with only 215 entries. I find crosstab() from the ecodist package helpful. The current version is on GitHub, but not yet CRAN (soon!). Sarah On Fri, May 26, 2017 at 7:47 AM A M Lavezzi wrote: > Dear R-Users > > I have data

[R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Dear R-Users I have data on bilateral trade flows among countries in the following form: > head(dataTrade) iso_o iso_d year FLOW 1 ABW AFG 1985 NA 2 ABW AFG 1986 NA 3 ABW AFG 1987 NA 4 ABW AFG 1988 NA 5 ABW AFG 1989 NA 6 ABW AFG 1990 NA where: iso_o: co

Re: [R] using "dcast" function ?

2017-05-26 Thread Ulrik Stervbo
It is correct and will produce a data.frame. But I guess the result is not what you intend since the resulting data.frame nothing but NA and Samples in the diagonal: df1 <- data.frame(x = letters[1:5], y = letters[6:10]) reshape2::dcast(df1, x ~ y) You are missing values somewhere. If you want al

[R] using "dcast" function ?

2017-05-26 Thread Bogdan Tanasa
Dear all, I would like to double-check with you please the use of "acast" or "dcast" function from "reshape2"package. I am starting with a data frame Y of GENES and SAMPLES,eg : Cancer_Gene Sample 1ABL2 WT_10T 2ABL2 WT_6T 3 ADGRA2 HB_8R 4AFF4 EWS_13R and I

Re: [R] MDS plot in Random Forest

2017-05-26 Thread Ismail SEZEN
> On 25 May 2017, at 20:35, Elahe chalabi via R-help > wrote: > > Thanks for your reply Bert. But the question on how to plot MDS on predicted > data I guess belong to here! Actually, You have 2 questions in conflict. 1- how can I plot MDS on predicted data? 2- Is MDS plot a way to find out

Re: [R] MDS plot in Random Forest

2017-05-26 Thread Elahe chalabi via R-help
Thanks for your reply Bert. But the question on how to plot MDS on predicted data I guess belong to here! On Thursday, May 25, 2017 9:43 AM, Bert Gunter wrote: Elahe: On Thu, May 25, 2017 at 8:15 AM, Elahe chalabi via R-help wrote: > Hi all, > I have applied Random Forest on my data and