Re: [R] How to obtain the unique communities when plotting VENNs?
Hi Krissey, I think what you need is the object (probably a matrix or data frame) that contains the present/absent codes for all of the species recorded. It looks to me as though the venn.diagram function wants a list with the indices of present codes for each set, and calculates the intersections from that. If you have that list, you can work backward to generate the initial present/absent matrix for all species. You will have to know the order of the rows in the initial matrix to identify which species is which. Jim On Fri, Aug 14, 2015 at 1:05 AM, Krissey kristin.kai...@web.de wrote: Thanks a lot John - I will set up a new post and hopefully do better :) -- View this message in context: http://r.789695.n4.nabble.com/How-to-obtain-the-unique-communities-when-plotting-VENNs-tp4711056p4711081.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multi-line forestplots, how to in R
Read Ella Comments in-line below On 14/08/2015 00:36, mcknight e. (em8g14) wrote: Hello, I am working on ecological data covering a meta-analysis on invasive species traits. I am not very skilled in R and would love if someone could assist me in my production of multi-line forest plots. The data I have is: random effects mixed model and is further divided into subsets, I have used metafor package and here is a breakdown of my code = #this is my main data calculation into effect sizes MA - escalc (measure=SMD, m1i=Invasive..mean, sd1i=sd.invasive, n1i=N.invasive, m2i=Control.mean, sd2i=sd.control, n2i=N.control, data=dataset) res.MA - rma(yi,vi,data=MA,method=REML);res.MA #random-effects models ; HS Viechtbauer (2005) Why does your comment say HS when you have in fact asked for it to estimate tau^2 using REML (which is the default)? #separating data lab - subset (x=MA, Type.of.ex==Lab) field - subset (x=MA, Type.of.ex==Field) You do not need to do that since rma.uni has a subset parameter as you use later res.MAlab - rma(yi,vi,data=lab,method=REML);res.MAlab #random-effects models ; HS Viechtbauer (2005) res.MAfield - rma(yi,vi,data=field,method=REML);res.MAfield #random-effects models ; HS Viechtbauer (2005) Could you not get the estimates you want by using Type.of.ex as a moderator here with the full dataset? From here on it is difficult to be sure what to say without more knowledge about your dataset and the underlying science but I wonder whether in fact you need to fit a multivariate model instead if you have (say) k studies each giving 6 trait estimates, and so on. If that is the way to go you need to read ?rma.mv Please set your mailer to not send HTML as it mangles your messages and it is more readable if you (a) put each command on a separate line (b) use more spaces. Disk space is cheap. res.traitlab - rma(yi,vi,mods= ~ factor(Trait)-1,data=lab);res.traitlab #model for traits res.traitfield - rma(yi,vi,mods= ~ factor(Trait)-1,data=field);res.traitfield #model for each lab traits res.labct - rma(yi,vi,subset=Trait==Consumption,data=lab);res.labct res.labec - rma(yi,vi,subset=Trait==Exploitative competition,data=lab);res.labec res.labgr - rma(yi,vi,subset=Trait==Growth,data=lab);res.labgr res.labic - rma(yi,vi,subset=Trait==Interference competition,data=lab);res.labic res.labpa - rma(yi,vi,subset=Trait==Predator avoidance,data=lab);res.labpa res.labpe - rma(yi,vi,subset=Trait==Predator escape,data=lab);res.labpe #model for each field traits res.fieldct - rma(yi,vi,subset=Trait==Consumption,data=field);res.labct res.fieldec - rma(yi,vi,subset=Trait==Exploitative competition,data=field);res.labec res.fieldgr - rma(yi,vi,subset=Trait==Growth,data=field);res.labgr res.fieldic - rma(yi,vi,subset=Trait==Interference competition,data=field);res.labic res.fieldpa - rma(yi,vi,subset=Trait==Predator avoidance,data=field);res.labpa res.fieldpe - rma(yi,vi,subset=Trait==Predator escape,data=field);res.labpe #producing a graph for lab data estimateslab - c(coef(res.labct), coef(res.labec), coef(res.labgr), coef(res.labic), coef(res.labpa),coef(res.labpe)) varianceslab - c(vcov(res.labct), vcov(res.labec), vcov(res.labgr), vcov(res.labic), vcov(res.labpa),vcov(res.labpe)) labelslab - c(Consumption (109),Exploitative competition (21),Growth (33),Interference competition (31),Predator avoidance (4),Predator escape (61)) forest(estimateslab, varianceslab, slab=labelslab, digit=0, annotate=F, xlab=Mean effect size,ylim=c(0,11)) #producing a graph for field data estimatesfield - c(coef(res.fieldct),coef(res.fieldec), coef(res.fieldgr), coef(res.fieldic),coef(res.fieldpa),coef(res.fieldpe)) variancesfield - c(vcov(res.fieldct),vcov(res.fieldec), vcov(res.fieldgr), vcov(res.fieldic), vcov(res.fieldpa), vcov(res.fieldpe)) labelsfield - c(Consumption (7),Exploitative competition (19),Growth (2),Interference competition (34),Predator avoidance (2),Predator escape (15)) forest(estimatesfield, variancesfield, slab=labelsfield,digit=0,annotate=F,xlab=Mean effect size,ylim=c(0,11)) # psize=1 size of mean box on forest plot addpoly(res.MAfield, row=0.2, cex=1, atransf=F, mlab=RE Model Field Studies (79),annotate=F) OK, so sorry for code overload... I hope you can understand what i have done. What i need it to produce one graph with both data sets Lab and field showing effect sizes for each of the mentioned traits. Im not super up to scratch on R and some of the current code was shared through a colleague, however this person isnt great at plots. Please please can someone help me. Im currently wasting heaps of my time and getting no where. Sincerely grateful Ella [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] cut variable within a loop
Hi Petr, Here the code below: load(data.Rda) # or see data at the bottom of this email ## ### Question cut2 intervals ### # I have the variable irrigation which has a range from 0% to 100%. # I now want to calculate the code below for different thresholds of irrigation. # So for instance: starting from 10%, a farmer is defined as irrigated farm. # Then we would have 0-10 = Rainfed, 10-100 is Irrigated. # In the code below I run a short code for only 50 observations and # only for the interval 0-1,1-100 and 0-2, 2-100. If that works, it should also # work for 1-99. # As indicated, it goes wrong when I want to cut based on the i specified at the start of the loop. # Thanks a lot for your help! # Janka d= data.frame(MEt_Rainfed=rep(1,2),MEp_Rainfed=rep(1,2),MEt_Irrigation=rep(1,2),MEp_Irrigation=rep(1,2)) library(Hmisc) o-lapply(1:2, function(i){ #cut sample in rainfed versus irrigation Alldata$irri=cut2(Alldata$irrigation,i) levels(Alldata$irri)-c(0,1) Alldata_Rainfed-subset(Alldata, irri == 0) Alldata_Irrigation-subset(Alldata, irri == 1) Alldata_Rainfed$w-Alldata_Rainfed$b48+Alldata_Rainfed$b50 Alldata_Irrigation$w-Alldata_Irrigation$b48+Alldata_Irrigation$b50 OLS_Rainfed - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+ ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+ pdnsty+portsML+cities500k+rentedland+subsidies1+ elevmean+elevrange+ t_gravel+t_gravel+t_ph_h2o+t_silt+t_sand+ AT+BE+DK+ES+FI+FR+GR+IE+IT+LU+NL+PT+SE+WDE+EDE+UK, weights=w,Alldata_Rainfed) attach(Alldata_Rainfed) CoefRainfed_ps1 - OLS_Rainfed$coeff[2] CoefRainfed_ps2 - OLS_Rainfed$coeff[3] CoefRainfed_ps3 - OLS_Rainfed$coeff[4] CoefRainfed_ps4 - OLS_Rainfed$coeff[5] CoefRainfed_ts1 - OLS_Rainfed$coeff[6] CoefRainfed_ts2 - OLS_Rainfed$coeff[7] CoefRainfed_ts3 - OLS_Rainfed$coeff[8] CoefRainfed_ts4 - OLS_Rainfed$coeff[9] CoefRainfed_ps1sq - OLS_Rainfed$coeff[10] CoefRainfed_ps2sq - OLS_Rainfed$coeff[11] CoefRainfed_ps3sq - OLS_Rainfed$coeff[12] CoefRainfed_ps4sq - OLS_Rainfed$coeff[13] CoefRainfed_ts1sq - OLS_Rainfed$coeff[14] CoefRainfed_ts2sq - OLS_Rainfed$coeff[15] CoefRainfed_ts3sq - OLS_Rainfed$coeff[16] CoefRainfed_ts4sq - OLS_Rainfed$coeff[17] attach(Alldata_Rainfed) ## MARGINAL EFFECTS SEASONAL and YEARLY and REGIONAL (EU or COUNTRY level) # Maar dit is dus de marginale impact per LnALVperHA? Alldata_Rainfed$MEts1 = CoefRainfed_ts1+2*CoefRainfed_ts1sq*Alldata_Rainfed$ts1 Alldata_Rainfed$MEts2 = CoefRainfed_ts2+2*CoefRainfed_ts2sq*Alldata_Rainfed$ts2 Alldata_Rainfed$MEts3 = CoefRainfed_ts3+2*CoefRainfed_ts3sq*Alldata_Rainfed$ts3 Alldata_Rainfed$MEts4 = CoefRainfed_ts4+2*CoefRainfed_ts4sq*Alldata_Rainfed$ts4 Alldata_Rainfed$MEt = Alldata_Rainfed$MEts1 + Alldata_Rainfed$MEts2 + Alldata_Rainfed$MEts3 + Alldata_Rainfed$MEts4 Alldata_Rainfed$MEps1 = CoefRainfed_ps1+2*CoefRainfed_ps1sq*Alldata_Rainfed$ps1 Alldata_Rainfed$MEps2 = CoefRainfed_ps2+2*CoefRainfed_ps2sq*Alldata_Rainfed$ps2 Alldata_Rainfed$MEps3 = CoefRainfed_ps3+2*CoefRainfed_ps3sq*Alldata_Rainfed$ps3 Alldata_Rainfed$MEps4 = CoefRainfed_ps4+2*CoefRainfed_ps4sq*Alldata_Rainfed$ps4 Alldata_Rainfed$MEp = Alldata_Rainfed$MEps1 + Alldata_Rainfed$MEps2 + Alldata_Rainfed$MEps3 + Alldata_Rainfed$MEps4 Alldata_Rainfed$weight2-Alldata_Rainfed$b48+Alldata_Rainfed$b50 attach(Alldata_Rainfed) library(stats) MEt_Rainfed-weighted.mean(MEt,weight2) MEp_Rainfed-weighted.mean(MEp,weight2) attach(Alldata_Irrigation) OLS_Irrigation - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+ ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+ pdnsty+portsML+cities500k+rentedland+subsidies1+ elevmean+elevrange+ t_gravel+t_gravel+t_ph_h2o+t_silt+t_sand+ AT+BE+DK+ES+FI+FR+GR+IE+IT+LU+NL+PT+SE+WDE+EDE+UK, weights=w,Alldata_Irrigation) CoefIrrigation_ps1 - OLS_Irrigation$coeff[2] CoefIrrigation_ps2 - OLS_Irrigation$coeff[3] CoefIrrigation_ps3 - OLS_Irrigation$coeff[4] CoefIrrigation_ps4 - OLS_Irrigation$coeff[5] CoefIrrigation_ts1 - OLS_Irrigation$coeff[6] CoefIrrigation_ts2 - OLS_Irrigation$coeff[7] CoefIrrigation_ts3 - OLS_Irrigation$coeff[8] CoefIrrigation_ts4 - OLS_Irrigation$coeff[9] CoefIrrigation_ps1sq - OLS_Irrigation$coeff[10] CoefIrrigation_ps2sq - OLS_Irrigation$coeff[11] CoefIrrigation_ps3sq - OLS_Irrigation$coeff[12] CoefIrrigation_ps4sq - OLS_Irrigation$coeff[13] CoefIrrigation_ts1sq - OLS_Irrigation$coeff[14] CoefIrrigation_ts2sq - OLS_Irrigation$coeff[15] CoefIrrigation_ts3sq - OLS_Irrigation$coeff[16] CoefIrrigation_ts4sq - OLS_Irrigation$coeff[17] attach(Alldata_Irrigation)
Re: [R] cut variable within a loop
Hey Michael, Sorry for the late reply! Thanks for your comment, but for the cut2 command, this is not the case. If I enter for instance Alldata$irri=cut2(irrigation,3) Then I get 2 intervals from 0-3 and from 3-100. Janka 2015-08-11 17:25 GMT+02:00 Michael Dewey li...@dewey.myzen.co.uk: Dear Janka If you supply a single number to the breaks parameter of cut I think it is the number of intervals. On 11/08/2015 13:57, Janka Vanschoenwinkel wrote: Hi Thierry! Thanks for your answer. I tried this, but I get this error: Error in cut.default(x, k2) : invalid number of intervals Which is strange because I am not specifying intervals, but the number at where the sample has to be cut? Greetings from Belgium! :-) 2015-08-11 14:52 GMT+02:00 Thierry Onkelinx thierry.onkel...@inbo.be: Dear Janka, You loop goes for 0 to 100. It should probably go from 1:99 Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-11 14:38 GMT+02:00 Janka Vanschoenwinkel janka.vanschoenwin...@uhasselt.be: Dear list members, I have a loop where I want to do several calculations for different samples and save the results for each sample. These samples are for each loop different. I want to use the i in the loop to cut the samples. So for instance: - In loop 1 (i=1), I have a sample from 0-1 and a sample from 1-100. - In loop 2 (i=2), I have a sample from 0-2 and a sample from 2-100. - In loop 99 (i=99), I have a sample from 0-99 and a sample from 99-100. I built the following function, but there is *a problem with the cut2 function* since it doesn't recognize the i. Outside the lapply loop it works, but not inside the loop. Could somebody please help me with this problem? Thanks a lot! d=data.frame(MEt_Rainfed=rep(0,100),MEp_Rainfed=rep(0,100),MEt_Irrigation=rep(0,100),MEp_Irrigation=rep(0,100)) o-lapply(0:100, function(i){ Alldata$irri=cut2(Alldata$irrigation,i) levels(Alldata$irri)-c(0,1) Alldata_Rainfed-subset(Alldata, irri == 0) Alldata_Irrigation-subset(Alldata, irri == 1) #calculations per sample, then store all the values per i and per variable in a dataframe: (the calculations are not shown in this example) d[i, ] = c(MEt_Rainfed,MEp_Rainfed,MEt_Irrigation,MEp_Irrigation) }) out-as.data.frame(do.call(rbind, o)) -- P Please consider the environment before printing this e-mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael http://www.dewey.myzen.co.uk/home.html -- [image: Logo UHasselt]Mevrouw Janka Vanschoenwinkel *Doctoraatsbursaal - PhD * Milieueconomie - Environmental economics T +32(0)11 26 87 42 | GSM +32(0)476 28 21 40 www.uhasselt.be/eec Universiteit Hasselt | Campus Diepenbeek Agoralaan Gebouw D | B-3590 Diepenbeek Kantoor F11 Postadres: Universiteit Hasselt | Martelarenlaan 42 | B-3500 Hasselt P Please consider the environment before printing this e-mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cut variable within a loop
On Aug 14, 2015, at 6:40 AM, Janka Vanschoenwinkel wrote: Hi Petr, Here the code below: load(data.Rda) # or see data at the bottom of this email ## ### Question cut2 intervals ### # I have the variable irrigation which has a range from 0% to 100%. # I now want to calculate the code below for different thresholds of irrigation. # So for instance: starting from 10%, a farmer is defined as irrigated farm. # Then we would have 0-10 = Rainfed, 10-100 is Irrigated. # In the code below I run a short code for only 50 observations and # only for the interval 0-1,1-100 and 0-2, 2-100. If that works, it should also # work for 1-99. # As indicated, it goes wrong when I want to cut based on the i specified at the start of the loop. # Thanks a lot for your help! # Janka d= data.frame(MEt_Rainfed=rep(1,2),MEp_Rainfed=rep(1,2),MEt_Irrigation=rep(1,2),MEp_Irrigation=rep(1,2)) library(Hmisc) o-lapply(1:2, function(i){ #cut sample in rainfed versus irrigation Alldata$irri=cut2(Alldata$irrigation,i) When using a function in R you may need to supply an argument name. Are you expecting this to be the number of groups. I cannot decipher the intent here with such sparse commentary, but this call to `cut2` does not make sense to me. Perhaps you meant the number of groups? in which case you need cut2( Alldata$irrigation, g=i ), since the arguments to cut2 are not that same as the arguments to cut. At the moment you are implicitly sending on the first pass a 1 and then on the second pass a 2 to the second argument of cut2 which is the `breaks` argument. So you wold be getting two different factors each with different cut-point levels. I looked at your data and in point of fact there would be no difference since you have 29 zero values and no values between 0 and 1. table(cut2(dat$irrigation, 1)) 0 [ 1,100] 2921 table(cut2(dat$irrigation, 2)) 0 [ 2,100] 2921 levels(Alldata$irri)-c(0,1) Alldata_Rainfed-subset(Alldata, irri == 0) Alldata_Irrigation-subset(Alldata, irri == 1) Alldata_Rainfed$w-Alldata_Rainfed$b48+Alldata_Rainfed$b50 Alldata_Irrigation$w-Alldata_Irrigation$b48+Alldata_Irrigation$b50 OLS_Rainfed - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+ ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+ pdnsty+portsML+cities500k+rentedland+subsidies1+ elevmean+elevrange+ t_gravel+t_gravel+t_ph_h2o+t_silt+t_sand+ AT+BE+DK+ES+FI+FR+GR+IE+IT+LU+NL+PT+SE+WDE+EDE+UK, weights=w,Alldata_Rainfed) attach(Alldata_Rainfed) CoefRainfed_ps1 - OLS_Rainfed$coeff[2] CoefRainfed_ps2 - OLS_Rainfed$coeff[3] CoefRainfed_ps3 - OLS_Rainfed$coeff[4] CoefRainfed_ps4 - OLS_Rainfed$coeff[5] CoefRainfed_ts1 - OLS_Rainfed$coeff[6] CoefRainfed_ts2 - OLS_Rainfed$coeff[7] CoefRainfed_ts3 - OLS_Rainfed$coeff[8] CoefRainfed_ts4 - OLS_Rainfed$coeff[9] CoefRainfed_ps1sq - OLS_Rainfed$coeff[10] CoefRainfed_ps2sq - OLS_Rainfed$coeff[11] CoefRainfed_ps3sq - OLS_Rainfed$coeff[12] CoefRainfed_ps4sq - OLS_Rainfed$coeff[13] CoefRainfed_ts1sq - OLS_Rainfed$coeff[14] CoefRainfed_ts2sq - OLS_Rainfed$coeff[15] CoefRainfed_ts3sq - OLS_Rainfed$coeff[16] CoefRainfed_ts4sq - OLS_Rainfed$coeff[17] attach(Alldata_Rainfed) ## MARGINAL EFFECTS SEASONAL and YEARLY and REGIONAL (EU or COUNTRY level) # Maar dit is dus de marginale impact per LnALVperHA? Alldata_Rainfed$MEts1 = CoefRainfed_ts1+2*CoefRainfed_ts1sq*Alldata_Rainfed$ts1 Alldata_Rainfed$MEts2 = CoefRainfed_ts2+2*CoefRainfed_ts2sq*Alldata_Rainfed$ts2 Alldata_Rainfed$MEts3 = CoefRainfed_ts3+2*CoefRainfed_ts3sq*Alldata_Rainfed$ts3 Alldata_Rainfed$MEts4 = CoefRainfed_ts4+2*CoefRainfed_ts4sq*Alldata_Rainfed$ts4 Alldata_Rainfed$MEt = Alldata_Rainfed$MEts1 + Alldata_Rainfed$MEts2 + Alldata_Rainfed$MEts3 + Alldata_Rainfed$MEts4 Alldata_Rainfed$MEps1 = CoefRainfed_ps1+2*CoefRainfed_ps1sq*Alldata_Rainfed$ps1 Alldata_Rainfed$MEps2 = CoefRainfed_ps2+2*CoefRainfed_ps2sq*Alldata_Rainfed$ps2 Alldata_Rainfed$MEps3 = CoefRainfed_ps3+2*CoefRainfed_ps3sq*Alldata_Rainfed$ps3 Alldata_Rainfed$MEps4 = CoefRainfed_ps4+2*CoefRainfed_ps4sq*Alldata_Rainfed$ps4 Alldata_Rainfed$MEp = Alldata_Rainfed$MEps1 + Alldata_Rainfed$MEps2 + Alldata_Rainfed$MEps3 + Alldata_Rainfed$MEps4 Alldata_Rainfed$weight2-Alldata_Rainfed$b48+Alldata_Rainfed$b50 attach(Alldata_Rainfed) library(stats) MEt_Rainfed-weighted.mean(MEt,weight2) MEp_Rainfed-weighted.mean(MEp,weight2) attach(Alldata_Irrigation) OLS_Irrigation - lm(LnALVperHA~ps1+ps2+ps3+ps4+ts1+ts2+ts3+ts4+ ps1sq+ps2sq+ps3sq+ps4sq+ts1sq+ts2sq+ts3sq+ts4sq+
Re: [R] R map data for South Africa
On Aug 14, 2015, at 9:45 AM, jgui001 wrote: I am looking for some elevation data to map in R for Cape Town, South Africa. Can it be found in any packages or R data bases? R has a well developed set of packages for geospatial analysis as well as an active mailing list, R-SIG-GEO. I suggest that you first do a google-search with terms: shape file elevation map cape town south africa After you have put some search time into this, you will be in a better position to ask for help on the correct mailing list. I do not know if that mailing list is mirrored on Nabble. Generally it is recommended that you subscribe to R support mailing lists rather than use Nabble. R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] System exactly singular with pgmm (package plm)
his is my first post, I'll do my best to be clear and complete. I am trying to run a pgmm regression (Arellano Bond estimator) following the example online with the EmplUK dataset. My dataset is unbalanced, with some missing values (that I also removed, without any difference). This is the paste from R' dataframe. row.names ID Yearp I 1 23 1 1992NA NA 2 22 1 199317.01 NA 3 21 1 199415.86 NA 4 20 1 199517.02 7.512347 5 19 1 199620.64 7.685104 6 18 1 199719.11 12.730282 7 17 1 199812.76 12.633871 8 16 1 199917.90 7.416381 9 15 1 200028.66 6.396114 10 14 1 200124.46 9.213729 11 13 1 200224.99 20.117159 12 12 1 200328.85 11.117816 13 11 1 200438.26 11.242638 14 10 1 200554.57 13.015168 15 9 1 200665.16 18.507212 16 8 1 200772.44 18.875281 17 7 1 200896.94 24.459170 18 6 1 200961.74 21.332035 19 5 1 201079.61 17.119038 20 4 1 2011111.26 16.941914 21 3 1 2012111.63 19.964875 22 2 1 2013108.56 28.863894 23 1 1 201499.03 15.182615 24 45 2 199317.01 NA 25 44 2 199415.86 NA 26 43 2 199517.02 NA 27 42 2 199620.64 NA 28 41 2 199719.11 NA 29 40 2 199812.76 NA 30 39 2 199917.90 11.428262 31 38 2 200028.66 20.232613 32 37 2 200124.46 25.811754 33 36 2 200224.99 18.959958 34 35 2 200328.85 20.767074 35 34 2 200438.26 29.260406 36 33 2 200554.57 25.837434 37 32 2 200665.16 32.675618 38 31 2 200772.44 48.415190 39 30 2 200896.94 42.35 40 29 2 200961.74 40.047462 41 28 2 201079.61 49.090816 42 27 2 2011111.26 53.828050 43 26 2 2012111.63 61.684020 44 25 2 2013108.56 68.394140 45 24 2 201499.03 55.738584 46 76 3 1984NA NA 47 75 3 1985NA NA 48 74 3 1986NA NA 49 73 3 198718.53 NA 50 72 3 198814.91 NA 51 71 3 198918.23 NA 52 70 3 199023.76 17.046268 53 69 3 199120.04 30.191128 54 68 3 199219.32 30.414108 55 67 3 199317.01 27.916000 56 66 3 199415.86 26.437651 57 65 3 199517.02 25.895513 58 64 3 199620.64 26.791996 59 63 3 199719.11 30.074375 60 62 3 199812.76 42.636103 61 61 3 199917.90 46.862510 62 60 3 200028.66 30.154079 63 59 3 200124.46 30.297644 64 58 3 200224.99 34.851205 65 57 3 200328.85 38.854943 66 56 3 200438.26 37.542447 67 55 3 200554.57 38.456399 68 54 3 200665.16 43.465535 69 53 3 200772.44 41.749414 70 52 3 200896.94 48.371262 71 51 3 200961.74 54.914470 72 50 3 201079.61 65.444964 73 49 3 2011111.26 76.888119 74 48 3 2012111.63 81.833602 75 47 3 2013108.56 83.800483 76 46 3 201499.03 79.713947 my codes are the following: data - plm.data(Autoregression,index=c(ID,Year)) Panel - subset(data, !is.na(I) ) Are - pgmm( I~p+lag( I , 0:1) | lag(I, 2:99), data = Panel, effect = twoways, model = onestep) I have tried also many other versions, including every possible number of the lags, shorter or longer. The error is the following : Errore in solve.default(crossprod(WX, t(crossprod(WX, A1 : Lapack routine dgesv: system is exactly singular: U[3,3] = 0 Inoltre: Warning message: In pgmm(I ~ lag(I, 1) + p | lag(I, 2:10), Panel, effect = twoways, : the first-step matrix is singular, a general inverse is used Can you please help me? Thanks for the attention, i'll wait for an answer Regards, Luca. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Notched boxplot using R
Instead of boxes use boxplot () then these values will be disappear -- View this message in context: http://r.789695.n4.nabble.com/Notched-boxplot-using-R-tp4710930p472.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Jaccard index
sreenath sreenath.rajur at macfast.ac.in writes: sim(file_name,method=jaccard) this command is giving the raw wise similarity matrix how can i find column wise similarity matrix? what is the command? please help me Based on a search library(sos); findFn(jaccard sim) I'm guessing that you're using the simba package (which you really should have said in your message ...). In general transposing the matrix sim(t(file_name),method=jaccard) should work. If you have ecology-related questions you might want to check out the r-sig-ecol...@r-project.org mailing list ... __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme4 package installation
Thanks Uwe Ligges for the suggestion. I tried using setInternet2() but also failed. I tried for several other countries but also failed. Any other suggestion to overcome it. Thanks. Warning: unable to access index for repository http://cran.utstat.utoronto.ca/src/contrib Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib Warning: unable to access index for repository http://cran.utstat.utoronto.ca/bin/windows/contrib/3.2 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2 On Fri, Aug 14, 2015 at 1:29 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 13.08.2015 22:52, Teck Kiang Tan wrote: Hi all I have problem in installation lme4 and have tried over the past 2 days. It failed to install from the various countries. install.packages(lme4) Warning: unable to access index for repository http://cran.stat.nus.edu.sg/src/contrib This mirror does not respond whn I just tried, choose another one. Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib This one works for me (but does not contain lme4). Perhaps also run setInternet2() before you try again in cae you need proxy settings. Best, Uwe Ligges Warning: unable to access index for repository http://cran.stat.nus.edu.sg/bin/windows/contrib/3.2 Warning message: package ‘lme4’ is not available (for R version 3.2.1) Teck Kiang On Thu, Aug 13, 2015 at 11:09 PM, Thierry Onkelinx thierry.onkel...@inbo.be wrote: Have you trying installing it directly from CRAN? install.packages(lme4) Do you have all dependencies installed? install.packages() from CRAN will take care of that. You repos = NULL you have to install all dependencies manually. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-13 16:13 GMT+02:00 aurora.gonza...@openmailbox.org: Hello I've downloaded the tar.gz file of the package lme4 and when I use the coomand: install.packages(lme4_1.1-8.tar.gz, repos = NULL, type = source) appears an error that suspends the installation: In file included from external.cpp:8:0: predModule.h:12:23: fatal error: RcppEigen.h: No such file or directory compilation terminated. make: *** [external.o] Error 1 ERROR: compilation failed for package ‘lme4’ * removing ‘/home/aurora/R/x86_64-pc-linux-gnu-library/3.2/lme4’ Does anyone know how to fix it? Thank you very much! My sessionInfo: R version 3.2.1 (2015-06-18) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu precise (12.04.5 LTS) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods [7] base loaded via a namespace (and not attached): [1] tools_3.2.1 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and
[R] Jaccard index
sim(file_name,method=jaccard) this command is giving the raw wise similarity matrix how can i find column wise similarity matrix? what is the command? please help me -- View this message in context: http://r.789695.n4.nabble.com/Jaccard-index-tp471.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R map data for South Africa
I am looking for some elevation data to map in R for Cape Town, South Africa. Can it be found in any packages or R data bases? Cheers - Josh -- View this message in context: http://r.789695.n4.nabble.com/R-map-data-for-South-Africa-tp4711123.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R map data for South Africa
See ?raster::getData for the SRTM option. Hth On Saturday, August 15, 2015, jgui001 j.guilb...@auckland.ac.nz wrote: I am looking for some elevation data to map in R for Cape Town, South Africa. Can it be found in any packages or R data bases? Cheers - Josh -- View this message in context: http://r.789695.n4.nabble.com/R-map-data-for-South-Africa-tp4711123.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsum...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help
Dear everyone, Would like to know how to add asterisks and arcs that indicate a subgroup comparison above box plots to denote statistical diference. Thank you. Andre [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cut variable within a loop
Hi Thierry and Petr, I really appreciate the comments you already gave. Thank you very much for that. Below you can find a link to the data and the code. Hopefully this helps in spotting the error. I still think the issue is that the cut2 function only accepts numbers, and not an i that refers to the number at the start of the loop. To answer Petr his question, yes, column 3 and 4 are NA (these are the columns of the second interval). But I don't really understand your point so could you clarify this please? https://drive.google.com/folderview?id=0By9u5m3kxn9yfkxxeVNMdnRQQXhoT05CRlJlZVBCWWF2NURMMTNmVFVFeXJXXzhlMWE4SUkusp=sharing Thank you very much once again! Janka 2015-08-11 15:10 GMT+02:00 Thierry Onkelinx thierry.onkel...@inbo.be: You'll need to send a reproducible example of the code. We can't run the code that you send. Hence it is hard to help you. See e.g. http://adv-r.had.co.nz/Reproducibility.html ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-11 14:57 GMT+02:00 Janka Vanschoenwinkel janka.vanschoenwin...@uhasselt.be: Hi Thierry! Thanks for your answer. I tried this, but I get this error: Error in cut.default(x, k2) : invalid number of intervals Which is strange because I am not specifying intervals, but the number at where the sample has to be cut? Greetings from Belgium! :-) 2015-08-11 14:52 GMT+02:00 Thierry Onkelinx thierry.onkel...@inbo.be: Dear Janka, You loop goes for 0 to 100. It should probably go from 1:99 Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-11 14:38 GMT+02:00 Janka Vanschoenwinkel janka.vanschoenwin...@uhasselt.be: Dear list members, I have a loop where I want to do several calculations for different samples and save the results for each sample. These samples are for each loop different. I want to use the i in the loop to cut the samples. So for instance: - In loop 1 (i=1), I have a sample from 0-1 and a sample from 1-100. - In loop 2 (i=2), I have a sample from 0-2 and a sample from 2-100. - In loop 99 (i=99), I have a sample from 0-99 and a sample from 99-100. I built the following function, but there is *a problem with the cut2 function* since it doesn't recognize the i. Outside the lapply loop it works, but not inside the loop. Could somebody please help me with this problem? Thanks a lot! d=data.frame(MEt_Rainfed=rep(0,100),MEp_Rainfed=rep(0,100),MEt_Irrigation=rep(0,100),MEp_Irrigation=rep(0,100)) o-lapply(0:100, function(i){ Alldata$irri=cut2(Alldata$irrigation,i) levels(Alldata$irri)-c(0,1) Alldata_Rainfed-subset(Alldata, irri == 0) Alldata_Irrigation-subset(Alldata, irri == 1) #calculations per sample, then store all the values per i and per variable in a dataframe: (the calculations are not shown in this example) d[i, ] = c(MEt_Rainfed,MEp_Rainfed,MEt_Irrigation,MEp_Irrigation) }) out-as.data.frame(do.call(rbind, o)) -- P Please consider the environment before printing this e-mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- [image: Logo UHasselt]Mevrouw Janka Vanschoenwinkel *Doctoraatsbursaal - PhD * Milieueconomie - Environmental economics T +32(0)11 26 87 42 | GSM +32(0)476 28 21 40 www.uhasselt.be/eec Universiteit Hasselt | Campus Diepenbeek Agoralaan Gebouw D | B-3590 Diepenbeek Kantoor F11 Postadres: Universiteit Hasselt | Martelarenlaan 42 | B-3500 Hasselt P Please
[R] R 3.2.2 is released
The build system rolled up R-3.2.2.tar.gz (codename Fire Safety) this morning. The list below details the changes in this release. The main point of this release is to enable package installation via secure HTTP, since ordinary HTTP is increasingly being considered a security risk. You can get the source code from http://cran.r-project.org/src/base/R-3/R-3.2.2.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course. For the R Core Team, Peter Dalgaard These are the md5sums for the freshly created files, in case you wish to check that they are uncorrupted: MD5 (AUTHORS) = eb97a5cd38acb1cfc6408988bffef765 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343 MD5 (FAQ) = e74e64dde0f92181957d46a0f8538e8b MD5 (INSTALL) = 3964b9119adeaab9ceb633773fc94aac MD5 (NEWS) = 5ff829377f0de5cdb0ad30bb42977611 MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8 MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801 MD5 (NEWS.2) = 8e2f4d1d5228663ae598a09bf1e2bc6b MD5 (R-latest.tar.gz) = 57cef5c2e210a5454da1979562a10e5b MD5 (README) = aece1dfbd18c1760128c3787f5456af6 MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435 MD5 (THANKS) = ba00f6cc68a823e1741cfa6011f40ccb MD5 (VERSION-INFO.dcf) = 55826f7f976cd9623577e5a9ac694c47 MD5 (R-3/R-3.2.2.tar.gz) = 57cef5c2e210a5454da1979562a10e5b This is the relevant part of the NEWS file CHANGES IN R 3.2.2: SIGNIFICANT USER-VISIBLE CHANGES: * It is now easier to use secure downloads from https:// URLs on builds which support them: no longer do non-default options need to be selected to do so. In particular, packages can be installed from repositories which offer https:// URLs, and those listed by setRepositories() now do so (for some of their mirrors). Support for https:// URLs is available on Windows, and on other platforms if support for libcurl was compiled in and if that supports the https protocol (system installations can be expected to do). So https:// support can be expected except on rather old OSes (an example being OS X 'Snow Leopard', where a non-system version of libcurl can be used). (Windows only) The default method for accessing URLs _via_ download.file() and url() has been changed to be wininet using Windows API calls. This changes the way proxies need to be set and security settings made: there have been some reports of sites being inaccessible under the new default method (but the previous methods remain available). NEW FEATURES: * cmdscale() gets new option list. for increased flexibility when a list should be returned. * configure now supports texinfo version 6.0, which (unlike the change from 4.x to 5.0) is a minor update. (Wish of PR#16456.) * (Non-Windows only) download.file() with default method = auto now chooses libcurl if that is available and a https:// or ftps:// URL is used. * (Windows only) setInternet2(TRUE) is now the default. The command-line option --internet2 and environment variable R_WIN_INTERNET2 are now ignored. Thus by default the internal method for download.file() and url() uses the wininet method: to revert to the previous default use setInternet2(FALSE). This means that https:// can be read by default by download.file() (they have been readable by file() and url() since R 3.2.0). There are implications for how proxies need to be set (see ?download.file): also, cacheOK = FALSE is not supported. * chooseCRANmirror() and chooseBioCmirror() now offer HTTPS mirrors in preference to HTTP mirrors. This changes the interpretation of their ind arguments: see their help pages. * capture.output() gets optional arguments type and split to pass to sink(), and hence can be used to capture messages. C-LEVEL FACILITIES: * Header Rconfig.h now defines HAVE_ALLOCA_H if the platform has the alloca.h header (it is needed to define alloca on Solaris and AIX, at least: see 'Writing R Extensions' for how to use it). INSTALLATION and INCLUDED SOFTWARE: * The libtool script generated by configure has been modified to support FreeBSD = 10 (PR#16410). BUG FIXES: * The HTML help page links to demo code failed due to a change in R 3.2.0. (PR#16432) * If the na.action argument was used in model.frame(), the original data could be modified. (PR#16436) * getGraphicsEvent() could cause a crash if a graphics window was closed while it was in use. (PR#16438) * matrix(x, nr, nc, byrow = TRUE) failed if x was an object of type expression. * strptime() could overflow the allocated storage on the C stack when the timezone had a non-standard format much longer than the standard formats. (Part of PR#16328.) *
Re: [R] cut variable within a loop
Hi Didn't you by chance use plain cut and k2 was NA? cut(1:300, NA) Error in cut.default(1:300, NA) : invalid number of intervals Cheers Petr -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Janka Vanschoenwinkel Sent: Friday, August 14, 2015 10:16 AM To: Michael Dewey Cc: r-help@r-project.org Subject: Re: [R] cut variable within a loop Hey Michael, Sorry for the late reply! Thanks for your comment, but for the cut2 command, this is not the case. If I enter for instance Alldata$irri=cut2(irrigation,3) Then I get 2 intervals from 0-3 and from 3-100. Janka 2015-08-11 17:25 GMT+02:00 Michael Dewey li...@dewey.myzen.co.uk: Dear Janka If you supply a single number to the breaks parameter of cut I think it is the number of intervals. On 11/08/2015 13:57, Janka Vanschoenwinkel wrote: Hi Thierry! Thanks for your answer. I tried this, but I get this error: Error in cut.default(x, k2) : invalid number of intervals Which is strange because I am not specifying intervals, but the number at where the sample has to be cut? Greetings from Belgium! :-) 2015-08-11 14:52 GMT+02:00 Thierry Onkelinx thierry.onkel...@inbo.be: Dear Janka, You loop goes for 0 to 100. It should probably go from 1:99 Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-11 14:38 GMT+02:00 Janka Vanschoenwinkel janka.vanschoenwin...@uhasselt.be: Dear list members, I have a loop where I want to do several calculations for different samples and save the results for each sample. These samples are for each loop different. I want to use the i in the loop to cut the samples. So for instance: - In loop 1 (i=1), I have a sample from 0-1 and a sample from 1-100. - In loop 2 (i=2), I have a sample from 0-2 and a sample from 2-100. - In loop 99 (i=99), I have a sample from 0-99 and a sample from 99-100. I built the following function, but there is *a problem with the cut2 function* since it doesn't recognize the i. Outside the lapply loop it works, but not inside the loop. Could somebody please help me with this problem? Thanks a lot! d=data.frame(MEt_Rainfed=rep(0,100),MEp_Rainfed=rep(0,100),MEt_Irri gation=rep(0,100),MEp_Irrigation=rep(0,100)) o-lapply(0:100, function(i){ Alldata$irri=cut2(Alldata$irrigation,i) levels(Alldata$irri)-c(0,1) Alldata_Rainfed-subset(Alldata, irri == 0) Alldata_Irrigation-subset(Alldata, irri == 1) #calculations per sample, then store all the values per i and per variable in a dataframe: (the calculations are not shown in this example) d[i, ] = c(MEt_Rainfed,MEp_Rainfed,MEt_Irrigation,MEp_Irrigation) }) out-as.data.frame(do.call(rbind, o)) -- P Please consider the environment before printing this e-mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael http://www.dewey.myzen.co.uk/home.html -- [image: Logo UHasselt]Mevrouw Janka Vanschoenwinkel *Doctoraatsbursaal - PhD * Milieueconomie - Environmental economics T +32(0)11 26 87 42 | GSM +32(0)476 28 21 40 www.uhasselt.be/eec Universiteit Hasselt | Campus Diepenbeek Agoralaan Gebouw D | B-3590 Diepenbeek Kantoor F11 Postadres: Universiteit Hasselt | Martelarenlaan 42 | B-3500 Hasselt P Please consider the environment before printing this e-mail [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem,