Re: [R] [R-sig-Geo] raster::levels() not working in packaged function.
Maybe including import(raster) or importFrom("raster", "levels") in the package NAMESPACE would help. Cheers, Marcelino El 31/10/2020 a las 13:24, nevil amos escribió: Apologies, I cannot see how to make a rero for this issue. I have a function that uses levels(r) tor return the RAT of a raster "r" when the function is sourced from a script source(".\R\function.r") it works fine. when the function is built into a package and sourced from there library(mypackage) using the same script file to make the package levels(r)[[1]] the same line throws an error, as levels(myraster returns NULL If I modify the script to include the raster namespace: raster::levels(r)[[1]] Then I get the error Error: 'levels<-' is not an exported object from 'namespace:raster' I have also tried just using levels(r) and putting raster as a depends rather than an import in the DESCRIPTION file for the package, this does not solve the error. Any suggestions on how to overcome the problem? many thanks Nevil Amos [[alternative HTML version deleted]] ___ R-sig-Geo mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo . -- Marcelino de la Cruz Rot Depto. de Biología y Geología Física y Química Inorgánica Universidad Rey Juan Carlos Móstoles España __ 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] Re : Privacy rights of an old user of this list
Dear all, I will express my opinion without knowing the details of the posts John would like to be removed. In the current state, people posting on this and other servers have no clear way to go when trying to remove their posts. It is a likely event that the number of people attempting the removal of their past posts will increase. Their reasons will vary and may or not may be reasonable to us. It seems that a discussion on how the R-server will handle this likely situation is needed (including the possibility of keeping the current policy, of course) Once the decision has been taken, a warning note would be helpful for newcomers (something in big, black letters saying that whatever we post will not be removed or something like that). Best regards to all, adan From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of John Gonzalez [john.gonza...@gmx.fr] Sent: Monday, September 16, 2013 5:14 PM To: David Winsemius; Albin Blaschka; Duncan Murdoch; Jeff Newmiller; S Ellison; Jim Lemon Cc: r-help@r-project.org Subject: [R] Re : Privacy rights of an old user of this list I would like to thank David for letting me publish this and discuss it openly. I must acknowledge from the answers that I received to my post, that the administrators of this list are doing what seems to be fair to me: what most people demand or understand that is right. However I don't share your views and I honestly think you are making a mistake which may hurt you just as much as it is hurting me now) in the long term. Let me develop my point. First of all let me clarify for those who accuse me of being desinformed or innocent about my request, I'm not asking for your collaboration to remove what I published from the internet, its google records or any of the infinite copies that may be lying around. I'm asking for a very simple thing: There are 7 messages (sorry it wasn't 3...) written by me and hosted at the server stat.ethz.ch https://stat.ethz.ch/pipermail/r-help/2009-March/190367.html which I would like to have removed. Now, Steve E makes a good point: "I am also of the opinion that the list owner was not showing disrespect by describing the state of affairs you agreed to on signing up, or by declining to act beyond the requirements of the conditions applicable to the list. " Steve Fair enough. But that doesn't mean that those conditions are right and should never be modified. I'm probably something similar to an unhappy customer who has bought a product with no money-back policy but with an important distinction: I'm going to be wearing this product for the rest of my life. So that makes me, if anything, a "very unhappy customer". Now let me explain why in this world I'm spending time on requesting the removal of these 7 messages in that server. I have a MS in Computer Science and a 5 years long Telecommunications degree, I know quite well how the internet works. This is not the first time that I request this. I already requested it in another mailing list, where they were kind enough to aprove it after I verified my identity and they checked that they weren't removing anything critical. The result was that that piece information was obviously not erased from the entire internet but was not showing up in the first 12 pages of google when you would look up my name (when it was on the first page previously). It took me 5 requests to different servers but I managed. There is nothing impossible about it and it made a difference in my life. So why is this important for me (something like not showing up on the first pages of google?). Well please understand that there is a difference between publishing an article and writing an email to a list. An article goes through several personal revisions and is examined by a professional reviewer before it is published. It only takes a click to send an email. It is extremely easy to make mistakes (particularly when you are young and you know little about life). Actually, people make lots of mistakes and banks may use it to deny you or give you credit, employers to give you an opportunity or not, a lover to have more or less reasons to meet you etc etc etc. Removing this information from servers that are more visited by the search bot crawlers makes a difference: your banker will have to spend more time or resources to refuse your credit request, your lover may be already calling you for a date, your employer may be already calling your for an interview. Now, if you have a lifetime job, if you never want to change your career, if you will never need a credit, if you have a lovely, healthy and loyal wife, what I just wrote may sound meaningless but if anything happens to your life, you may end up remembering what I said and suffering like me. Why? Because you it is not possible to remove 7 messages from a server? OK, this is surely extra work that may be difficult to handle but
[R] SEM and count data
Hi all- New to R, and I've managed to learn a bit about Lavaan package for SEM, and pscl package for analyzing count data. I would like to find a way to combine these analyses as I am hoping to run a model with a multi-trait, multi-reporter factor (2 reporters by 4 traits apiece, with one overall factor to represent common variance) as a predictor, and predict (zero-inflated) count substance use outcomes. Do people have any suggestions for how to do this? It seems that Lavaan can't handle count data, and I don't know if there is a count data package that can handle SEM models. I'm thinking I may have to do a two-step process and run SEM package to get factor scores, and then put in as a predictor in count outcomes package. Thanks! Rick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Expected number of events, Andersen-Gill model fit via coxph in package survival
I have a follow-up question (for either Dr. Therneau, or anybody who might know). sum(zz) (see below) estimates the number of events for the cohort. Now, how can I compute a confidence interval for sum(zz)? Or a standard error? My obvious choice, square root of the sum of the squares of the standard errors for zz provided by predict.coxph, turns out to be too small. Thank you for any suggestions. Omar. On Thu, Oct 11, 2012 at 1:26 PM, Omar De la Cruz C. wrote: > Thank you, Dr. Therneau, that was very helpful. > > Best regards, > > Omar. > > > On Mon, Oct 8, 2012 at 9:58 AM, Terry Therneau wrote: >> >>> I am interested in producing the expected number of events, in a >>> recurring events setting. I am using the Andersen-Gill model, as fit >>> by the function "coxph" in the package "survival." >>> >>> I need to produce expected numbers of events for a cohort, >>> cumulatively, at several fixed times. My ultimate goal is: To fit an >>> AG model to a reference sample, then use that fitted model to generate >>> expected numbers of events for a new cohort; then, comparing the >>> expected vs. the observed numbers of events would give us some idea of >>> whether the new cohort differs from the reference one. >>> >>>> From my reading of the documentation and the text by Therneau and >>> >>> Grambsch, it seems that the function "survexp" is what I need. But >>> using it I am not able to obtain expected numbers of events that match >>> reasonably well the observed numbers *even for the same reference >>> population.* So, I think I am misunderstanding something quite badly. >>> >> >> You've hit a common confusion. Observed versus expected events >> computations are done on a cumulative hazard scale H, not the surivival >> scale S; S = exp(-H). Relating this back to simple Poisson models H(t) >> would be the expected number of events by time t and S(t) the probability of >> "no events before time t". G. Berry (Biometrics 1983) has a classic ane >> readable article on this (especially if you ignore the proofs). >> >> Using your example: >> >>> cphfit <- >>> coxph(Surv(start,stop,event)~rx+number+size+cluster(id),data=bladder2) >>> zz <- predict(cphfit, type='expected') >>> c(sum(zz), sum(bladder2$event)) >> [1] 112 112 >> >>> tdata <- bladder2[1:10] #new data set (lazy way) >>> predict(cphfit, type='expected', newdata=tdata) >> [1] 0.0324089 0.3226540 0.4213402 1.0560768 0.6702130 0.2163531 0.6490665 >> [8] 0.8864808 0.2932915 0.5190647 >> >> >> You can also do this using survexp and the cohort=FALSE argument, which >> would return S(t) for each subject and we would then use -log(result) to get >> H. This is how it was done when I wrote the book, but the newer predict >> function is easier. >> >> Terry Therneau >> >> __ R-help@r-project.org mailing list 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] Expected number of events, Andersen-Gill model fit via coxph in package survival
Thank you, Dr. Therneau, that was very helpful. Best regards, Omar. On Mon, Oct 8, 2012 at 9:58 AM, Terry Therneau wrote: > >> I am interested in producing the expected number of events, in a >> recurring events setting. I am using the Andersen-Gill model, as fit >> by the function "coxph" in the package "survival." >> >> I need to produce expected numbers of events for a cohort, >> cumulatively, at several fixed times. My ultimate goal is: To fit an >> AG model to a reference sample, then use that fitted model to generate >> expected numbers of events for a new cohort; then, comparing the >> expected vs. the observed numbers of events would give us some idea of >> whether the new cohort differs from the reference one. >> >>> From my reading of the documentation and the text by Therneau and >> >> Grambsch, it seems that the function "survexp" is what I need. But >> using it I am not able to obtain expected numbers of events that match >> reasonably well the observed numbers *even for the same reference >> population.* So, I think I am misunderstanding something quite badly. >> > > You've hit a common confusion. Observed versus expected events > computations are done on a cumulative hazard scale H, not the surivival > scale S; S = exp(-H). Relating this back to simple Poisson models H(t) > would be the expected number of events by time t and S(t) the probability of > "no events before time t". G. Berry (Biometrics 1983) has a classic ane > readable article on this (especially if you ignore the proofs). > > Using your example: > >> cphfit <- >> coxph(Surv(start,stop,event)~rx+number+size+cluster(id),data=bladder2) >> zz <- predict(cphfit, type='expected') >> c(sum(zz), sum(bladder2$event)) > [1] 112 112 > >> tdata <- bladder2[1:10] #new data set (lazy way) >> predict(cphfit, type='expected', newdata=tdata) > [1] 0.0324089 0.3226540 0.4213402 1.0560768 0.6702130 0.2163531 0.6490665 > [8] 0.8864808 0.2932915 0.5190647 > > > You can also do this using survexp and the cohort=FALSE argument, which > would return S(t) for each subject and we would then use -log(result) to get > H. This is how it was done when I wrote the book, but the newer predict > function is easier. > > Terry Therneau > > __ R-help@r-project.org mailing list 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] Expected number of events, Andersen-Gill model fit via coxph in package survival
Hello, I am interested in producing the expected number of events, in a recurring events setting. I am using the Andersen-Gill model, as fit by the function "coxph" in the package "survival." I need to produce expected numbers of events for a cohort, cumulatively, at several fixed times. My ultimate goal is: To fit an AG model to a reference sample, then use that fitted model to generate expected numbers of events for a new cohort; then, comparing the expected vs. the observed numbers of events would give us some idea of whether the new cohort differs from the reference one. >From my reading of the documentation and the text by Therneau and Grambsch, it seems that the function "survexp" is what I need. But using it I am not able to obtain expected numbers of events that match reasonably well the observed numbers *even for the same reference population.* So, I think I am misunderstanding something quite badly. Below is an example that illustrates the situation. At the end I include the sessionInfo(). Thank you! Omar. # Example of unexpected behavior in computing estimated number of events # in using package "survival" for fitting the Andersen-Gill model require(survival) head(bladder2) # this is the data, in interval format # Fit Andersen-Gill model cphfit = coxph(Surv(start,stop,event)~rx+number+size+cluster(id),data=bladder2) # Choose some arbitrary time horizons t.horiz = seq(min(bladder2$start),max(bladder2$stop),length=6) # Compute the cohort expected survival s = survexp(~1,data=bladder2,ratetable=cphfit,times=t.horiz) # This are the expected survival values: s$surv # We are interested in the rate of events e.r = as.vector( 1 - s$surv ) # How does this compare to the actual number of events, cumulative at # each time horizon? observed = numeric(length(t.horiz)) for (i in 1:length(t.horiz)){ observed[i] = sum(bladder2$event[bladder2$stop <= t.horiz[i]]) } print(observed) # We would like to compute expected numbers of events that approximately # match these observed values. # We should multiply the expected survival rates by the number of individuals. # Now, one would think that this is the number of at-risk individuals: s$n.risk # But that is actually the total number of rows in the data. In any case, # these numbers do not match: rbind(expected = s$n.risk*e.r,observed=observed) # What if we multiply by the number of individuals? rbind(expected = length(unique(bladder2$id))*e.r,observed=observed) # This does not work either! The required factor seems to be about 133, but # I don't see an explanation for that. # In this example, multiplying by 133.182 gives a good match between observed # and expected values, but in other examples even the shape of the curves # are different. # Multiplying by a number of individuals at risk at each time point # (number of individuals # for which there is a time interval containing the time horizon) does # not work either. # > sessionInfo() R version 2.15.1 (2012-06-22) Platform: i386-apple-darwin9.8.0/i386 (32-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] survival_2.36-14 loaded via a namespace (and not attached): [1] tools_2.15.1 __ R-help@r-project.org mailing list 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] Problems with plm's pgmm: changing results
Hello, I'm a newbie with R, and this is my first time to post here. Apologies in advanced if I should be posting my question on another list. I'm working on a problem on Arellano and Bond's GMM estimator, and I've chosen to use plm/pgmm. My issue is, I'm getting different results from pgmm() every time I run it. Here's my code: library(plm) mydata = read.csv('mydata.csv') ab = pgmm(formula = y ~ lag(y,1), data = mydata, gmm.inst=~lag(gmm_inst,1), effect = "individual", model="onestep") coef(ab) I noticed that every time I run the last 2 lines, I get different results after a few or so runs. Sometimes, I get an error, then in the next run, I get results. I can't figure this out, and I'm a bit desperate for a light at the end of the tunnel. I'm attaching the data file I'm using. It's a N=150, T=30 panel data with practically only one variable. Thank you very much! Rolan__ R-help@r-project.org mailing list 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] help with hclust
>From: Madeleine Seeland in.tum.de> >Subject: help with hclust >Date: 2011-09-14 08:14:48 GMT >Hello, > >I have two questions regarding hclust: > >1) First I would like to cut a hclust tree at a specific height and receive the cluster (di) similarity at this >height. With an example: hc <- hclust(dist(USArrests), "ave") plot(hc, hang = -1) hc.cf <- cophenetic(hc) #cophenetic distance # cut cluster at height=50 rect.hclust(hc, h = 50) hc.50 <- cutree(hc, h=50) hc.simi <- NULL for(i in unique(hc.50)) hc.simi <- c(hc.simi, max(as.matrix(hc.cf)[names(hc.50[hc.50==i]),names(hc.50[hc.50==i])])) hc.simi [1] 44.28392 44.83793 20.59851 38.52791 41.09477 >2) Next, I would like to receive all clusterings up to a given tree height that fulfill a minimal required >similarity (i.e., the inner cluster similarity of all clusters needs to fulfill a given similarity >value). How can I achieve that? For example, all clusterings with a (di)similarity at least 40 # which clusters have a maximum dissimilarity < 40 hc.le.40 <-unique(hc.50)[hc.simi<40] # clusterings up to a height of 40 hc.50[hc.50==hc.le.40[1]|hc.50==hc.le.40[2]] ConnecticutFlorida IdahoIndiana Kansas 3 4 3 3 3 KentuckyMontana Nebraska North Carolina Ohio 3 3 3 4 3 Pennsylvania Utah 3 3 HTH, MArcelino > >I would appreciate your help! > >Best regards, >Madeleine > Marcelino de la Cruz Rot Depto. Biologia Vegetal EUIT Agricola Universidad Politecnica de Madrid tel: 34 + 913365435 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] "useR! 2011" T-shirt competition
David Firth wrote: Dear R users: It is planned that participants in the R User Conference, useR! 2011 (August 16-18, http://R-project.org/useR-2011) will each receive a Better : http://www.R-project.org/useR-2011 __ R-help@r-project.org mailing list 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] How to extract information from the following dataset?
Xin Zhang wrote: Hi all, I have never worked with this kind of data before, so Please help me out with it. I have the following data set, in a csv file, looks like the following: Jan 27, 2010 16:01:24,000 125 - - - Jan 27, 2010 16:06:24,000 125 - - - Jan 27, 2010 16:11:24,000 176 - - - Jan 27, 2010 16:16:25,000 159 - - - Jan 27, 2010 16:21:25,000 142 - - - Jan 27, 2010 16:26:24,000 142 - - - Jan 27, 2010 16:31:24,000 125 - - - Jan 27, 2010 16:36:24,000 125 - - - Jan 27, 2010 16:41:24,000 125 - - - Jan 27, 2010 16:46:24,000 125 - - - Jan 27, 2010 16:51:24,000 125 - - - Jan 27, 2010 16:56:24,000 125 - - - Jan 27, 2010 17:01:24,000 157 - - - Jan 27, 2010 17:06:24,000 172 - - - Jan 27, 2010 17:11:25,000 142 - - - Jan 27, 2010 17:16:24,000 125 - - - Jan 27, 2010 17:21:24,000 125 - - - Jan 27, 2010 17:26:24,000 125 - - - Jan 27, 2010 17:31:24,000 125 - - - Jan 27, 2010 17:36:24,000 125 - - - Jan 27, 2010 17:41:24,000 125 - - - Jan 27, 2010 17:46:24,000 125 - - - Jan 27, 2010 17:51:24,000 125 - - - .. The first few columns are month, day, year, time with OS3 accuracy. And the last number is the measurement I need to extract. I wonder if there is a easy way to just take out the measurements only from a specific day and hour, i.e. if I want measurements from Jan 27 2010 16:--:-- then I get 125,125,176,159,142,142,125,125,125,125,125,125. Many thanks!! The easiest is in the shell, if you're using some flavour of unix : grep "Jan 27, 2010 16" filein.txt | awk '{print $5}' > fileout.txt and use fileout which will contain only the column of data you want. -- __ R-help@r-project.org mailing list 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] use of ROCR package (ROC curve / AUC value) in a specific case versus integral calculation
Christine SINOQUET wrote: Hello, I would like to use the ROCR package to draw ROC curves and compute AUC values. However, in the specific context of my application, the true positive rates and false positive rates are already provided by some upstream method. Of course, I can draw a ROC plot with the following command : plot(x=FPrate, y=TPrate, "o", xlab="false positive rate", ylab="true positive rate", xlim=c(0, 1), ylim=c(0, 1) but this will bot compute the AUC value. There are two possibilities : Either it is possible to use the above parameters - FPrate and TPrate vectors- to run the performance function and I would like to know how, or it is not possible and I have to compute the area under the curve but I cannot find on the Web how to perform this, through an R package, using the two vectors above, if possible (I would rather not implement an integration algorithm). I thank you in advance for your answer. My answer doesn't use R... For some applications, when the classifier performance is quite good, integrating the ROC curve isn't a good idea, as the curve is very abrupt. Another approach is to use the fact that the (1-AUC) represents the probability of taking at random one positive and one negative event and don't geting them in the correct order (by their score). This is related to the Wilcoxon distribution. So, if you have a set of negative and positive events and the "scores" assigned to them, you can sort them by their scores and enumerate the number of couples out of order you can get. Hope this help. José-Marcio -- --- Jose Marcio MARTINS DA CRUZ http://j-chkmail.ensmp.fr Ecole des Mines de Paris 60, bd Saint Michel 75272 - PARIS CEDEX 06 mailto:jose-marcio.mart...@mines-paristech.fr __ R-help@r-project.org mailing list 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] calculate phase/amplitude of fourier transform function in R
sammyny wrote: I did a fourier transform on a function in time domain to get the following functions in frequency domain (in latex): $Y_1[\omega] = \frac{1}{1-\phi_1 e^{-jw}}$ $Y_2[\omega] = \frac{1}{1-(\phi_1 + \phi_2)e^{-jw} +\phi_1\phi_2e^{-2jw}}$ How do I find the spectrum of this function for given $\phi_1$ and $\phi_2$ coefficients and in the discretization interval $w = [-\pi:.1*\pi: \pi]$? Then, how do I find the 'magnitude' of spectrum and 'phase' of spectrum in R? Is there an existing package/function in R? An example would be very helpful. Take a look at fft - help(fft) - to know how to get the fourier transform and complex - help(complex) - to know how to get the magnitude and phase of complex values. Usually you'll find examples on help pages. __ R-help@r-project.org mailing list 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] Time unit in ts() and arima() functions
Thanks for the hint. Helped a lot Gabor Grothendieck wrote: On Sat, Feb 12, 2011 at 7:48 AM, Jose-Marcio Martins da Cruz Functions which work with ts typically assume that a full cycle is represented by 1 unit so if a full cycle is a week then a week must be one unit and a day must be 1/7th of a unit; however, you can later convert your series to a non-ts representation which supports dates. -- __ R-help@r-project.org mailing list 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] Time unit in ts() and arima() functions
This question is surely trivial, sorry. I'm afraid I'm misunterpreting the information I got with the documentation, and I'm a little bit confused. I'm just an engineer with some little skills in statistics. Well, I have a time series - 600 days long - with some weekly periodicity inside. So far, so good. Well, if I define the time series with, say : a <- ts(b, frequency = 7) and I do "plot(a)", each unit of time seems to be a week, not a day, which is coherent with help(ts) which says "frequency: the number of observations per unit of time." but this isn't what I want. I'd like to retrieve seasonal information but, as I'd like to retrieve also day to day information, the time unit should remain one "day". Also, when I use the "arima(...)" function to fit a model (almost the same kind of algorithm which appeared here some days ago), and I specify in the "seas=" parameter, "frequency = 7", or "frequency = frequency(a)" (a is the time series), I can get arN, maN, sarN, smaN... coefficients. What unit shall be applied to these coefficients ? One day or one week ? Logically (and ideally), for me, one day for arN and maN and one week for sarX and smaX coefficients, but I'm not sure. I have the same kind of doubt about lag units when I apply the acf() function to the time series (a) or the residuals returned by the arima() function. Thanks for your answer. __ R-help@r-project.org mailing list 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] predict and arima
bryan wrote: Indeed, there was a bug ... my current play code looks like this ... H the bug seems to be there, still. >fit<- arima(x.ts, order=c(p,q,d), * >seasonal=list(order=c(P,D,Q), >period=frequency(x.ts)), >method='CSS') P.S. - I'm trying to use this code, me too. Also based on the same source. But it doesn't seem to work with one of my series. get.best.arima<- function(x.ts, maxord=c(3,3,3,3)) { # function based on 'Introductory Time Series with R' # ... try and fit the best ARIMA(p,d,q,P,D,Q) model # using all permutations from 0 to maxord for p,q,P,Q # Assume D=1 and select d using ndiffs and the KPSS test # for stationarity. # ... if no model can be found - return NULL -- --- Jose Marcio MARTINS DA CRUZ http://j-chkmail.ensmp.fr Ecole des Mines de Paris 60, bd Saint Michel 75272 - PARIS CEDEX 06 mailto:jose-marcio.mart...@mines-paristech.fr __ R-help@r-project.org mailing list 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] predict and arima
I think ther's a bug here : bdp wrote: Some code I have been playing with to do this follows ... get.best.arima<- function(x.ts, minord=c(0,0,0,0,0,0), maxord=c(2,1,1,2,1,1)) { # function based on 'Introductory Time Series with R' best.aic<- 1e8 # a big number n<- length(x.ts) for(p in minord[1]:maxord[1]) for(d in minord[2]:maxord[2]) for(q in minord[3]:maxord[3]) { for(P in minord[4]:maxord[4]) for(D in minord[5]:maxord[5]) for(Q in minord[6]:maxord[6]) { fit<- arima(x.ts, order=c(p,q,d), seas=list(order=c(P,D,Q), maybe it should be : fit<- arima(x.ts, order=c(p,d,q), seas=list(order=c(P,D,Q), exchange q and d ! frequency(x.ts)), method='CSS') fit.aic<- -2 * fit$loglik + (log(n) + 1) * length(fit$coef) if(fit.aic< best.aic) # probably should do other tests here before accepting { best.aic<- fit.aic best.fit<- fit best.model<- c(p,d,q,P,D,Q) } } } #print(best.aic) #print(best.model) return(best.fit) } ... __ R-help@r-project.org mailing list 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] Cross validation for Ordinary Kriging
ear ALL, The last part of my thesis analysis is the cross validation. Right now I am having difficulty using the cross validation of gstat. Below are my commands with the tsport_ace as the variable: nfold <- 3 part <- sample(1:nfold, 69, replace = TRUE) sel <- (part != 1) m.model <- x2[sel, ] m.valid <- x2[-sel, ] t<- fit.variogram(v,vgm(0.0437, "Exp", 26, 0)) cv69 <- krige.cv(tsport_ace ~ 1, x2, t, nfold = nrow(x2)) The last line gives an error saying: Error in SpatialPointsDataFrame(coordinates(data), data.frame(matrix(as.numeric(NA), : row.names of data and coords do not match I don't know what is wrong. The x2 data is a SpatialPointsdataframe that is why i did not specify the location (as it will take it from the data). Here is the usage of the function krige.cv: krige.cv(formula, locations, data, model = NULL, beta = NULL, nmax = Inf, nmin = 0, maxdist = Inf, nfold = nrow(data), verbose = TRUE, ...) I hope you can help me on this. Thanks a lot. Best regards, Pearl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Prediction error for Ordinary Kriging
Hi ALL, Can you please help me on how to determine the prediction error for ordinary kriging?Below are all the commands i used to generate the OK plot: rsa2 <- readShapeSpatial("residentialsa", CRS("+proj=tmerc +lat_0=39.66 +lon_0=-8.1319062 +k=1 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs")) x2 <- readShapeSpatial("ptna2", CRS("+proj=tmerc +lat_0=39.66 +lon_0=-8.1319062 +k=1 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs")) bb <- bbox(rsa2) cs <- c(1, 1) cc <- bb[, 1] + (cs/2) cd <- ceiling(diff(t(bb))/cs) rsa2_grd <- GridTopology(cellcentre.offset = cc,cellsize = cs, cells.dim = cd) getClass("SpatialGrid") p4s <- CRS(proj4string(rsa2)) x2_SG <- SpatialGrid(rsa2_grd, proj4string = p4s) x2_SP <- SpatialPoints(cbind(x2$X, x2$Y)) v <- variogram(log1p(tsport_ace) ~ 1, x2, cutoff=100, width=9) te<- fit.variogram(v,vgm(0.0437, "Exp", 26, 0)) y <- krige(tsport_ace~1, x2, x2_SG, model = ve.fit) spplot(y, 1, col.regions = bpy.colors(100), sp.layout = list("sp.lines",as(rsa2, "SpatialLines"),no.clip = TRUE)) I'm looking forward to your response. Thanks. Best regards, Pearl dela Cruz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Convert tileplot's trellis to shapefile/ Add values to voronoi polygon
I would like to create a voronoi map that can show me point values like the ones in colum street_cle. I was able to do it in tileplot(latticeExtra) like the ones attached, and with the following commands: xy=list(x=x2$X, y=x2$Y) xy$street_cle <- x2$street_cle tileplot(street_cle~ x*y, xy) But this is a trellis. Is it possible to be converted to a shapefile or image so I can plot it using spplot. I tried the following under tripack: > tritest.vm <- voronoi.mosaic(x2$X,x2$Y) > x2.vm <- voronoi.mosaic(x2$X,x2$Y) > plot(x2.vm) > x2.vp <- voronoi.polygons(x2.vm) > plot(x2.vp) The mosaic is fine but when I made it to voronoi polygon, it gives me a weird plot just like the ones attached in this message. To add, this functions only plot the coordinates and does not have an option to add other values just like tileplot did in the street_cle column. In any way, can you help me on either converting tileplot's trellis to shapefile/image or (solving the problem of voronoi polygons and adding another column to represent the polygons in tripack). Thanks a lot in advance, Pearl dela Cruz __ R-help@r-project.org mailing list 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] Unable to load an object
R-help, I seem not to get an object saved neither with ".RData" extension nor output via dput. Whenever I try to import the above object in another worspace I just get nothing. > geoFeatures <- load("geoFeatures.RData") > geoFeatures [1] "geoFeatures" The "geoFeatures.RData" workspace contains an object list called "geoFeatures" Thanks in advance > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 11.1 year 2010 month 05 day31 svn rev52157 language R version.string R version 2.11.1 (2010-05-31) __ R-help@r-project.org mailing list 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] Sort a data frame according to romans
R-help, I have a data frame: > mydata strata nh NhWhfh 1 I 10 26 0.048 0.385 2 II 32 84 0.154 0.381 3 III 16 42 0.077 0.381 4 IV 4 11 0.020 0.364 5 V 10 26 0.048 0.385 7 VII 64 168 0.309 0.381 8VIII 49 129 0.237 0.380 9 IX 22 58 0.107 0.379 91 VI 0 0 0.000 0.000 and I wish to rearrange the data are sorted according to the roman (first column): I,II,III,IV,V,VI,VII,VIII,IX Thanks in advance __ R-help@r-project.org mailing list 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] could not find function lapply<-
R-help, I have a list whose elements are data frames. I want to change the colnames attribute in each element of this list but an error message comes up: > lapply(LD_strataNew,function(x) dimnames(x)[[2]][-1]) <- as.roman(1:9)[-6] Error in lapply(LD_strataNew, function(x) dimnames(x)[[2]][-1]) <- as.roman(1:9)[-6] : could not find function "lapply<-" > lapply(LD_strataNew,function(x) dimnames(x)[[2]]) $`1996` [1] "lgdcm" "X1""X2""X3""X4""X5""X7""X8""X9" $`1997` [1] "lgdcm" "X1""X2""X3""X4""X5""X7""X8""X9" $`1998` [1] "lgdcm" "X1""X2""X3""X4""X5""X7""X8""X9" ... ... ... Why does it not work? Thanks in advance. __ R-help@r-project.org mailing list 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] Optim(...) estimate of stDev far too low
R-help, I'm just trying to find the ML (maximum likelihood) estimates of the mean and standard deviation of a set of observations: >xx=c(2.5,3.5,4,6,6.5,7.5) fn<-function(params,x=xx) { media<-params[1] st <-params[2] pdf=-sum(dnorm(log(xx),log(media),st,TRUE)) return(pdf) } optim(c(mu,stdev),fn,method="L-BFGS-B",lower=c(0.001, 0.001) ,upper = rep(Inf, 2), hessian=TRUE, control=list(trace=1)) iter0 value 3.011784 final value 2.802694 converged $par [1] 4.6597779 0.3860387 $value [1] 2.802694 $counts function gradient 17 17 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH" WHich gives an estimate of stDev = 0.38 while the empirical stDev = 1.94 Is there anything wrong above in the code? Thanks in advance __ R-help@r-project.org mailing list 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] Maximum likelihood estimation of parameters make no biological sense
R-help, I'm trying to estimate some parameters using the Maximum Likehood method. The model describes fish growth using a sigmoidal-type of curve: fn_w <- function(params) { Winf <- params[1] k <- params[2] t0 <- params[3] b <- params[4] sigma <- params[5] what <- Winf * (1-exp(- k *(tt - t0)))^b logL <- -sum(dnorm(log(wobs),log(what),sqrt(sigma),TRUE)) return(logL) } tt <- 4:14 wobs <- c(1.545, 1.920, 2.321 ,2.591, 3.676, 4.425 ,5.028, 5.877, 6.990, 6.800 ,6.900) An then the optimization method: OPT <-optim(c(8, .1, 0, 3, 1), fn_w, method="L-BFGS-B" ,lower=c(0.0, 0.001, 0.001,0.001, 0.01), upper = rep(Inf, 5), hessian=TRUE, control=list(trace=1)) which gives: $par Winf k t0 b sigma [1] 24.27206813 0.04679844 0.0010 1.61760492 0.0100 $value [1] -11.69524 $counts function gradient 143 143 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH" $hessian [,1] [,2] [,3] [,4] [,5] [1,] 1.867150e+00 1.262763e+03-7.857719 -5.153276e+01 -1.492850e-05 [2,] 1.262763e+03 8.608461e+05 -5512.469266 -3.562137e+04 9.693180e-05 [3,] -7.857719e+00 -5.512469e+0341.670222 2.473167e+02 -5.356813e+01 [4,] -5.153276e+01 -3.562137e+04 247.316675 1.535086e+03 -1.464370e-03 [5,] -1.492850e-05 9.693180e-05 -53.568127 -1.464370e-03 1.730462e+04 after iteration number 80. >From the biological point of view Winf =24(hipothesized asimptotical maximum >weight) makes no sense while the b parameter is no nearly close to b=3 leading to a non-sigmoidal curve. However using the least-squares method provide with more sensible parameter estimates $par Winf k t0b [1] 10.3827256 0.0344187 3.1751376 2.9657368 $value [1] 2.164403 $counts function gradient 48 48 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH" Is there anything wrong with my MLE function and parameters? I have tried with distinct initial parameters also. Can anyone give me a clue on this? Thanks in advance. __ R-help@r-project.org mailing list 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] Error: C stack usage is too close to the limit
R-help, I 'm trying to optimize a model to data using log-likelihoods but I encounter the following error message: > l= c(49.4, 57.7,64.8,70.9,78.7,86.6,88.3,91.6,99,115) > t=3:12 > fn <- function(params, l=l, t=t) { Linf <- params[1] k <- params[2] t0 <- params[3] sigma <- params[4] lhat <- params[1]*(1-exp(-params[2]*(t-params[3]))) logL <- -sum(dnorm(log(l),log(lhat),sqrt(sigma),TRUE)) return(logL) } > resop <- optim(c(120, .1, 0, 1), fn, method="L-BFGS-B",lower=c(0.0, 0.001, > 0.001,0.01) + ,upper = rep(Inf, 4), hessian=TRUE, control=list(trace=1)) Error: C stack usage is too close to the limit Thanks in advance. Running R on a Windows XP machine > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) __ R-help@r-project.org mailing list 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] cannot upgrade to R 2.9.1 in Ubuntu
R-help, At the moment the R version installed on my machine is 2.8.1. (Ubuntu 9.04) I wish to upgrade to R 2.9.1. I did: $ sudo apt-get upgrade ..but R is not upgraded although the "sources.list" file is updated with: deb http://cran.ii.uib.no/bin/linux/ubuntu jaunty/ When I run from the terminal I still get: $ R R version 2.8.1 (2008-12-22) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale .. .. Thanks in advance __ R-help@r-project.org mailing list 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] RODBC package to connect to Oracle database Linux
R-help, I get the following error message when trying to connect to an Oracle database through R (2.8.1) under Linux (Ubuntu 9.04). > channel<-odbcConnect("magnus",uid="luisr",pwd="juanayzakarias") Warning messages: 1: In odbcDriverConnect(st, ...) : [RODBC] ERROR: state IM002, code 0, message [unixODBC][DriverManager]Data source name not found, and no default driver specified 2: In odbcDriverConnect(st, ...) : ODBC connection failed I connect to the Oracle database in the following way: $ sqlplus username/passw...@myipaddress/databaseName Doing some googling I found a mail thread with the following code: con<-odbcDriverConnect("SERVER=myIPaddress;DRIVER=oracle;DATABASE=databaseName") Warning messages: 1: In odbcDriverConnect("SERVER=192.168.20.129;DRIVER=oracle;DATABASE=MAGNUS") : [RODBC] ERROR: state IM002, code 0, message [unixODBC][DriverManager]Data source name not found, and no default driver specified 2: In odbcDriverConnect("SERVER=192.168.20.129;DRIVER=oracle;DATABASE=MAGNUS") : ODBC connection failed which it is not the correct syntax (I also need some help on this). The problem is with the driver. It seems that the file "odbcinst.ini" contains the information of the driver but mine is empty although I have already run the Oracle Universal Installer to install the Oracle ODBC driver for linux. In that same mail thread there are examples on how this file should look like but on this I would need also help as there is no example on Oracle drivers (just MySql, PostgreSQLt) Thanks in advance ---- Luis Ridao Cruz Faroe Marine Research Institute Nóatún 1, P.O. Box 3051 FO-110 Tórshavn Faroe Islands Tel : (+298) 353900, Tel (direct) : (+298) 353912 Mob.:(+298) 580800, Fax: : (+298) 353901 e-mail: lu...@hav.fo luri...@hotmail.com __ R-help@r-project.org mailing list 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] Oracle ODBC driver for Linux
R-help, I get the following error message when trying to connect to an Oracle database through R (2.8.1) under Linux (Ubuntu 9.04). > channel<-odbcConnect("magnus",uid="luisr",pwd="juanayzakarias") Warning messages: 1: In odbcDriverConnect(st, ...) : [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified 2: In odbcDriverConnect(st, ...) : ODBC connection failed I connect to the Oracle database in the following way: $ sqlplus username/passw...@myipaddress/databaseName Doing some googling I found a mail thread with the following code: con<-odbcDriverConnect("SERVER=myIPaddress;DRIVER=oracle;DATABASE=databaseName") Warning messages: 1: In odbcDriverConnect("SERVER=192.168.20.129;DRIVER=oracle;DATABASE=MAGNUS") : [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified 2: In odbcDriverConnect("SERVER=192.168.20.129;DRIVER=oracle;DATABASE=MAGNUS") : ODBC connection failed which it is not the correct syntax (I also need some help on this). The problem is with the driver. It seems that the file "odbcinst.ini" contains the information of the driver but mine is empty although I have already run the Oracle Universal Installer to install the Oracle ODBC driver for linux. In that same mail thread there are examples on how this file should look like but on this I would need also help as there is no example on Oracle drivers (just MySql, PostgreSQLt) Thanks in advance. __ R-help@r-project.org mailing list 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] Problem installing RODBC package under UBUNTU
R-help, I'm now on the process of installing RODBC on UBUNTU but an error occured. I copy-paste the output: > install.packages("RODBC") Warning in install.packages("RODBC") : argument 'lib' is missing: using '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8' trying URL 'http://cran.ii.uib.no/src/contrib/RODBC_1.2-6.tar.gz' Content type 'application/x-gzip' length 123956 bytes (121 Kb) opened URL == downloaded 121 Kb * Installing *source* package 'RODBC' ... checking for gcc... gcc -std=gnu99 checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc -std=gnu99 accepts -g... yes checking for gcc -std=gnu99 option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -std=gnu99 -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sql.h usability... no checking sql.h presence... no checking for sql.h... no checking sqlext.h usability... no checking sqlext.h presence... no checking for sqlext.h... no configure: error: "ODBC headers sql.h and sqlext.h not found" ERROR: configuration failed for package 'RODBC' ** Removing '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8/RODBC' The downloaded packages are in /tmp/RtmpWqXfbD/downloaded_packages Warning message: In install.packages("RODBC") : installation of package 'RODBC' had non-zero exit status # # $ uname -a Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:58:03 UTC 2009 x86_64 GNU/Linux > version _ platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) ## ## __ R-help@r-project.org mailing list 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] rgdal package -- Error in installing package
R-help, I'm trying to install the rgdal package under Ubuntu but I get the following warning: > install.packages("rgdal") Warning in install.packages("rgdal", configure.args = "--with-gdal-modules=/usr/local/lib") : argument 'lib' is missing: using '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8' which causes the error: > library("rgdal") Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8/rgdal/libs/rgdal.so': libgdal.so.1: cannot open shared object file: No such file or directory Error: package/namespace load failed for 'rgdal' If I try the following: > install.packages("rgdal",configure.args="--with-gdal-modules=/usr/local/lib") Warning in install.packages("rgdal", configure.args = "--with-gdal-modules=/usr/local/lib") : argument 'lib' is missing: using '/home/luisridaocruz/R/x86_64-pc-linux-gnu-library/2.8' trying URL 'http://cran.ii.uib.no/src/contrib/rgdal_0.6-8.tar.gz' Content type 'ap . Then the same error occurs and by doing: > install.packages("rgdal",configure.args="--with-gdal-modules=/usr/local/lib",lib="/usr/local/lib") Warning in install.packages("rgdal", configure.args = "--with-gdal-modules=/usr/local/lib", : 'lib = "/usr/local/lib"' is not writable Error in install.packages("rgdal", configure.args = "--with-gdal-modules=/usr/local/lib", : unable to install packages Can anyone helps? __ R-help@r-project.org mailing list 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 under Ubuntu
R-help, I have installed R under Ubuntu and I'm very new to a Linux distribution. To open an empty R session I just type R on the Terminal aplication. But how can I open a saved workspace? At present I just start R and then load ("my_workspace") but it must be possible to do it all at onceright? Thanks in advance __ R-help@r-project.org mailing list 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-sig-Geo] Comparing spatial distributions - permutation test implementation
) }, dat[,c("x","y")], dat[,c("var1","var2")]) # Compute the statistic (i.e. sum of mean squared differences) return(sum(meanSqDiff)) } # Get data online : http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv system("curl http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv > syrjala_data_cod.csv") dataCod = read.csv(file = "syrjala_data_cod.csv", header = TRUE) # Normalize abundances dataCod$var1 = dataCod$var1/sum(dataCod$var1) dataCod$var2 = dataCod$var2/sum(dataCod$var2) # Number of permutations nperm = 1000 # Create nperm-1 replicates of the data (one is the original observation) d = rep(list(dataCod), nperm-1) # Compute number of observations before to avoid doing that for every replicate n = nrow(dataCod) require(plyr) # Permute some observations and compute the syrjala stat for each permutation psis = ldply(d, .fun=function(x, n){ # choose indices of observations to swap idx = sample(1:n, runif(1, min=1, max=n)) # swap observations x[idx, 3:4] = x[idx, 4:3] # compute syrjala stat return(syrjala.stat(x)) }, n, .progress="text") } # Compute the syrjala stat for the observations psi = syrjala.stat(dataCod) # Estimate the pvalue pvalue = (sum(psis>=psi)+1)/nperm psi pvalue # Should be: # statistic = 0.224 # p-value = 0.1900 Thank you very much in advance. Sincerely, JiHO --- http://jo.irisson.free.fr/ [1] A statistical test for a difference between the spatial distributions of two populations. Syrjala SE. Ecology. 1996;77(1):7580. http://dl.getdropbox.com/u/1047321/Syrjala1996.pdf [2] https://stat.ethz.ch/pipermail/r-sig-geo/2008-February/ thread.html#3137 ___ R-sig-Geo mailing list r-sig-...@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo Marcelino de la Cruz Rot Departamento de Biología Vegetal E.U.T.I. Agrícola Universidad Politécnica de Madrid 28040-Madrid Tel.: 91 336 54 35 Fax: 91 336 56 56 marcelino.delac...@upm.es __ R-help@r-project.org mailing list 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] RES: set a legend with an "image" graph
R-help, I'm sorry that I said " I don't have idea ". What I mean t is that I just don't know how to set a legend when "image" is called. Thanks in advance __ R-help@r-project.org mailing list 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] set a legend with an "image" graph
R-help, I have an image plot and I wish to set a legend to it but I don't have an idea how to do it. Below it's the code line. image(yyy, col = rev(heat.colors(10)), axes = T) Thanks in advance. __ R-help@r-project.org mailing list 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] cluster analysis: mean values for each variable and cluster
Try this: c4 <- cutree(cluster, k=4) by(data, c4, mean) HTH Marcelino On 2009-02-20 Jgaspard wrote: Hi all! I'm new to R and don't know many about it. Because it is free, I managed to learn it a little bit. Here is my problem: I did a cluster analysis on 30 observations and 16 variables (monde, figaro, liberation, etc.). Here is the .txt data file: "monde","figaro","liberation","yespeople","nopeople","bxl","europe","ue","union_eur","other","yesmeto","nometo","yesfonc","nofonc","yestone","notone" 1,0,0,0,1,0,0,0,1,0,0,1,1,0,1,0 1,0,0,0,1,0,0,0,1,0,0,1,1,0,1,0 1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0 0,1,0,0,1,0,0,0,1,0,0,1,1,0,0,1 1,0,0,0,1,0,0,0,1,0,0,1,1,0,0,1 1,0,0,0,1,0,0,0,0,1,0,1,1,0,1,0 1,0,0,0,1,0,0,0,0,1,0,1,1,0,1,0 1,0,0,0,1,0,0,0,1,0,0,1,0,1,1,0 0,1,0,0,1,0,0,0,1,0,0,1,0,1,1,0 0,1,0,0,1,0,0,0,0,1,0,1,0,1,1,0 1,0,0,0,1,0,1,0,0,0,0,1,0,1,0,1 0,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0 0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0 1,0,0,0,1,0,0,1,0,0,0,1,0,1,1,0 0,1,0,0,1,0,0,0,1,0,0,1,1,0,1,0 0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0 0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,0 0,1,0,0,1,1,0,0,0,0,1,0,0,1,1,0 0,1,0,0,1,1,0,0,0,0,1,0,0,1,1,0 0,1,0,0,1,1,0,0,0,0,1,0,0,1,1,0 0,1,0,0,1,1,0,0,0,0,1,0,0,1,1,0 0,1,0,0,1,1,0,0,0,0,1,0,0,1,0,1 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 0,1,0,0,1,1,0,0,0,0,1,0,1,0,1,0 1,0,0,0,1,1,0,0,0,0,1,0,1,0,1,0 The steps I made were those: headlines=read.table("/data.csv", header=T, sep=",") data dist=dist(data,method="euclidean") dist cluster=hclust(dist,method="ward") cluster plot(cluster) rect.hclust(cluster, k=4, border="red") I extracted 4 clusters from the data. My question is: is it possible to produce a summary of every mean values for each variable of each of the 4 clusters? Thanks a lot in advance, Jeoffrey Marcelino de la Cruz Rot Departamento de Biología Vegetal E.U.T.I. Agrícola Universidad Politécnica de Madrid 28040-Madrid Tel.: 91 336 54 35 Fax: 91 336 56 56 marcelino.delac...@upm.es __ R-help@r-project.org mailing list 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] multidimensional scaling with long form data
This is my approach: If "cosa" is your data.frame . e.g. >cosa i1 i2 dis [1,] 1 1 0.00 [2,] 1 2 0.93 [3,] 1 3 0.80 [4,] 1 4 1.00 [5,] 2 2 0.00 [6,] 2 3 0.02 [7,] 2 4 0.22 [8,] 3 3 0.00 [9,] 3 4 0.95 [10,] 4 4 0.00 # first crate a square matrix of 0´s, of the appropriate dimensions (in this example, 4) pepe <- matrix(0, nr=4, nc=4) # then assign your long disimilarity data to trhe lower tree of the square matrix # check the diag argument! pepe[lower.tri(pepe, diag=T)] <- cosa[,3] # then transpose the matrix pepe <- t(pepe) # and symmetrize the resulting matrix library(calibrator) pepe <- symmetrize(pepe) # finaly, transform to a dist matrix: pepe <- as.dist (pepe) HTH, Marcelino kirsten-be...@uiowa.edu wrote: I have a dissimilarity dataset with the form: 1 1 dissimilarity value 1 2 ... 1 3 1 4 2 2 2 3 2 4 ... I would like to do nonmetric multidimensional scaling with this data, but I am having trouble using this format. I would like to either find a function that accepts this format or find a way to easily convert this format to a matrix for use with existing functions. Thanks! Marcelino de la Cruz Rot Departamento de Biología Vegetal E.U.T.I. Agrícola Universidad Politécnica de Madrid 28040-Madrid Tel.: 91 336 54 35 Fax: 91 336 56 56 marcelino.delac...@upm.es _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] distance betwenn axis and axis annotation
R-help, How can I specify the distance between the axis and axis annotation? Thanks in advance __ R-help@r-project.org mailing list 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] Filter a big matrix
Hi, I have a big matrix X with M rows and N columns that I want to filter it into smaller ones with m (=5 ...etc ,] X[X$a<5 & X$b<5 & X$c>=5 & X$d<5 ...etc ,] ... ... ... ... with all the possible combinations which is 2^M I try to use multiple for loops to separate it: for (i in 1:2) for (j in 1:2) for (k in 1:2) ... ... assign(paste(i,j,k,...,sep="")), X[if (i==1) paste("X$a<5") else paste("X$a>=5") & if (i==1) paste("X$b<5") else paste("X$b>=5") & ..., ]) # there might be syntax errors, I just want to clearly describe my problem Since paste("X$a>=5") gives type of character; whereas the type of X$a>=5 should be logical. How can I do this? All thoughts are greatly appreciated. Many Thanks, cruz __ R-help@r-project.org mailing list 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] error in my previous message
try this: temp2 <- temp2[order(temp2[,1]),] # PROBLEM IS HERE dim(temp2) <- c(5,1) print(temp2) On Wed, Feb 11, 2009 at 2:23 PM, wrote: > i'm sorry. i had an error in my previous code because i left out a letter in > the rownames. > while fixing that, i also found a solution. so i'm sorry for the confusion. > > below is my fix. > > temp2 <- matrix(rnorm(10),nc=1,nrow=10) > rownames(temp2) <- c("a","b","c","d","e","f","g","h","i","j") > print(temp2) > temp2 <- as.matrix(temp2[order(temp2[,1,drop=FALSE]),]) > print(temp2) > > > > > > On Wed, Feb 11, 2009 at 1:18 AM, markle...@verizon.net wrote: > >> this is a bad question but I can't figure it out and i've tried. if i sort >> the 2 column >> matrix , temp1, by the first column, then things work as expected. But, >> if I sort the 1 column matrix, temp2, then it gets turned coerced to a >> vector. I realize that I >> need to use drop=FALSE but i've put it in a few different places with no >> success. Thanks. >> >> temp1 <- matrix(rnorm(10),nc=2,nrow=5) >> rownames(temp1) <- c("a","b","c","d","e") >> print(temp2) >> temp1 <- temp1[order(temp1[,1]),] >> print(temp1) >> >> temp2 <- matrix(rnorm(10),nc=1,nrow=5) >> rownames(temp2) <- c("a","b","c","d","e","f","g","h","i") >> print(temp2) >> temp2 <- temp2[order(temp2[,1]),] # PROBLEM IS HERE >> print(temp2) >> >> __ >> R-help@r-project.org mailing list >> 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 > 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 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] installing R on Ubuntu
nice:) The next step is to install Emacs, because we need a editor as we code, we need to run the line as we go, so here is a very good guide for the complete starter: http://www.stat.rice.edu/~helpdesk/tutorial/ess.html The official ESS manual does not bother to go into this brief, I can't even start a R session in Emacs when I have read the ESS manual several times, but it is getting clearer to me now as I have been writing R codes by Emacs for a couple of weeks... It is exactly the same as we code in Windows. Thanks, cruz PS: The R gurus may find this thread annoying cause it is too trivial to them. On Sun, Feb 8, 2009 at 9:13 AM, Paul Heinrich Dietrich wrote: > > I've read some of R's literature on Linux, including the R Admin manual, and > didn't find it very useful, which is probably my own limitation. But I did > finally manage to get it working well. I'm posting this to help others. > The following worked when installing R 2.8.1 on Ubuntu 8.04 Hardy Heron. > Here are truly step-by-step instructions for those who don't know Linux > (like me): > > Installation and Initial Set-Up of R for Ubuntu Linux > > 1. Open the Bash terminal (Applications > Accessories > Terminal) > 2. Type these lines to add the security key to access the latest version of > the R Ubuntu package: >u...@computer:~$ gpg --keyserver subkeys.pgp.net --recv-key E2A11821 >u...@computer:~$ gpg -a --export E2A11821 | sudo apt-key add - > 3. Use the Bash terminal to open your sources.list file with gedit (text > editor) for editing: >u...@computer:~$ sudo gedit /etc/apt/sources.list > 4. Add this line to the bottom of the sources.list file: >deb http://rh-mirror.linux.iastate.edu/CRAN/bin/linux/ubuntu hardy/ > 5. Save the file and go back to the Bash terminal. > 6. Type this to update apt-get's database before you install R: >u...@computer:~$ sudo apt-get update > 7. Install R with this command: >u...@computer:~$ sudo apt-get install r-base > 8. Go to System > Administration > Synaptic Package Manager, and download > the build-essential package. > 9. To use R, simply enter R in the Bash terminal. To quit, enter q(). > > > Additional programs will be needed to install other packages or work with > other programs: > 1. Install compilers for C++ and Fortran >u...@computer:~$ sudo apt-get install g++ gfortran > 2. Install the developer versions of Blas and Lapack (what are these?) >u...@computer:~$ apt-get install libblas-dev liblapack-dev > > > Updating Packages in R > 1. Open the Bash terminal and start R with root permissions >u...@computer:~$ sudo R > 2. Type > update.packages() > > > Installing the R Commander GUI > 1. Open the Bash terminal and type: > u...@computer:~$ apt-get install r-cran-rcmdr > > > Using the R Commander GUI > library(Rcmdr) > ...or once the library is open and Commander has been shut down, type: > commander() > > > Notes > It looks like most of R has been put here: > /etc/R (Rprofile.site is here) > /usr/lib/R > > > Downloaded Packages seem to go here: > /usr/local/lib/R/site-library/ > -- > View this message in context: > http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21894865.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > 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 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 on Mobile Devices (Android)
On Fri, Feb 6, 2009 at 8:12 PM, Harsh wrote: > Hell R-list, > > At the cost of sounding far-fetched and almost incredulous, I would > like to know if any R user is remotely considering the use of R on > Mobile devices, and Android in particular. > Check out FreeRunner from Openmoko (http://wiki.openmoko.org/wiki/Main_Page). It is a Linux based mobile device, and this is a FOSS project. __ R-help@r-project.org mailing list 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] annotating a filled contours plot with a grid of points
Try this example: mygrid <- expand.grid(x=seq(0,1, by=0.1), y=seq(0,1, by=0.1)) filled.contour(volcano, color = terrain.colors, asp = 1, plot.axes={ axis(1); axis(2); points(mygrid, cex=0.5, pch=19)}) Cheers, Marcelino > From: Dario Martin-Benito inia.es> > Subject: [R] annotating a filled contours plot with a grid of points > To: r-help r-project.org > Date: Friday, February 6, 2009, 8:23 AM > Dear R-help members, > > I am trying to plot annotate a filled contours plot (with > filled.contour) > with a grid of points. I have read ways of annotating it > with individual > points but not with grids in another matrix. > > > > Any ideas? > > > > Thank you very much. > > > > Dario > > ___ > Dario Martin-Benito > CIFOR-INIA > Dpto. Sistemas y Recursos Forestales > Ctra. La Coruña, Km. 7.5 > E-28040 Madrid (Spain ) > Tel.: +34 91 347 1461 > e-mail: dmartin inia.es /// dmartinbenito gmail.com > > <http://dmartinbenito.googlepages.com>http://dmartinbenito.googlepages.com > Marcelino de la Cruz Rot Departamento de Biología Vegetal E.U.T.I. Agrícola Universidad Politécnica de Madrid 28040-Madrid Tel.: 91 336 54 35 Fax: 91 336 56 56 marcelino.delac...@upm.es _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Text Mining
There is an interesting article "An Introduction to Text Mining in R" by Ingo Feinerer on R News Volume 8/2, October 2008 (http://www.r-project.org/doc/Rnews/Rnews_2008-2.pdf) Check it out On Fri, Feb 6, 2009 at 9:16 AM, spiketide wrote: > > hi everyone... > > i am a newbie to text mining. and i gotta do my project in it i've > looked up various infos online but still haven't got an idea on where to > start so please, if anyone gave suggestions on this, it will be really > helpful... > > thanks a lot in advance > > -- > View this message in context: > http://www.nabble.com/Text-Mining-tp11467848p21864801.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > 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 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] non-numeric argument to binary operator
Hi, I compute the value of xi*xj by "for" loops, this how I try: > x1 <- c(1:3) > x2 <- c(2:4) ### to compute x1*x2 > (paste("x", 1, sep = ""))*(paste("x", 2, sep = "")) Error in (paste("x", 1, sep = "")) * (paste("x", 2, sep = "")) : non-numeric argument to binary operator > All comments are appreciated. Thanks, cruz __ R-help@r-project.org mailing list 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] Alternate looping
R-help, I'm using the "for" control flow to graph plots continuously: par(mfrow=c(3,5), mar=c(0.6,.2,1.2,.2),yaxt="n",xaxt="n") for(j in 1:11) { for(i in 1:15) { species <- spAldur[spAldur$ar == 1993+i & spAldur$aldur == j,] plot(spec...@coords[,1], spec...@coords[,2], xlim=c(-10,-3.5), ylim=c(60.1,63) , col=3,type="n",xlab="",ylab="") points(geoFeatures[["dyp100"]],pch=".",cex=1.2,col="blue") . . . }} This will plot a map of "something" in the following way: (j=1, i=1), (j=1, i=2),(i=1, i=3),,, (j=2, i=1), (j=2, i=2),(i=2, i=3),,, (j=3, i=1), (j=3, i=2),(i=3, i=3),,, and so on but I wish to have it like this: (j=1, i=1), (j=2,i=2),(i=3,i=3),,, Thanks in advance __ R-help@r-project.org mailing list 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] Newbie question
abntest[abntest$abntesr > 90,] On Sun, Jan 4, 2009 at 11:55 AM, wrote: > Hi: > > I'm loading in students test scores with: > >> abntest <- read.table("scores.txt") > > if I type: > >>abntest > > I get ALL the values. I want to be able to filter it by various things such > as: > > > if( abntesr > 90) Print abntest; > > and other logical operators. I'm sure this is simple for someone experienced. > > > Thanks, > > Gregg Allen > > __ > R-help@r-project.org mailing list > 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 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] example of using loess()
Hi, I have read ?loess help page and did some google on loess, however there are insufficient information on weighted variance. I am wondering that if any of you know of an example or document on weighted variance using loess (), especially for the cases when more than one explanatory variable is involved. Thanks a lot, cruz __ R-help@r-project.org mailing list 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] Fitting weighted polynomial regression model
Hi, I have a simple question but I just couldn't find the right way to do it after 3 hours of hacking and google. How do I fit a weighted polynomial regression model to my plot? This is what I got so far: > lines(loess(A~B + I(B^2),weights=1/B^2)) Error in xy.coords(x, y) : 'x' and 'y' lengths differ In addition: Warning messages: 1: pseudoinverse used at 0.52416 0.029047 2: neighborhood radius 3.8766 3: reciprocal condition number 4.3293e-017 4: There are other near singularities as well. 19.538 > Any idea would be appreciated. Thanks, cruz __ R-help@r-project.org mailing list 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 simulations
I need help with these R simulations ___ The generation of pseudo-random numbers with uniform distribution [0.1] can be done through a method called Congruencial Committee, which consists the use of a recursive relationship of the type: xi +1 = (a.xi + c) mod m being a, c, and the positive integers m, c 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] CRAN mirror for Taipeh vs Taipei
Hi, I am residing in Taipei, Taiwan. My windows has English R (2.7.2) installed. I noticed that the CRAN mirror for Taipei is Taiwan (Taipeh), Is Taipeh a Deutsch or English name? Thanks, cruz __ R-help@r-project.org mailing list 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] help for code in jump diffusion
i tried to run your code, this is how/why you got NaN: > mu<-0.2 > sig<-0.2 > S0<-100 > j<-0.2 > dt<-1/252 > int<-0.1 > i<-0 > is.nan function (x) .Primitive("is.nan") > k<-rnorm(1,0,1) > k [1] 0.3214954 > theta<-ifelse((k<(int*dt)),1,0) > theta [1] 0 > m<-rnorm(1) > m [1] -0.4525731 > gam<-qnorm(m,0,1) Warning message: In qnorm(p, mean, sd, lower.tail, log.p) : NaNs produced > gam [1] NaN > S0<-abs(S0*((1+mu*dt+sig*sqrt(dt)+ gam)- j*theta)) > S0 [1] NaN > if(!is.nan (S0 <= 0)) + warning("S0 must be positive") Warning message: S0 must be positive > cat("NaN","\n") NaN > cat(S0,"\n") NaN > On Sat, Nov 22, 2008 at 2:37 PM, subbudas <[EMAIL PROTECTED]> wrote: > > hello everyone , > i have written some code in R for jump diffusion model. > the code generates answer as > " NaN > There were 50 or more warnings (use warnings() to see the first 50)" > my code is > > mu<-0.2 > sig<-0.2 > S0<-100 > j<-0.2 > dt<-1/252 > int<-0.1 > i<-0 > while(i<=1) > { > is.nan > k<-rnorm(1,0,1) > theta<-ifelse((k<(int*dt)),1,0) > m<-rnorm(1) > gam<-qnorm(m,0,1) > S0<-abs(S0*((1+mu*dt+sig*sqrt(dt)+ gam)- j*theta)) > if(!is.nan (S0 <= 0)) > warning("S0 must be positive") > cat("NaN","\n") > cat(S0,"\n") > i<-i+(1/252) > } > > the problem i am facing is i am not able to find out the reason for this NaN > output. > please help > > thanks in advance. > > > __ R-help@r-project.org mailing list 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] problem with urca package
is this what you expect? > ur.df(PIBTUN$V1,type='none',lags=1) ### # Augmented Dickey-Fuller Test Unit Root / Cointegration Test # ### The value of the test statistic is: 6.2523 On Wed, Nov 12, 2008 at 8:56 AM, <[EMAIL PROTECTED]> wrote: > Dear R users, > I have the joined txt file in the following direct directory C:// > I have written the following lines: > library(urca); > PIBTUN<-read.table("C:/AF.txt", header=F); > ur.df(PIBTUN,type='none',lags=1) > but I have obtained the following message: > Error in embed(z, lags) : 'x' is not a vector or matrix > I don't What's the problem, can you please help me > Thank you in advance > > > > Avec le traducteur Voila, lisez enfin les journaux étrangers ! > http://tr.voila.fr/ > > __ > R-help@r-project.org mailing list > 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 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] estimated variance for parametric fit
Hi, What formula is appropriate for calculating the estimate of variance from the parametric fit? I have a linear regression model i.e. lm(a~b) Thanks, cruz __ R-help@r-project.org mailing list 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] Re move specific rows from a matrix
use the trick from this thread: https://stat.ethz.ch/pipermail/r-help/2008-November/178985.html your problem shall be fixed On Fri, Nov 7, 2008 at 8:21 PM, mentor_ <[EMAIL PROTECTED]> wrote: > > Hi, > > imagine the following two matrix: > Matrix A: > a b c > 1 2 3 > 4 5 6 > 7 8 9 > > Matrix B: > a > 4 > 7 > > I would like to remove those rows from matrix A which are present in both > matrices. > So after removing the corresponding rows the matrix A should look like this: > Matrix A: > a b c > 1 2 3 > > Thanks in advance! __ R-help@r-project.org mailing list 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] grouping data together
hi friend, this is from your previous posts on Kruskal-Wallis test:) i came up with this one: A5 <- read.table('kew.dat' ,header=TRUE) plot(factor(A5$Month, levels=month.abb), A5$Rain) is that what you want? On Sat, Nov 8, 2008 at 7:03 AM, Swanton0822 <[EMAIL PROTECTED]> wrote: > > Hi. > i have a data, and there is 3 columns, Month, Year and Total. and there is > over 1000 rows for them because there is 87 years data for every month, so > there is month from Jan-Dec, and year from 1900-1987, > so i was wondering if i would want to make 12 groups (Jan,Feb...,Dec), > and put each year's total into the corresponding month (so every month group > will have 88 values of total) > how can i do that? > many thanks. __ R-help@r-project.org mailing list 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] missing value where TRUE/FALSE needed
is this what you want? > vector1 [1] 65 1 34 100 42 20 79 43 89 10 > vector2 [1] 34 65 47 91 48 32 23 74 92 86 > > for (i in 1:10) { + for (j in 1:10) { + if (vector1[i] == vector2[j]) + show(c(i,j)) + } + } [1] 1 2 [1] 3 1 On Sat, Nov 8, 2008 at 8:22 AM, David Croll <[EMAIL PROTECTED]> wrote: > Hello dear R people, > > > for my MSc thesis I need to program some functions, and some of them simply > do not work. In the following example, I made sure both vectors have the > same length (10), but R gives me the following error: > > Error in if (vector1[i] == vector2[j]) { : > missing value where TRUE/FALSE needed > > I googled for possible solutions, but I did not find a good explanation for > this... > > > The code: > > test <- function() { > vector1 <- sample(1:100,10) > vector2 <- sample(1:100,10) > for (i in vector1) { > for (j in vector2) { > if (vector1[i] == vector2[j]) { > show(list(i,j)) > } > } > } > } > > Regards, David > > __ > R-help@r-project.org mailing list > 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 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] chi square table
Hi, How do we get the value of a chi square as we usually look up on the table on our text book? i.e. Chi-square(0.01, df=8), the text book table gives 20.090 > dchisq(0.01, df=8) [1] 1.036471e-08 > pchisq(0.01, df=8) [1] 2.593772e-11 > qchisq(0.01, df=8) [1] 1.646497 > nono of them give me 20.090 Thanks, cruz __ R-help@r-project.org mailing list 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] How to avoid "$ operator is invalid for atomic vectors"
> > Does that answer your question? > Thanks:) I received one from Erin: x <- NULL __ R-help@r-project.org mailing list 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] How to avoid "$ operator is invalid for atomic vectors"
Thanks for all the responses, they are all very helpful:) > you don't need to assign dimension or classes to your objects. > It's easier if you do like this this is something that really bothers me, when I need to define an object which i will later fill with data, the dimension of this object should not be fixed because it will grow... so in MATLAB, i.e. we define x = [ ], what about in R? Thanks, cruz __ R-help@r-project.org mailing list 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] How to avoid "$ operator is invalid for atomic vectors"
Hi, I am writing this in a wrong way, can someone please correct me? > A <- matrix() > length(A) <- 6 > dim(A) <- c(3,2) > colnames(A) <- c("X","Y") > A X Y [1,] NA NA [2,] NA NA [3,] NA NA > A$X Error in A$X : $ operator is invalid for atomic vectors > Thanks, cruz __ R-help@r-project.org mailing list 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] Data manipulation question
On Thu, Nov 6, 2008 at 4:23 PM, Peter Jepsen <[EMAIL PROTECTED]> wrote: > > Here is an example: > > id <- c(rep("a",4),rep("b",2), rep("c",5), rep("d",1)) > start <- c(c(0,6,17,20),c(0,1),c(0,5,10,11,50),c(0)) > stop <- c(c(6,12,20,30),c(1,10),c(3,10,11,30,55),c(6)) > data <- as.data.frame(cbind(id,start,stop)) > data > #id start stop > # 1 a 06 > # 2 a 6 12 > # 3 a17 20 > # 4 a20 30 > # 5 b 01 > # 6 b 1 10 > # 7 c 03 > # 8 c 5 10 > # 9 c10 11 > # 10 c11 30 > # 11 c50 55 > # 12 d 06 > > So, what I want to end up with is this: > > id start stop > a 0 12 # This patient was transferred at time 6 and discharged at > time 12. The admission starting at time 17 is therefore irrelevant. > b 0 10 > c 0 3 > d 0 6 > Try this: result <- list() num <- length(levels(factor(data$id))) length(result) <- 3*num dim(result) <- c(3,num) result <- data[data$start == 0,] Y <- as.integer(row.names(result)) for (i in 1:num) { if (Y[i] == dim(data)[1]) (result[i,3] <- data[dim(data)[1],3]) else (result[i,3] <- data[Y[i]+1,3]) } result Sorry it is ugly cuz i am new too but hopefully it gives you some ideas. __ R-help@r-project.org mailing list 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] Reshape a matrix
On Thu, Nov 6, 2008 at 8:53 AM, dinesh kumar <[EMAIL PROTECTED]> wrote: > Dear R users, > > I have a matrix like > > A X1 > B Y2 > C Z3 > > I want to reshape this matrix into this format > >X Y Z > A 1 > B 2 > C 3 > is this what you want? > matrix(diag(c(1,2,3)),nrow=3,ncol=3,dimnames=list(c("A","B","C"),c("X","Y","Z"))) X Y Z A 1 0 0 B 0 2 0 C 0 0 3 __ R-help@r-project.org mailing list 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] FW: need some help
> > How can I assign df$counts values to dd$counts for the corresponding > dd$comp==df$comp > ?factor the $comp then assign accordingly __ R-help@r-project.org mailing list 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] use abline() for regression model in the plot
On Wed, Nov 5, 2008 at 6:47 AM, Swanton0822 <[EMAIL PROTECTED]> wrote: > > after that i have been ask to do the following: > 'The regression equation for EXPEND depending on ECAB is > E(EXPEND)=119.0+1.73xECAB when there is outliners and > E(EXPEND)=97.8+1.94xECAB when the outliners are omitted from the regression > model. To the plot in 2) without the outliners, use abline() to add a fitted > line for the full regression model, and a coloured, dashed regression line > for the non-outliner regression model.' > m1 <- lm(EXPEND ~ ECAB, data=A5) m1 abline(m1) m2 <- lm(EXPEND ~ ECAB, data=A5e) m2 abline(m2,col="green",lty=2) __ R-help@r-project.org mailing list 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] qr() and Gram-Schmidt
Hi, Why the qr() produces a negative Q compared with Gram-Schmidt? (note example below, except Q[2,3]) Here is an example, I calculate the Q by Gram-Schmidt process and compare the output with qr.Q() a <- c(1,0,1) b <- c(1,0,0) c <- c(2,1,0) x <- matrix(c(a,b,c),3,3) ## # Gram-Schmidt ## A <- matrix(a,3,1) q1 <- (1/sqrt(sum(A^2)))*A B <- b - (q1%*%b)%*%q1 q2 <- (1/sqrt(sum(B^2)))*B C <- c - (q1%*%c)%*%q1 - (q2%*%c)%*%q2 q3 <- (1/sqrt(sum(C^2)))*C Orthonormal.basis <- matrix(c(q1,q2,q3),3,3) > Orthonormal.basis [,1][,2] [,3] [1,] 0.7071068 0.70710680 [2,] 0.000 0.0001 [3,] 0.7071068 -0.70710680 ## # QR Factorisation X = QR ## x.qr <- qr(x) Q <- qr.Q(x.qr) R <- qr.R(x.qr) X <- qr.X(x.qr) > Q [,1][,2] [,3] [1,] -0.7071068 -0.70710680 [2,] 0.000 0.000 1 [3,] -0.7071068 0.70710680 Thanks, cruz __ R-help@r-project.org mailing list 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] Reconstruct the Q matrix from the QR object
Hi, Is it possible to construct a Q from qr() that some of the rows could be specified (to be fixed values)? Thanks, cruz __ R-help@r-project.org mailing list 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] How to label a "vector"
Hi, I have an object, Z: > typeof(Z) [1] "list" It looks like: [,1] [,2] [,3] [1,] 111 [2,] 111 How can it label the Rows and Columns with Text? so that it looks like: Y1 Y2 Y3 X1 111 X2 111 Thanks, cruz __ R-help@r-project.org mailing list 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] savePlot() does not save plot with format set
R-help, Whenever I try to save a plot with "savePlot" the file is not stored in my hard disk with the selected format. Several formats are set and none of them works. I just get the file name with missing extension and it can't be open with programs like Paint and Microsoft Photo Editor Th only one able to open it is "Windows Picture and Fax Viewer" plot(rnorm(10)) savePlot("test", type="png") savePlot("test", type="bmp") My platform is Windows XP SP3 > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.0 year 2008 month 04 day22 svn rev45424 language R version.string R version 2.7.0 (2008-04-22) Thanks in advanced __ R-help@r-project.org mailing list 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] "remove.packages" gives error message
R-help, I'm trying to remove some packages with the command "remove.packages" but R 2.4.1 will come out with this: > remove.packages(pkgs="FLAssess", lib = "C:\\Program Files\\R\\R-2.4.1\\library\\FLAssess") Error in .find.package(pkgs, lib) : there is no package called 'FLAssess' Thanks in advance NB: I know the R version is old but I need to run in this version for back compability with some packages. > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) __ R-help@r-project.org mailing list 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] equivalent of excel "sumif"
R-help, I have two data frames df1 and df2: >head(df1) lgdcm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... ... > head(df2) lgdcm 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 34 NA NA 1 NA NA NA NA NA NA NA NA NA NA NA NA NA 36 NA NA 1 NA NA NA NA NA NA NA NA NA NA NA NA NA 40 NA NA 1 1 NA NA NA NA NA NA NA NA NA NA NA NA 41 NA NA NA NA 3 NA NA NA NA NA NA NA NA NA NA NA 42 NA NA NA NA 7 NA NA NA NA NA NA NA NA NA NA NA 43 NA NA NA 1 6 NA NA NA NA NA NA NA NA NA NA NA I want to fill up the columns of df1 (0,1,215) with columns from df2 (0,1,215) with column 'lgdcm' as the criterion for matching. There is a function in excel which does this type of thing, something like: SUMIF(range,criteria,sum_range) Can anyone help with this? Thanks in advance. __ R-help@r-project.org mailing list 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] data manipulation
R-help, I have a data frame in which I compute maximum by rows and I wish to find out the column name at which this maximun occurs. Does anyone know how to do it? Thanks in advance __ R-help@r-project.org mailing list 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] shaded area graph and extra plot
R-help, I'm using the code below to plot a shaded area graph. At the same time I want to plot a second series on the y-axis (from par(new=T) on) but as the two series have different x-axis range (first 1994:2007 and second 1996:2007) the corresponding x's do not match. How can this be sorted out? Thanks in advance # plot.new() plot.window(xlim=c(1993,2008), xaxs="i", ylim=c(0,400), yaxs="i") x=1994:2007 xx = c(1994, x, 2007) yy1 = c(0, indexSp[,"Xhat5Sp"]+indexSp[,"seA"], 0 ) yy2 = c(0, indexSp[,"Xhat5Sp"]-indexSp[,"seA"], 0 ) polygon(xx, yy1, col="grey", lty=0) polygon(xx, yy2, col="white", lty=0) lines(x, indexSp[,"Xhat5Sp"], type="l") axis(1) axis(2) par(new=T) plot(1996:2007, c(0,0,indexSu[,"Xhat5Su"]), type="p", col=2, lwd=2, cex=1,ann=T,axes=F) axis(4) # __ R-help@r-project.org mailing list 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] shaded area graph and extra plot
R-help, I'm using the code below to plot a shaded area graph. At the same time I want to plot a second series on the y-axis (from par(new=T) on) but as the two series have different x-axis range (first 1994:2007 and second 1996:2007) the corresponding x's do not match. How can this be sorted out? Thanks in advance # plot.new() plot.window(xlim=c(1993,2008), xaxs="i", ylim=c(0,400), yaxs="i") x=1994:2007 xx = c(1994, x, 2007) yy1 = c(0, indexSp[,"Xhat5Sp"]+indexSp[,"seA"], 0 ) yy2 = c(0, indexSp[,"Xhat5Sp"]-indexSp[,"seA"], 0 ) polygon(xx, yy1, col="grey", lty=0) polygon(xx, yy2, col="white", lty=0) lines(x, indexSp[,"Xhat5Sp"], type="l") axis(1) axis(2) par(new=T) plot(1996:2007, c(0,0,indexSu[,"Xhat5Su"]), type="p", col=2, lwd=2, cex=1,ann=T,axes=F) axis(4) # __ R-help@r-project.org mailing list 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] sort a data frame according to roman characters
R-help, I have a data frame with one column containing roman numbers The data are not sorted as : III III IV VVI VII VIII IX XXI XII XIII XIV XV Using data[order(data$Roman),] does not do the job. How can this be done? Thanks in advance. __ R-help@r-project.org mailing list 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] function code
R-help, Sorry for this question (I guess it has been addressed before but I could not find it in the archives) but how can I see a function code when the following comes up: > svymean function (x, design, na.rm = FALSE, ...) { .svycheck(design) UseMethod("svymean", design) } Thanks in advance __ R-help@r-project.org mailing list 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] reduce the code used by "for"
R-help, I have a 3-way array: > dim(bugvinP) [1] 13 14 3 The array looks something like this (object trimmed for readability) , , slag = 1 ar 1994 1995 1996 1997 1998 1 NA 0.000 0.000 0.000 0.000 2 0.036 0.059 0.027 0.000 0.000 3 0.276 0.475 0.491 0.510 0.559 10 1.000 1.000 1.000 1.000 1.000 11NA 1.000 1.000NA 1.000 12NA 1.000 1.000 1.000 1.000 13NA 1.000NA 1.000NA , , slag = 2 ar 1994 1995 1996 1997 1998 1 NA 0.000 0.000 0.000 0.000 2 0.129 0.029 0.011 0.026 0.000 9 1.000 1.000 1.000 1.000 1.000 10 1.000 1.000 1.000 1.000 1.000 11 1.000 1.000 1.000 1.000 1.000 12 1.000 1.000 1.000 1.000 1.000 13NANA 1.000 1.000NA I want to set NAs to 0 if the row names are e.g. 3 and 1 otherwise. To implement this I do the following which is OK but I wish to find out a more compact/shorter version. for(i in 1:3) { bugvinP[,,i] <- ifelse(as.numeric(rownames(bugvinP[,,i])) < 3 & is.na(bugvinP[,,i]), 0 , ifelse(as.numeric(rownames(bugvinP[,,i])) > 9 & is.na(bugvinP[,,i]), 1, bugvinP)) } Thanks in advance > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) > __ R-help@r-project.org mailing list 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] Fail to open R 2.6.1 - additional information
This is additional information to my previous email (pasted below) ## I opened an R session ( R 2.6.0 on Windows) and got the following pop-up window: ## "This application has failed to start because tk84.dll was not found. Re-installing the application may fix the problem" ## I have now upgraded to R 2.6.1 but the same fatal error comes up. ## Can someone let me know what is going on? I have started an empty R session and tried to load the workspace I can't open (above) I get the error message: > load("E:\\WORKSPACE_I CANNOT OPEN") Loading Tcl/Tk interface ...Error in dyn.load(file, ...) : unable to load shared library 'C:/PROGRA~1/R/R-26~1.1/library/tcltk/libs/tcltk.dll': LoadLibrary failure: The specified module could not be found. Error: .onLoad failed in 'loadNamespace' for 'tcltk' How can I fix it? Thanks in advance > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) __ R-help@r-project.org mailing list 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] Fail to open R 2.6.1
R-help, I opened an R session ( R 2.6.0 on Windows) and got the following pop-up window: "This application has failed to start because tk84.dll was not found. Re-installing the application may fix the problem" I have now upgraded to R 2.6.1 but the same fatal error comes up. Can someone let me know what is going on? Thanks in advance. __ R-help@r-project.org mailing list 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] print " character
R-help, Sorry if this question has been discussed/posted before but I can't just find it myself. How can I print the comment character (") ? Thanks in advance __ R-help@r-project.org mailing list 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] Unable to save plot as ".pdf" , "ps" , "eps"
R-help, Whenever I try to save a plot with extension ".pdf" , "ps" or "eps" I get the following error/warning message: plot(rnorm(10)) savePlot("test",type="pdf") Error in savePlot("test", type = "pdf") : Invalid font type In addition: Warning messages: 1: In savePlot("test", type = "pdf") : font family not found in PostScript font database 2: In savePlot("test", type = "pdf") : font family not found in PostScript font database Can anyone let me know wht it is going on Thanks in advance > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.0 year 2007 month 10 day03 svn rev43063 language R version.string R version 2.6.0 (2007-10-03) __ R-help@r-project.org mailing list 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] manipulating 3-way array
R-Help, I have a 3 dimensional array with dimensions: > dim(test) [1] 241 104 12 I copy-paste an example of the object > test[1:5,1:5,1:2] , , ar = 1996 slagnr puntar12 34 5 I1 60.30303 36.50610 0 0.0 0 I10 58.19512 35.48209 0 75.0 0 I11 0.0 0.0 0 0.0 0 I13 57.47000 33.84501 0 67.3 0 I15 57.21971 41.59078 0 0.0 54 , , ar = 1997 slagnr puntar12 3 4 5 I1 54.32000 42.75032 0 0 51 I10 59.04167 41.16009 0 0 0 I11 0.0 0.0 0 0 0 I13 55.18274 40.59340 0 0 0 I15 58.64486 43.91055 0 0 0 There are many columns which are zero and I wish to get rid of them and do the following: for(i in 1:12) { ind0 <- apply(test[,,i], 2, sum) != 0 DIM <- dim(test[, ind0, i]) testU0 <- array(0, dim = DIM) testU0 <- test[, ind0, i] } but this will override the object testU0 every time the loop is run Is there a nicer and simpler solution for this? Thanks in advance > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 6.0 year 2007 month 10 day03 svn rev43063 language R version.string R version 2.6.0 (2007-10-03) > __ R-help@r-project.org mailing list 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.