Re: [R] sm.options
Viviana Ruiz vivruiz at gmail.com writes: I am doing kernel density plots, and am trying to make the lines thicker. I comparing three groups, in sm.density.compare. I tried changing lwd to make the line sthicker right on the density compare call, but was not able to do it. There is not an option in sm.options to specify line thickness, as well as cex.ylab or cex.xlab- I tried it and it does not change the thickness of the lines. Does anyone know how to do this? If you pring sm.density.compare (without the ()), you will notice that lwd is not passed to the lines() function, nor are ... parameters available. So the only choice is to globally set par(lwd=2) Which give a result that looks reasonable for a slide. Dieter __ 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] sm.options
Hi Viviana, I am doing kernel density plots, and am trying to make the lines thicker. You need to hack the code for sm.density.compare. See the code below. This uses the same defaults as the original, but you can customize band colour, line width, and so on using arguments to the function. The easiest way to use it is to copy it into your environment space. The original code is untouched and may be accessed as sm:::sm.density.compare(). Regards, Mark. ## Hack on sm.density.compare ## Allows me to change colour of the band, to set ylim, and change lwd (was only for ## model=equal option) sm.density.compare - function (x, group, h, model = none, bandcol = 'cyan', lwd = par(lwd), usePolyg = NULL, asp=NA, xlab=opt$xlab, ylab=opt$ylab, ...) { if (!is.vector(x)) stop(sm.density.compare can handle only 1-d data) opt - sm.options(list(...)) sm:::replace.na(opt, ngrid, 50) ## These all changed from replace.na() -- sm::: sm:::replace.na(opt, display, line) sm:::replace.na(opt, xlab, deparse(substitute(x))) sm:::replace.na(opt, ylab, Density) sm:::replace.na(opt, xlim, c(min(x) - diff(range(x))/4, max(x) + diff(range(x))/4)) sm:::replace.na(opt, eval.points, seq(opt$xlim[1], opt$xlim[2], length = opt$ngrid)) if (is.na(opt$band)) { if (model == none) opt$band - FALSE else opt$band - TRUE } if ((model == none) opt$band) opt$band - FALSE band - opt$band ngrid - opt$ngrid xlim - opt$xlim nboot - opt$nboot y - x if (is.na(opt$test)) { if (model == none) opt$test - FALSE else opt$test - TRUE } if ((model == none) opt$test) opt$test - FALSE test - opt$test if (opt$display %in% none) band - FALSE fact - factor(group) fact.levels - levels(fact) nlev - length(fact.levels) ni - table(fact) if (band (nlev 2)) { cat(Reference band available to compare two groups only., \n) band - FALSE } if (length(opt$lty) nlev) opt$lty - 1:nlev if (length(opt$col) nlev) opt$col - 2:(nlev + 1) if (missing(h)) h - h.select(x, y = NA, group = group, ...) opt$band - band opt$test - test estimate - matrix(0, ncol = opt$ngrid, nrow = nlev) se - matrix(0, ncol = opt$ngrid, nrow = nlev) for (i in 1:nlev) { sm - sm.density(y[fact == fact.levels[i]], h = h, display = none, eval.points = opt$eval.points) estimate[i, ] - sm$estimate se[i, ] - sm$se } eval.points - sm$eval.points if (!(opt$display %in% none | band)) { plot(xlim, c(0, 1.1 * max(as.vector(estimate))), xlab = opt$xlab, ylab = opt$ylab, type = n) #for (i in 1:nlev) lines(eval.points, estimate[i, ], lty = opt$lty[i], #col = opt$col[i]) for (i in 1:nlev) lines(eval.points, estimate[i, ], lty = opt$lty[i], ## lwd hacked in col = opt$col[i], lwd = lwd[i]) } est - NULL p - NULL if (model == equal test) { if (nlev == 2) { ts - sum((estimate[1, ] - estimate[2, ])^2) } else { sm.mean - sm.density(y, h = h, xlim = opt$xlim, ngrid = opt$ngrid, display = none)$estimate ts - 0 for (i in 1:nlev) ts - ts + ni[i] * sum((estimate[i, ] - sm.mean)^2) } p - 0 est.star - matrix(0, ncol = opt$ngrid, nrow = nlev) for (iboot in 1:nboot) { ind - (1:length(y)) for (i in 1:nlev) { indi - sample((1:length(ind)), ni[i]) est.star[i, ] - sm.density(y[ind[indi]], h = h, ngrid = opt$ngrid, xlim = opt$xlim, display = none)$estimate ind - ind[-indi] } if (nlev == 2) { ts.star - sum((est.star[1, ] - est.star[2, ])^2) } else { sm.mean - sm.density(y, h = h, xlim = opt$xlim, ngrid = opt$ngrid, display = none)$estimate ts.star - 0 for (i in 1:nlev) { ts.star - ts.star + ni[i] * sum((est.star[i, ] - sm.mean)^2) } } if (ts.star ts) p - p + 1 if (opt$verbose 1) { cat(iboot) cat( ) } } p - p/nboot cat(\nTest of equal densities: p-value = , round(p, 3), \n) est - list(p = p, h = h) } if (model == equal band) { av - (sqrt(estimate[1, ]) + sqrt(estimate[2, ]))/2 se - sqrt(se[1, ]^2 + se[2, ]^2) upper - (av + se)^2 lower - pmax(av - se, 0)^2 plot(xlim, c(0, 1.1 * max(as.vector(estimate), upper)), xlab = xlab, ylab = ylab, type = n, asp=asp, ...) ## ... and asp
Re: [R] RV: help
Jani Lobo lobo at grupocomar.com writes: I want to estimate the survival mean of a few specific teams. I'm trying to calculate it through a Kaplan Meier estimator. For doing so, I load the survival package and run the following instructions: options(survfit.print.mean=TRUE) allows showing the mean and mean standard error KM=survfit(Surv(Dias,Censura)) runs the model KM shows the model It is in this very moment when it shows the mean value and the mean standard error. I'd like to know if there is any instruction that returns the mean value and its standard error, something like: KM$rmean It's always good to use an example that can be run by other people, and it is easy: just use the example from the documentation library(survival) fit - survfit(Surv(time, status) ~ x, data=aml) # str tells you what fit has to offer str(fit) ### Too bad, no summary data available here, looks ## like print.survfit does the job getAnywhere(print.survfit) Checking the code: there are a lot of print statements in here, and the summary results are not returned. Now you have two choices: either use the code from print.survfit, copy it, and get the values you need from a changed function. Can be some work. Or check if someone else has done the work for you, and bingo: summary.survfit in package Design looks like it is doing the job. Dieter summary.survfit {Design} __ 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] Regressão linear
On Thu, 2009-03-05 at 02:20 +, Ben Bolker wrote: Sueli Rodrigues srodrigu at esalq.usp.br writes: Olá. Tenho um arquivo que a cada 6 linhas corresponde uma amostra da qual preciso dos coeficientes da regressão linear. Como faço para que o programa distinga a cada 6 linhas como uma amostra e não calcule como um todo? Estou usando a função: model=lm(y ~ x) You're more likely to get a response if you post to the list in English (even fractured English). Based on what Google translator thinks you said (you want to perform linear regressions on 6-line subsets of a data set?), here's a starting point (assuming your data are in a data frame mydata, and have column names x and y): splitdat - split(mydata,rep(1:6,length.out=nrow(mydata)) linfits - lapply(splitdata,lm,formula=y~x) coefs - sapply(linfits,coef) or something like that. Ben Bolker Hi Ben Bolker First of all I would like to thank the kindness with my countrywoman. Second in her problem each 6 rows is a subset for a linear regression so the command is splitdat - split(mydata,rep(1:(nrow(mydata)/6),each=6)) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ 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] Automatically execute traceback when execution of script causes error?
Hi I am using R scripts which are running remotely. To make debugging easier, I would like to have the possibility to execute traceback() automatically when an error occurs. Is this possible? OS: Linux Thanks Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ 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] Odp: nice way to find or not a value (problem with numeric(0))
Hi r-help-boun...@r-project.org napsal dne 05.03.2009 15:21:22: Hello Petr, In fact spec is data.frame with a column called code (containing numerical values) and some other columns called data1, data2, ... containing data for each equipment (that is for each code). But I don't have the data for all my devices. It means that some 'code' are not in spec$Code. In that case I want to assign a default value to the data. for example : spec$Code spec$data1 4 12.5 820.2 Then, with code=4 spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) gives 12.5 But with code=654, I get numeric(0) instead of 1 because this value is not in spec$Code and returns numeric(0). I hope it is clearer (is it ?) and that you could find a nice way to write my test (the if-test works but is not very elegant). Not much. Guess what I get using your code? If you think it is 12.5 you are mistaken. spec code data1 14 12.5 28 20.2 code=4 spec$data1[spec$code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) Error in inherits(x, factor) : object specmodules not found This is why you shall provide reproducible code. Now I still need to only **think** what you want to do. Maybe merge is what you want Having spec like above and test-data.frame(code = c(4,5,8,12), value= c(10, 20, 30,40)) then merge(test, spec, by=code, all.x=T) code value data1 1410 12.5 2520NA 3830 20.2 4 1240NA Gives you new data frame which you can then filter by is.na and which to replace NA values with standard ones. Regards Petr Thanks in adance for you help, Ptit Bleu. Petr Pikal wrote: Hi r-help-boun...@r-project.org napsal dne 04.03.2009 09:11:06: Hello, I have a data.frame called spec containing data about samples. But I don't have these data for all my samples. So if I have data (that is code of the sample is in spec$Code), I would like to assign data1 to the variable m. If I don't have this data, I would like to assign 1 to m. I tried this : m-spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) It works when I have the data but if it is not the case I get numeric(0) instead of 1. I finally use the following command. It works but I'm sure there is a more elegant way. if (code %in%spec$Code) m-spec$data1[spec$Code==code] else m-1 It is a bit cryptic what do you want. Above version shall not work as it takes only one logical value but you probably have vector of values. (We do not know code, spec$Code or any other data you have). when I try your first construction with some values I have I get sensible results so without trying to find out how your data really look like I suggest you to inspect it more closely and/or provide some working example demonstrating what you did, what is the result and how the result shall look like. zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 10 1 120 80 50 20 zdrz$otac[5]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 1 1 120 80 50 20 zdrz$sklon[4]-Inf zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 Inf 1 1 120 80 50 20 zdrz$sklon[4]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 NA 1 1 120 80 50 20 Regards Petr Is there a way to avoid an if-test ? Thanks for your help, Have a good day, Ptit Bleu. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a- value-%28problem-with-numeric%280%29%29-tp22325406p22325406.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. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a- value-%28problem-with-numeric%280%29%29-tp22325406p22352529.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
[R] PCA and categorical data
Hi all, I' m trying to figure out if it is appropriate to do a PCA having only categorical data (not ordinal). I have only find the following quote: One method to find such relationships is to select appropriate variables and to view the data using a method like Principle Components Analysis (PCA) [4]. This approach gives us a clear picture of the data using KL-plot of the PCA. However, the method is not settled for the data including categorical data. [http://hp.vector.co.jp/authors/VA038807/personal/covEigGiniRep17.pdf] but I'm still not sure if it WRONG to do so. Any opinion or reference would be very helpful 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.
[R] Ask about glm()
Hi, I am using glm(). I'd like to know what the command means. For example, glm(family=binomial(link=logit)) means logit model. Then, glm(family=gaussian(link=logit)), does this mean? Thank you in advance. Kenji. A Analysis Manager SPI - Strategy, Productivity, Insight., Japan __ 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] Automatically execute traceback when execution of script causes error?
On Fri, 6 Mar 2009, Rainer M Krug wrote: Hi I am using R scripts which are running remotely. To make debugging easier, I would like to have the possibility to execute traceback() automatically when an error occurs. Is this possible? See options 'error' and 'showErrorCalls'. The latter is the default in batch use of R, and its compact traceback is found to be sufficient by many of us. If 'remotely' means interactively, consider options(error=recover). It might help to review section 4.2 of 'Writing R Extensions'. OS: Linux Thanks Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] PCA and categorical data
You might want to look into correspondence analysis, which has several variants of PCA designed for categorical data. On Fri, 6 Mar 2009, Galanidis Alexandros wrote: Hi all, I' m trying to figure out if it is appropriate to do a PCA having only categorical data (not ordinal). I have only find the following quote: One method to find such relationships is to select appropriate variables and to view the data using a method like Principle Components Analysis (PCA) [4]. This approach gives us a clear picture of the data using KL-plot of the PCA. However, the method is not settled for the data including categorical data. [http://hp.vector.co.jp/authors/VA038807/personal/covEigGiniRep17.pdf] but I'm still not sure if it WRONG to do so. Since normally categorical data is taken to be binomial or Poisson distributed, the variance varies with the mean and least-squares (the basis of PCA) is then sub-optimal. Correspondence analysis takes that into account (at least to some extent). Any opinion or reference would be very helpful There is a basic introduction in MASS4, with references to more comprehensive accounts. 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] PCA and categorical data
On 06-Mar-09 09:25:26, Prof Brian Ripley wrote: You might want to look into correspondence analysis, which has several variants of PCA designed for categorical data. In particular, have a look at the results of RSiteSearch(correspondence) Ted. On Fri, 6 Mar 2009, Galanidis Alexandros wrote: Hi all, I' m trying to figure out if it is appropriate to do a PCA having only categorical data (not ordinal). I have only find the following quote: One method to find such relationships is to select appropriate variables and to view the data using a method like Principle Components Analysis (PCA) [4]. This approach gives us a clear picture of the data using KL-plot of the PCA. However, the method is not settled for the data including categorical data. [http://hp.vector.co.jp/authors/VA038807/personal/covEigGiniRep17.pdf] but I'm still not sure if it WRONG to do so. Since normally categorical data is taken to be binomial or Poisson distributed, the variance varies with the mean and least-squares (the basis of PCA) is then sub-optimal. Correspondence analysis takes that into account (at least to some extent). Any opinion or reference would be very helpful There is a basic introduction in MASS4, with references to more comprehensive accounts. 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 06-Mar-09 Time: 09:46:15 -- XFMail -- __ 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] dummy variable encoding
The best encoding depends upon which language you would like to manipulate the variable in. In R, genders are most naturally represented as factors. That means that in an external data source (like a spreadsheet of data), you should ideally have the gender recorded as human-understandable text (male and female, or M and F). Once the data is read into R, by default R will convert the string to factors (keeping the human readable labels). This way you avoid having to remember that 1 means male (or whatever). If you were manipulating the data in a different language that didn't have factors, then it might be more appropriate to use an integer. Which integers you use doesn't matter, you need to have a look-up table to know what each number refers to, whatever you choose. Yes, that's what I thought. However somebody told me that it is better to use 1/2 rather than 0/1 for a 2 level factor such as gender, and I've no idea why. I told them it didn't matter, but have since seen quite a few examples where they use 1/2 (admittedly in SPSS). The only benefit that I can see of using 1/2 instead of 0/1 is fairly minor. If you have cases where there are missing values, and you are working in a language that doesn't support NA values for integers (or factors; I'm thinking of something like C), then you could encode your genders as 0: not recorded 1: female 2: male Then you can include logic like if(gender) { do something } The alternative encoding of 0/1, would be something like -1: not recorded 0: female 1: male This makes the code slightly less pretty. if(gender != -1) { do something } Again, none of this really applies to R, since you should be using factors for this sort of variable. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ 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] PCA and categorical data
Hi Galandis, dudi.mix() in package ade4 does PCA using categorical and/or quantitative variables. Ordered cats are replaced by poly(x, deg=2). Squares of categoricals can also be used. The method is a generalization by Chessel of the method of Hill and Smith. Regards, Mark. Galanidis Alexandros wrote: Hi all, I' m trying to figure out if it is appropriate to do a PCA having only categorical data (not ordinal). I have only find the following quote: One method to find such relationships is to select appropriate variables and to view the data using a method like Principle Components Analysis (PCA) [4]. This approach gives us a clear picture of the data using KL-plot of the PCA. However, the method is not settled for the data including categorical data. [http://hp.vector.co.jp/authors/VA038807/personal/covEigGiniRep17.pdf] but I'm still not sure if it WRONG to do so. Any opinion or reference would be very helpful 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. -- View this message in context: http://www.nabble.com/PCA-and-categorical-data-tp22368671p22369249.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.
Re: [R] R editor that will work with Rcmdr
John Sorkin jsorkin at grecc.umaryland.edu writes: R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John Hi John, From my experience, while (X)Emacs + ESS or JGR work with Rcmdr under Linux, there can be problems using either of these in conjunction with Rcmdr under Windows. From John Fox's own 'An Introduction to ESS + XEmacs for Windows Users of R': The Rcmdr package does not run reliably under XEmacs/ESS for Windows. On Windows XP at least, this still seems to be the case - for me it always ends up crashing R. Under Windows, Tinn-R and Notepad++ with NppToR (http://sourceforge.net/projects/npptor/) work fine alongside Rcmdr, but both of them are Windows only. Other IDEs such as Eclipse I haven't tested. Hope this is helpful, Michael Bibo Queensland Health __ 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] Re : PCA and categorical data
See homals package in R. But also look documents for ade4 package. Justin BEM BP 1917 Yaoundé Tél (237) 76043774 De : Galanidis Alexandros a...@env.aegean.gr À : r-help@r-project.org r-help@r-project.org Envoyé le : Vendredi, 6 Mars 2009, 10h09mn 18s Objet : [R] PCA and categorical data Hi all, I' m trying to figure out if it is appropriate to do a PCA having only categorical data (not ordinal). I have only find the following quote: One method to find such relationships is to select appropriate variables and to view the data using a method like Principle Components Analysis (PCA) [4]. This approach gives us a clear picture of the data using KL-plot of the PCA. However, the method is not settled for the data including categorical data. [http://hp.vector.co.jp/authors/VA038807/personal/covEigGiniRep17.pdf] but I'm still not sure if it WRONG to do so. Any opinion or reference would be very helpful 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. [[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] function ctree in package party
Hi Maxl18, error in mo...@fit(data,...) : object var3 not found What should I do? Make sure that var3 exists/is available ## str(datalist$var3) ## is it here? ls(pattern=var3) ## is it here? Regards, Mark. Maxl18 wrote: Hi, I have a problem with the function ctree in the package party. When I launch ctree with weights=NULL it works. ctree(function~var1+var2, data=datalist, weights=NULL, controls=ctree_control(mincriterion=0.95, maxdepth=4, teststat=quad,testtype=Bonferroni)) But when I try ctree(function~var1+var2, data=datalist, weights=var3, controls=ctree_control(mincriterion=0.95, maxdepth=4, teststat=quad,testtype=Bonferroni)) there`s an error message error in mo...@fit(data,...) : object var3 not found What should I do? Thanks -- View this message in context: http://www.nabble.com/function-ctree-in-package-party-tp22369191p22369456.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.
Re: [R] File checking problem
HI,Barry. Thanks a lot for your details reply. I have already rewritten the programs. Now it totally works. Your comment: Note the use of comments and breaking the code up into small independent, testable functions is really Valuable! Thanks again. Hi,David, You are right, My previous code was really horrible. Its not good to make multiple codes at the same time, sometime I feel really confused about the original one. About Your comment: You should indent and space around more things ( - for example). And either use = for assignment or -, don't use both in the same bit of code., At the moment, I am still feeling confused about the different usage of - and =?? Now I have seperated the code into pieces, now it works. Thanks a lot. Hi Brian, Thanks for your suggestion. Seems the error is not when i call list.file. The true error is what i quote from Barry's suggestion: name = list.files(...) for(k in 1:length(name)){ log1 = read.table(name[k],) while(something){ k =k + 1 log1 = read.table(name[k],...) # 1 } } What will happen is that when the last file is read at point #1, the loop goes round again, k becomes more than the length of name, and it will fail at #1 again. Thanks for all your concentration. Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] How to apply a function to slices of multidimensional arrays, and not just iterating through single elements
Hello, If I want to apply some f(x) to such chunks of the the array dim(A)==c(d1,d2,d3,..,dk,...,dn) which are defined by A[...,ik,...] (ik belongs to {1,..,dk}), for now I use iteration via 'for (i in dim(A)[k]) f(A[...,k,...])' . Is there any more elegant approach, e.g like in 'apply' function which you can use on margin of the array. Just in my case I want the entire slice defined by margin to be an argument to my f(x), not just element-by-element. If the former is too confusing: A - array dim(A)=c(3,4,5) f(x) - function; x is argument dim(x)=c(3,5) A has 4 slices of dim c(3,5) I want my result to be a vector c( f(A[,1,]), f(A[,2,]), f(A[,3,]), f(A[,4,]) ) Until now I was doing 'for (i in 1:4) res[i]-f(A[,i,])' . Is there a more efficient way of doing this, maybe some predefined function? Cheers, TK __ 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] modifying a built in function from the stats package (fixing arima) (CONCLUSIONS)
Thanks a lot to everybody that helped me out with this. Conclusions: (1) In order to edit arima in R: fix(arima) or alternatively: arima-edit(arima) (2) This is not contained in the Introduction to R manual. (3) A productive fix of arima is attached (arma coefficients printed out and error catched so that it doesn't halt parent loops to search for candidate coefficients): Note 1: productive means I'm a beginner in R so there is probably a better way to print the error message and fill the output arguments (I only return NA in aic,var and sigma2). Note 2: Changing BFGS to NelderMead in exitpoint 0 changes the coefficients for which arima can't fit a model but results in terms of aic and sigma2 also change significantly. By visual inspection I think that BFGS works better. function (x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA), xreg = NULL, include.mean = TRUE, transform.pars = TRUE, fixed = NULL, init = NULL, method = c(CSS-ML, ML, CSS), n.cond, optim.control = list(), kappa = 1e+06) { %+% - function(a, b) .Call(R_TSconv, a, b) upARIMA - function(mod, phi, theta) { p - length(phi) q - length(theta) mod$phi - phi mod$theta - theta r - max(p, q + 1) if (p 0) mod$T[1:p, 1] - phi if (r 1) mod$Pn[1:r, 1:r] - .Call(R_getQ0, phi, theta) else if (p 0) mod$Pn[1, 1] - 1/(1 - phi^2) else mod$Pn[1, 1] - 1 mod$a[] - 0 mod } arimaSS - function(y, mod) { .Call(R_ARIMA_Like, y, mod$phi, mod$theta, mod$Delta, mod$a, mod$P, mod$Pn, as.integer(0), TRUE) } armafn - function(p, trans) { par - coef par[mask] - p trarma - .Call(R_ARIMA_transPars, par, arma, trans) Z - upARIMA(mod, trarma[[1]], trarma[[2]]) if (ncxreg 0) x - x - xreg %*% par[narma + (1:ncxreg)] res - .Call(R_ARIMA_Like, x, Z$phi, Z$theta, Z$Delta, Z$a, Z$P, Z$Pn, as.integer(0), FALSE) s2 - res[1]/res[3] 0.5 * (log(s2) + res[2]/res[3]) } armaCSS - function(p) { par - as.double(fixed) par[mask] - p trarma - .Call(R_ARIMA_transPars, par, arma, FALSE) if (ncxreg 0) x - x - xreg %*% par[narma + (1:ncxreg)] res - .Call(R_ARIMA_CSS, x, arma, trarma[[1]], trarma[[2]], as.integer(ncond), FALSE) 0.5 * log(res) } arCheck - function(ar) { p - max(which(c(1, -ar) != 0)) - 1 if (!p) return(TRUE) all(Mod(polyroot(c(1, -ar[1:p]))) 1) } maInvert - function(ma) { q - length(ma) q0 - max(which(c(1, ma) != 0)) - 1 if (!q0) return(ma) roots - polyroot(c(1, ma[1:q0])) ind - Mod(roots) 1 if (all(!ind)) return(ma) if (q0 == 1) return(c(1/ma[1], rep(0, q - q0))) roots[ind] - 1/roots[ind] x - 1 for (r in roots) x - c(x, 0) - c(0, x)/r c(Re(x[-1]), rep(0, q - q0)) } series - deparse(substitute(x)) if (NCOL(x) 1) stop(only implemented for univariate time series) method - match.arg(method) x - as.ts(x) if (!is.numeric(x)) stop('x' must be numeric) storage.mode(x) - double dim(x) - NULL n - length(x) if (!missing(order)) if (!is.numeric(order) || length(order) != 3 || any(order 0)) stop('order' must be a non-negative numeric vector of length 3) if (!missing(seasonal)) if (is.list(seasonal)) { if (is.null(seasonal$order)) stop('seasonal' must be a list with component 'order') if (!is.numeric(seasonal$order) || length(seasonal$order) != 3 || any(seasonal$order 0)) stop('seasonal$order' must be a non-negative numeric vector of length 3) } else if (is.numeric(order)) { if (length(order) == 3) seasonal - list(order = seasonal) else ('seasonal' is of the wrong length) } else stop('seasonal' must be a list with component 'order') if (is.null(seasonal$period) || is.na(seasonal$period) || seasonal$period == 0) seasonal$period - frequency(x) arma - as.integer(c(order[-2], seasonal$order[-2], seasonal$period, order[2], seasonal$order[2])) narma - sum(arma[1:4]) xtsp - tsp(x) tsp(x) - NULL Delta - 1 for (i in seq_len(order[2])) Delta - Delta %+% c(1, -1) for (i in seq_len(seasonal$order[2])) Delta - Delta %+% c(1, rep(0, seasonal$period - 1), -1) Delta - -Delta[-1] nd - order[2] + seasonal$order[2] n.used - sum(!is.na(x)) - length(Delta) if (is.null(xreg)) { ncxreg - 0 } else { nmxreg - deparse(substitute(xreg)) if (NROW(xreg) != n) stop(lengths of 'x' and 'xreg' do not match)
Re: [R] How to apply a function to slices of multidimensional arrays, and not just iterating through single elements
well, you can still use apply(), e.g., A - array(rnorm(3*4*5), c(3, 4, 5)) f - sum out - numeric(4) for (i in 1:4) out[i] - f(A[, i, ]) out apply(A, 2, f) I hope it helps. Best, Dimitris Todor Kondic wrote: Hello, If I want to apply some f(x) to such chunks of the the array dim(A)==c(d1,d2,d3,..,dk,...,dn) which are defined by A[...,ik,...] (ik belongs to {1,..,dk}), for now I use iteration via 'for (i in dim(A)[k]) f(A[...,k,...])' . Is there any more elegant approach, e.g like in 'apply' function which you can use on margin of the array. Just in my case I want the entire slice defined by margin to be an argument to my f(x), not just element-by-element. If the former is too confusing: A - array dim(A)=c(3,4,5) f(x) - function; x is argument dim(x)=c(3,5) A has 4 slices of dim c(3,5) I want my result to be a vector c( f(A[,1,]), f(A[,2,]), f(A[,3,]), f(A[,4,]) ) Until now I was doing 'for (i in 1:4) res[i]-f(A[,i,])' . Is there a more efficient way of doing this, maybe some predefined function? Cheers, TK __ 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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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 ctree in package party
Hi, I have a problem with the function ctree in the package party. When I launch ctree with weights=NULL it works. ctree(function~var1+var2, data=datalist, weights=NULL, controls=ctree_control(mincriterion=0.95, maxdepth=4, teststat=quad,testtype=Bonferroni)) But when I try ctree(function~var1+var2, data=datalist, weights=var3, controls=ctree_control(mincriterion=0.95, maxdepth=4, teststat=quad,testtype=Bonferroni)) there`s an error message error in mo...@fit(data,...) : object var3 not found What should I do? Thanks -- View this message in context: http://www.nabble.com/function-ctree-in-package-party-tp22369191p22369191.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.
Re: [R] including tabular information with a plot in R Graphics
Hi all, Thanks very much for the suggestions. My experience for the benefit of others is: - use addtable2plot if you want a fancier legend or small table *within* a plot area - use textplot if you want combinations of tables and text listings in the graphics device. The help for textplot gives a very good example Thanks again, Richie 2009/3/5 Eik Vettorazzi e.vettora...@uke.uni-hamburg.de Hi Richie, have a look at textplot() from the gplots-package. hope, it helps! R User R User schrieb: Hi all, I have a presentation problem that I cannot find a solution to in the documetnation. I have a nice barplot. Below this I would also like a table with some information relating to the plot. My idea was to have the plot and table on the same graphics window so I can output them as an image file for a report. Does anybody know how to include tabular information from a dataset or table into the graphics device? Is there a better/more correct way to output tables and graphics to a single file? Thanks very much, Richie [[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. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 [[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] How to apply a function to slices of multidimensional arrays, and not just iterating through single elements
If I well understand, maybe you have still apply at your disposal: arrayA - 1:60 dim(arrayA) - c(3,4,5) apply(arrayA, 2, sum) You have the same result of: res-numeric(4);for (i in 1:4) res[i]-sum(arrayA[,i,]) Ciao, domenico PS: have a look at plyr package for more slicing and applying functions Todor Kondic wrote: Hello, If I want to apply some f(x) to such chunks of the the array dim(A)==c(d1,d2,d3,..,dk,...,dn) which are defined by A[...,ik,...] (ik belongs to {1,..,dk}), for now I use iteration via 'for (i in dim(A)[k]) f(A[...,k,...])' . Is there any more elegant approach, e.g like in 'apply' function which you can use on margin of the array. Just in my case I want the entire slice defined by margin to be an argument to my f(x), not just element-by-element. If the former is too confusing: A - array dim(A)=c(3,4,5) f(x) - function; x is argument dim(x)=c(3,5) A has 4 slices of dim c(3,5) I want my result to be a vector c( f(A[,1,]), f(A[,2,]), f(A[,3,]), f(A[,4,]) ) Until now I was doing 'for (i in 1:4) res[i]-f(A[,i,])' . Is there a more efficient way of doing this, maybe some predefined function? Cheers, TK __ 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] Extract dates from dataframe
Hi, I have the following dataframe: IDDates 1 16-07-01 06-10-95 224/01/02 06-10-95 3 16/01/02 16/08/94 12/01/91 And I would like to extract the dates, but couple the ID's to the right dates, eg: ID Dates 116-07-01 106-10-95 224-01-02 2 I have no clue about how to get started, looks something for the regexp/grep/... kind of functions, but I don't get the point. Any thoughts?? Kind regards Bart Joosen PS: for the reconstruction of the dataframe: dat - structure(list(ID = c(1, 2, 3), Dates = structure(c(2L, 4L, 6L ), .Label = c(16-01-02 16-08-94, 16-07-01 06-10-95, 24-01-02 06-10-95, 24/01/02 06-10-95, 16/01/02 16/08/94, 16/01/02 16/08/94 12/01/91 ), class = factor)), .Names = c(ID, Dates), row.names = c(NA, 3L), class = data.frame) -- View this message in context: http://www.nabble.com/Extract-dates-from-dataframe-tp22369479p22369479.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] fitting a gompertz model through the origin using nls
Dear all! I tried to fit Gompertz growth models to describe cummulative germination rates using nls. I used the following code: germ.model-nls(percent.germ~a*exp(-b*exp(-k*day)),data=tab,start=list(a=100,b=10,k=0.5)) My problem is that I want that the fitted model goes through the origin, since germination cannot start before the experiment was started, and y-max should be 100. Does anyone know how I can achieve this? Thanks a lot in advance! Swantje __ 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] impcat='tree'
Dear All, I am going through a worked example provided by Harrell, Lee and Mark (1996, Stats in Medicine, 15, 361-387). I know that the code provided is for S-PLUS and R but the languages don't differ enough for this to be a problem. I am using the Hmisc and Design libraries and have used the following code (as shown in the example provided in the referenced paper): '%in%' - function(a,b)match(a,b,nomatch=0)0 # Define function for easy determination of whether a value is in a list levels(ekg)[levels(ekg)%in%c('oldMI','recentMI')] - 'MI' # Combines last 2 levels and uses a new name, MI pf.coded - as.integer(pf) # Save original pf, re-code to 1-4 levels(pf) - c(levels(pf)[1:3],levels(pf)[3]) # Combine last 2 levels of original This is where I have the problem. I am writing an imputation rule: w - transcan(~sz+sg+ap+sbp+dbp+age+wt+hg+ekg+pf+bm+hx,imputed=TRUE,data=prostate,impcat='tree') However I get the following error message(s) Convergence criterion:1.511 0.787 0.41 0.215 0.115 0.062 Error: could not find function tree In addition: Warning messages: 1: In approx(y, x, xout = aty, rule = rule) : collapsing to unique 'x' values 2: In approx(y, x, xout = aty, rule = rule) : collapsing to unique 'x' values 3: In approx(y, x, xout = aty, rule = rule) : collapsing to unique 'x' values 4: In approx(y, x, xout = aty, rule = rule) : collapsing to unique 'x' values Has anyone had a similar problem? If so, any solution? Thank you, Laura __ 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] Re peated ANOVA or nested ANOVA, or parallel one way ANOVA six times?
Hi, every body! I am a new comer for R, so my question would unavoidablely sounds stupid. Sorry! In my experiment, there are two type of soil ( soil F and soil D), each half of them were subjected to steam sterilize (result in FS and DS soil). A equal volume of soil from two of the four soil types (F, D, FS, DS) were mixed as follows: F+F, F+D, F+FS, F+DS, D+F, D+FS, D+DS, FS+DS (eight treatment). Two type of plant (A, B) were planted in the eight treatment of soil in pot. There were 40 pots divided into 5 groups (8 pots for each group) for each treatment*plant combination. Finally there were 80 groups for plant A and B in total. The 40 groups for plant A were randomly arranged in plot 1, and for plant B in plot 2. The experiment were sampled for three times. In each sampling date, one pot was randomly choosing from each group to measure biomass (80 pot for sampling date). Now my question are as follow: If different plant respond to soil treatment differently? If plant's react to soil treatment deppends on time? If soil F and D differed significantly in effects on plant biomass? If soil sterilization have any aditional effects on plant biomass in this experiment? Which is the most important factor for biomass accumulation? I can't figure out wether a repeated ANOVA or nested ANOVA, or a parallel one way ANOVA six times is right for this experiment. It seems not so feasible to run six paralle one way ANOVA for each plant and sampling date combination for the questions above. It takes me a long time to learn lme4 package in R, but till now fruitless. Would anybody recommend me a model and formula for these questions? Thank you! Now you can see, my English is equally well as my statistics! Sorry again! Jane Ding -- View this message in context: http://www.nabble.com/Repeated-ANOVA-or-nested-ANOVA%2C-or-parallel-one-way-ANOVA-six-times--tp22370060p22370060.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.
Re: [R] how to omit NA without using ifelse
?is.na Manli Yan wrote: I have a 50*50 matrix,some entry are NAs,I want to replace these NA by 0,so can I use some syntax to do so other than using ifelse? I tried to use replace(a,NA,0),it didnt work~~(a is matrix name) Thanks~ [[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. -- View this message in context: http://www.nabble.com/how-to-omit-NA-without-using-ifelse-tp22365996p22371063.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] About warnings for non-matched items
Dear All, I have many files in my directory. I want to transfer each data into one which is readable. They have so many possibilities, i have collected(manually and visually) all possibilities and represent them as different numbers. Rep[grep('context_log',log1$Remain[1:length(log1$Date)]),]-2 Rep[grep('gs',log1$Remain[1:length(log1$Date)]),]-5 Rep[grep('ClockApp',log1$Remain[1:length(log1$Date)]),]-6 Rep[grep('mce',log1$Remain[1:length(log1$Date)]),]-7 .. I manually collect all possibilities contained in all files!!!(manually and visually: this process is so time-consuming, can i have better ideal to collect all possibilities by computer rather than by myself?) The programs are fine, but each file doesn't match all possibilities, whenever there are non-matched items with above, then warning information come ups: 31: In max(i) ... : no non-missing arguments to max; returning -Inf 32: In max(i) ... : no non-missing arguments to max; returning -Inf 33: In max(i) ... : no non-missing arguments to max; returning -Inf they returns non-matched items. How to vanish those warnings? Thanks a lot. Tammy _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx [[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] Extract dates from dataframe
Try this: library(gsubfn) # convert date strings to dd-mm-yy Dates - gsub(/, -, dat$Dates) # regular expressiont to match dates re - \\d\\d-\\d\\d-\\d\\d # extract dates and convert them to Date class # giving a list d each of whose components is a vector of dates d - strapply(Dates, re, ~ as.Date(x, %d-%m-%y), perl = TRUE) names(d) - dat$ID # combine them into a single data frame do.call(rbind, lapply(dat$ID, function(id) data.frame(ID = id, Date = d[[id]]))) On Fri, Mar 6, 2009 at 6:17 AM, bartjoosen bartjoo...@hotmail.com wrote: Hi, I have the following dataframe: ID Dates 1 16-07-01 06-10-95 2 24/01/02 06-10-95 3 16/01/02 16/08/94 12/01/91 And I would like to extract the dates, but couple the ID's to the right dates, eg: ID Dates 1 16-07-01 1 06-10-95 2 24-01-02 2 I have no clue about how to get started, looks something for the regexp/grep/... kind of functions, but I don't get the point. Any thoughts?? Kind regards Bart Joosen PS: for the reconstruction of the dataframe: dat - structure(list(ID = c(1, 2, 3), Dates = structure(c(2L, 4L, 6L ), .Label = c(16-01-02 16-08-94, 16-07-01 06-10-95, 24-01-02 06-10-95, 24/01/02 06-10-95, 16/01/02 16/08/94, 16/01/02 16/08/94 12/01/91 ), class = factor)), .Names = c(ID, Dates), row.names = c(NA, 3L), class = data.frame) -- View this message in context: http://www.nabble.com/Extract-dates-from-dataframe-tp22369479p22369479.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] Linear Regression
On Fri, Mar 6, 2009 at 6:07 AM, Sueli Rodrigues srodr...@esalq.usp.br wrote: Hi, I have the following file, and I need to work out the linear regression for each sample. I tried the model(*) and receive the error message (**): data=split(mydata,rep(1:(nrow(mydata)/6),each=6)) arrang.linear=lapply(data,lm,formula=KA~PA) Erro em storage.mode(y) - double : invalid to change the storage mode of a factor Além disso: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored SAMPLE PA KA 2 0.917 11.261 2 0.823 11.010 2 0.803 10.381 2 0.744 10.208 2 0.697 10.006 2 0.681 9.916 3 0.789 10.271 3 0.702 10.076 3 0.692 9.990 3 0.646 9.779 3 0.620 9.749 3 0.608 9.708 4 1.052 11.779 4 0.941 11.249 4 0.881 10.140 4 0.824 10.052 4 0.790 9.859 . . . . . . . . . 80 0.499 9.819 The lmList function in the package nlme is designed to handle situations like this. Try library(nlme) modlst - lmList(KA ~ PA | SAMPLE, data) __ 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 Series - ARIMA differencing problem
Uploaded the data and my comparison. Hopefully this will help illustrate and solve the problem. http://www.nabble.com/file/p22371555/data.csv data.csv http://www.nabble.com/file/p22371555/arima%2Bmethods.docx arima+methods.docx -- View this message in context: http://www.nabble.com/Time-Series---ARIMA-differencing-problem-tp22354071p22371555.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.
Re: [R] Statistics
On Thu, Mar 5, 2009 at 7:49 PM, per243 jose.perezsua...@csiro.au wrote: How can a non-linear regression to calculate the statistical R-square, R-square adjusted, RMSE, VIF?? It is not clear that these statistics are meaningful for a nonlinear regression model. For example, an R^2 value is meaningful when the model being fit contains the constant model because it compares the fit of the current model to the fit of the model y ~ 1. Not all nonlinear regression models contain the constant model as a submodel. __ 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] Ask about glm()
On 3/6/09, kenji_aoyagi kenji_aoy...@spi-consultants.com wrote: Hi, I am using glm(). I'd like to know what the command means. For example, glm(family=binomial(link=logit)) means logit model. Means : binomial response variable transformed with the logit Then, glm(family=gaussian(link=logit)), does this mean? Means : normally distributed response variable transformed by the logit function. Link is the link function, and different link functions can be used on different data. How R treats these, I don't know, but using the command '?glm' should get you further. Thank you in advance. Kenji. A Analysis Manager SPI - Strategy, Productivity, Insight., Japan __ 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. [[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] offlist Re: Time Series - ARIMA differencing problem
Your methods were sent in a docx file. I could be wrong, but it seems unlikely that very many people will bother to open such a file even if they do have an M$ product that will allow them to do so. My advice: First read the posting guide; then learn to sent plain text attachments. This is sent offlist. I am not a TS guru or even a casual user. Don't send followups to my message. -- David Winsemius On Mar 6, 2009, at 7:28 AM, thefurryblur wrote: Uploaded the data and my comparison. Hopefully this will help illustrate and solve the problem. http://www.nabble.com/file/p22371555/data.csv data.csv http://www.nabble.com/file/p22371555/arima%2Bmethods.docx arima +methods.docx -- View this message in context: http://www.nabble.com/Time-Series---ARIMA-differencing-problem-tp22354071p22371555.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] Re peated ANOVA or nested ANOVA, or parallel one way ANOVA six times?
janey ding janeding1 at hotmail.com writes: Sorry! In my experiment, there are two type of soil ( soil F and soil D), each half of them were subjected to steam sterilize (result in FS and DS soil). A equal volume of soil from two of the four soil types (F, D, FS, DS) were mixed as follows: F+F, F+D, F+FS, F+DS, D+F, D+FS, D+DS, FS+DS (eight treatment). Two type of plant (A, B) were planted in the eight treatment of soil in pot. There were 40 pots divided into 5 groups (8 pots for each group) for each treatment*plant combination. Finally there were 80 groups for plant A and B in total. The 40 groups for plant A were randomly arranged in plot 1, and for plant B in plot 2. The experiment were sampled for three times. In each sampling date, one pot was randomly choosing from each group to measure biomass (80 pot for sampling date). ... Looks like a split-block experiment. You should check # 1.6 at the bottom of library\nlme\scripts\Ch01.R, the package nlme, and the book by Pinheiro/ Bates. Dieter __ 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] fitting a gompertz model through the origin using nls
On 06-Mar-09 11:33:21, Swantje Löbel wrote: Dear all! I tried to fit Gompertz growth models to describe cummulative germination rates using nls. I used the following code: germ.model-nls(percent.germ~a*exp(-b*exp(-k*day)),data=tab, start=list(a =100,b=10,k=0.5)) My problem is that I want that the fitted model goes through the origin, since germination cannot start before the experiment was started, and y-max should be 100. Does anyone know how I can achieve this? Thanks a lot in advance! Swantje Given your observation that germination cannot start before the experiment has started, it is clear that a Gompertz growth curve model is unrealistic for your experiment, at least to that extent, since it is impossible for the Gompertz function to take the value 0 for any positive (or zero) time. So you should certainly be asking why you wanted to use that model in the first place. That being said, you may wish to try developing an alternative model along the following lines. [A] Suppose (to start with) that, under given experimental conditions, your seeds will germinate at times which are independent of each other, and randomly according to the condition of the seed and local variations of the condition of the soil surrounding the seed. Then the proportion of such seeds which would have germinated by time 'day' is F(day), where F is the cumulative distribution function of the distribution of germination time of such seeds in such conditions. The choice of a possible distribution function will have to be a valid representation of real-life constraints, so that F(day) = 0 for 'day' = 0, and no doubt F(day) = 1 for 'day' Day.max, a time by which any seed which is going to germinate will have germinated. Which raises a further possibility: that an (initially) unknown proportion of seeds may never germinate. So call this (1-P) where 'P' is the proportion that will germinate. You may be confident that you can take P=1. Or not, as the case may be. Then the growth curve will be of the form P*F(day). If you take P=1, than this automatically has value 0 when day=0, and value 1 when day=Day.max. As to suggestions for good analyttical forms for F(day), I'm not going to pretend that I know enough about seed biology to make realistic recommendations. But one might consider fairly simple functions, readily available in R, which can be adapted to the kind of scenario suggested above. For example, suppose that the germination time over the interval (0,Day.max) is a beta distribution of the form (u^(a-1))*((1-u)^(b-1))/B(a,b) where u = day/Day.max (and B(a,b) is the normalising constant). Then F(day) is the cumulative distribution of this, available in R as pbeta(u,a,b). This corresponds to a germination rate dbeta(u,a,b). So, with this choice, the function you would fit would be P*pbeta((day/Day.max),a,b) where you have to fit P, Day.max, a, b. However, the beta suggestion is only off the top of my head, and some other choice may be better in terms of biological reality. At least it has the property of being able to represent a variety of possible germination behaviours, e.g. for a=1 and b1, the germination rate would be highest at day=0, decreasing to 0 as day approaches Day.max. If a 1 and b 1, then germination rate is zero right at the start, increases to a maximum at day = Day.max*(a-1)/(a+b-2), and then decreases to zero at day=Day.max. Similarly, if a1 and b=1, then the rate is initially zero, and rises to a maximum at day=Day.max [B] A more complicated (and perhaps more realistic) scenario might require consideration of competition between seeds trying to germinate, and seed which have already germinated (where the infant plants may be sucking up resources wouch could have induced ungerminated seeds to germinate). In that case, the assumpation underlying approach [A], that the seeds germinate independently of each other, no longer holds, and the germination rate at 'day' would depend on the numbers which have already germinated (and possibly on other factors, such as the locations of seeds which have germinated, or the lengths of time since they have germinated since this will be related to the sizes of those infant plants). This is beginning to move back into Gompertz territory, since the underlying rationale of the Gompertz growth curve is that growth rate decreases with population size because of reduced resources. But it should be modelled in a different way. Again, I don't know what would be realistic in seed biology, but an approach which would incorporate such considerations could be: Other things being equal, a seed has constant hazard rate 'a' of germinating, but this this decreases proportionately to the number n of seeds already germinated (1 - b*n).[*] Then (dn/dt) = a*(1-b*n) so n = (1 - exp(-a*b*t))/b But this does not enforce 100% by Day.max, so you could fudge that in by dividing by a suitable factor: n = ((1 - exp(-a*b*t))/b/((1 -
[R] Travel funding for DSC/useR 2009 for young researchers at U.S. institutions
*** Travel and Accommodation Support *** Funds from the U.S. National Science Foundation may be available to provide partial support for travel and accommodation for some graduate students and junior faculty at U.S. post-secondary institutions to attend DSC 2009 and useR 2009. If you wish to apply for this support, please send an application to l...@stat.uiowa.edu. Your application should include a brief CV a copy of your abstract if you have submitted a paper or a poster a statement that demonstrates your eligibility, your need for support, and an amount of support requested students should include a brief letter of support from their supervisor faculty or post-doc applicants should include a brief statement about other funding sources The allocation will be based on merit and need; women and minority candidates are encouraged to apply. Applications must be made by March 31 (2009-03-31) and successful applicants will be notified by email soon thereafter. Please visit the conference web pages at http://www.r-project.org/dsc-2009/ and http://www.agrocampus-rennes.fr/math/useR-2009/ for conference details. Best, Luke Tierney -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: l...@stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu ___ r-annou...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ 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] About warnings for non-matched items
I have many files in my directory. I want to transfer each data into one which is readable. They have so many possibilities, i have collected(manually and visually) all possibilities and represent them as different numbers. Rep[grep('context_log',log1$Remain[1:length(log1$Date)]),]-2 Rep[grep('gs',log1$Remain[1:length(log1$Date)]),]-5 Rep[grep('ClockApp',log1$Remain[1:length(log1$Date)]),]-6 Rep[grep('mce',log1$Remain[1:length(log1$Date)]),]-7 .. I manually collect all possibilities contained in all files!!! (manually and visually: this process is so time-consuming, can i have better ideal to collect all possibilities by computer rather than by myself?) The programs are fine, but each file doesn't match all possibilities, whenever there are non-matched items with above, then warning information come ups: 31: In max(i) ... : no non-missing arguments to max; returning -Inf 32: In max(i) ... : no non-missing arguments to max; returning -Inf 33: In max(i) ... : no non-missing arguments to max; returning -Inf they returns non-matched items. How to vanish those warnings? The error means that the input you provided to the max function is missing or NULL or of length 0. At a guess, what has happened is that you've called grep, which didn't match anything (and so returned integer(0)), then used that as an input to max. To get rid of the warning, check the input to max first. e.g. x1 - c(foo, bar, foo) g1 - grep(foo, x1) if(length(g1)) max(g1) g2 - grep(baz, x1) if(length(g2)) max(g1) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ 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 to use ppp in spatial analysis
Hi, i am using spatstat package for spatial data analysis and now i have a problem to create a point pattern. The points are in file points.txt (first column for Latitude and second column for Longitude ) and I imported them and separated each columns in two arrays x and y. If I plots x and y ( e.g plot(x,y) ) the result appears in square area without problems and the scale is adequate to visual analysis of points ploted. But if i try to use ppp function to create a point pattern the result appears in rectangle area with a poor scale, dificulting in this case the analysis of the points. I think that is probably because of xrange and yrange parameter of ppp function, that was calculated based on max and min values of both x and y, but i am not sure: latitude - dataset$V2 longitude - dataset$V3 xrange -c(min(longitude), max(longitude)) yrange -c(min(latitude), max(latitude)) area - ppp(longitude/1, latitude/10, xrange, yrange) /* there are 181 point in file */ plot(longitude, latitude) / * square area of visualisation has an adequate scale to analysis */ plot(area) /* poor rectangle area of visualisation showing point too concentrated and hiding details - possible hot spots */ Is there a way of automatically define the size of window parameter (owin object) in ppp function from dataset of points? How can i scale the window without problems like: warning message: 181 points were rejected as lying outside the specified window Thanks Ricardo __ 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] Linear Regression
Dear Sueli, Assuming that your data is in a data frame called mydata, something like the following should work: # splitting the data by SAMPLE msp-with(mydata,split(mydata,SAMPLE)) # linear models by sample models-lapply(msp,function(x) lm(KA ~ PA, data = x)) # linear models by sample models-lapply(msp,function(x) lm(KA ~ PA, data = x)) models # summaries lapply(models,summary) # to access the models for the first sample and plot its residuals par(mfrow=c(2,2)) plot(models[[1]]) # to access a different sample, change the number 1 HTH, Jorge On Fri, Mar 6, 2009 at 7:07 AM, Sueli Rodrigues srodr...@esalq.usp.brwrote: Hi, I have the following file, and I need to work out the linear regression for each sample. I tried the model(*) and receive the error message (**): data=split(mydata,rep(1:(nrow(mydata)/6),each=6)) arrang.linear=lapply(data,lm,formula=KA~PA) Erro em storage.mode(y) - double : invalid to change the storage mode of a factor Além disso: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored SAMPLE PA KA 2 0.917 11.261 2 0.823 11.010 2 0.803 10.381 2 0.744 10.208 2 0.697 10.006 2 0.681 9.916 3 0.789 10.271 3 0.702 10.076 3 0.692 9.990 3 0.646 9.779 3 0.620 9.749 3 0.608 9.708 4 1.052 11.779 4 0.941 11.249 4 0.881 10.140 4 0.824 10.052 4 0.790 9.859 . . . . . . . . . 80 0.499 9.819 Sueli Rodrigues Eng. Agrônoma - UNESP Mestranda - USP/ESALQ PPG-Solos e Nutrição de Plantas Fones (19)93442981 (19)33719762 __ 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. [[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] Statistics
that statistic would be appropriate for non-linear regression?. know how I can calculate the VIF for a linear model?. per243 wrote: How can a non-linear regression to calculate the statistical R-square, R-square adjusted, RMSE, VIF?? Thanks jose -- View this message in context: http://www.nabble.com/Statistics-tp22364717p22373183.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] Numbers
Hi, I know the function LETTERS, but, now I have some letters to convert it in numbers, like A=1,B=2, etc... Is any function to do that? Atenciosamente, Leandro Lins Marino Centro de Avaliação Fundação CESGRANRIO Rua Santa Alexandrina, 1011 - 2º andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 ( (21) 8777-7907 ( lean...@cesgranrio.org.br Aquele que suporta o peso da sociedade é precisamente aquele que obtém as menores vantagens. (SMITH, Adam) Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE __ 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] Numbers
try this: x - c(A, X, F, W, G, V, L) match(x, LETTERS) I hope it helps. Best, Dimitris Leandro Marino wrote: Hi, I know the function LETTERS, but, now I have some letters to convert it in numbers, like A=1,B=2, etc... Is any function to do that? Atenciosamente, Leandro Lins Marino Centro de Avaliação Fundação CESGRANRIO Rua Santa Alexandrina, 1011 - 2º andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 ( (21) 8777-7907 ( lean...@cesgranrio.org.br Aquele que suporta o peso da sociedade é precisamente aquele que obtém as menores vantagens. (SMITH, Adam) Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE __ 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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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 editor that will work with Rcmdr
Dear Michael, For what it's worth, I develop the Rcmdr under Eclipse, and it works fine with Eclipse -- both under Windows and under Mac OS X. Of the IDEs that I've used with R, I'm most impressed with Eclipse/StatET, but configuration is non-trivial and documentation is sparse. I have a little experience with the Rcmdr under Emacs (as opposed to XEmacs) on Windows, and that too seems to work. Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bibo Sent: March-06-09 5:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] R editor that will work with Rcmdr John Sorkin jsorkin at grecc.umaryland.edu writes: R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John Hi John, From my experience, while (X)Emacs + ESS or JGR work with Rcmdr under Linux, there can be problems using either of these in conjunction with Rcmdr under Windows. From John Fox's own 'An Introduction to ESS + XEmacs for Windows Users of R': The Rcmdr package does not run reliably under XEmacs/ESS for Windows. On Windows XP at least, this still seems to be the case - for me it always ends up crashing R. Under Windows, Tinn-R and Notepad++ with NppToR (http://sourceforge.net/projects/npptor/) work fine alongside Rcmdr, but both of them are Windows only. Other IDEs such as Eclipse I haven't tested. Hope this is helpful, Michael Bibo Queensland Health __ 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 editor that will work with Rcmdr
Hi, I also use R under Eclipse/StatET. I found the following doc really useful: http://www.splusbook.com/Rintro/R_Eclipse_StatET.pdf Regards Alain 212-449-4894 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Fox Sent: Friday, March 06, 2009 10:31 AM To: 'Michael Bibo' Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] R editor that will work with Rcmdr Dear Michael, For what it's worth, I develop the Rcmdr under Eclipse, and it works fine with Eclipse -- both under Windows and under Mac OS X. Of the IDEs that I've used with R, I'm most impressed with Eclipse/StatET, but configuration is non-trivial and documentation is sparse. I have a little experience with the Rcmdr under Emacs (as opposed to XEmacs) on Windows, and that too seems to work. Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Bibo Sent: March-06-09 5:20 AM To: r-h...@stat.math.ethz.ch Subject: Re: [R] R editor that will work with Rcmdr John Sorkin jsorkin at grecc.umaryland.edu writes: R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John Hi John, From my experience, while (X)Emacs + ESS or JGR work with Rcmdr under Linux, there can be problems using either of these in conjunction with Rcmdr under Windows. From John Fox's own 'An Introduction to ESS + XEmacs for Windows Users of R': The Rcmdr package does not run reliably under XEmacs/ESS for Windows. On Windows XP at least, this still seems to be the case - for me it always ends up crashing R. Under Windows, Tinn-R and Notepad++ with NppToR (http://sourceforge.net/projects/npptor/) work fine alongside Rcmdr, but both of them are Windows only. Other IDEs such as Eclipse I haven't tested. Hope this is helpful, Michael Bibo Queensland Health __ 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. -- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. References to Merrill Lynch are references to any company in the Merrill Lynch Co., Inc. group of companies, which are wholly-owned by Bank of America Corporation. Secu! rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this E-communication may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- __ 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] Summary grouped by factor
### example:start v - sample(rnorm(200), 100, replace=T) k - rep.int(c(locA, locB, locC, locD), 25) tapply(v, k, summary) ### example:end ... (hopefully) produces 4 summaries of v according to k group membership. How can I transform the output into a nice table with the croups as columns and the interesting statistics as lines? Thx, Sören __ 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] Summary grouped by factor
Dear Sören, How about this? do.call(cbind,tapply(v, k, summary)) HTH, Jorge On Fri, Mar 6, 2009 at 10:48 AM, soeren.vo...@eawag.ch wrote: ### example:start v - sample(rnorm(200), 100, replace=T) k - rep.int(c(locA, locB, locC, locD), 25) tapply(v, k, summary) ### example:end ... (hopefully) produces 4 summaries of v according to k group membership. How can I transform the output into a nice table with the croups as columns and the interesting statistics as lines? Thx, Sören __ 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. [[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] Summary grouped by factor
soeren.vo...@eawag.ch wrote: ### example:start v - sample(rnorm(200), 100, replace=T) k - rep.int(c(locA, locB, locC, locD), 25) tapply(v, k, summary) ### example:end Maybe this could be a solution: t1 - tapply(v, k, summary) t2 - sapply(t1, cbind) rownames(t2) - names(t1[[1]]) t2 Ciao, domenico ... (hopefully) produces 4 summaries of v according to k group membership. How can I transform the output into a nice table with the croups as columns and the interesting statistics as lines? Thx, Sören __ 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] Summary grouped by factor
soeren.vo...@eawag.ch wrote: ### example:start v - sample(rnorm(200), 100, replace=T) k - rep.int(c(locA, locB, locC, locD), 25) tapply(v, k, summary) ### example:end This one is better: do.call(cbind, tapply(v,k,summary)) Ciao, domenico ... (hopefully) produces 4 summaries of v according to k group membership. How can I transform the output into a nice table with the croups as columns and the interesting statistics as lines? Thx, Sören __ 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] Summary grouped by factor
On 06.03.2009, at 16:48, soeren.vo...@eawag.ch wrote: ### example:start v - sample(rnorm(200), 100, replace=T) k - rep.int(c(locA, locB, locC, locD), 25) tapply(v, k, summary) ### example:end ... (hopefully) produces 4 summaries of v according to k group membership. How can I transform the output into a nice table with the croups as columns and the interesting statistics as lines? ### Right??? and good??? solution: sapply(by(v, list(area=k), function(x)x, simplify=F), summary) Sören (again) __ 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] Does R have function or method to finish my task?
You have pretty much exhausted my expertise on time series, you may want to reask your question on the sig-finance list (with a more specific subject line), there seem to be more time series experts hanging out on that list (though someone please correct me if my impression is wrong). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 From: zhijie zhang [mailto:rusers...@gmail.com] Sent: Thursday, March 05, 2009 6:37 PM To: Greg Snow Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Does R have function or method to finish my task? Actually, i had checked out the methods of time series (TS), but i had thought it cannot solve it. TS may only considers the autocorrelation of Y in different time, but not Xs. Besides Y, i also have several independent variables. Following your suggestion, i browsed the dynlm package and found it is helpful. Lag function (e.g.lag(x, lag = -k)) may solve the problem. That is, TS plus Lag function may finally solve my task. But one question is how to determine the best k for Y and Xs. Thanks. 2009/3/6 Greg Snow greg.s...@imail.orgmailto:greg.s...@imail.org I think that the dynlm package was designed for just such a problem. I also would not be surprised if there are tools in the zoo package to do this. You should probably check out the time series task view on CRAN as well. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.orgmailto:greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-boun...@r-mailto:r-help-boun...@r- project.orghttp://project.org/] On Behalf Of zhijie zhang Sent: Thursday, March 05, 2009 8:56 AM To: r-h...@stat.math.ethz.chmailto:r-h...@stat.math.ethz.ch Subject: [R] Does R have function or method to finish my task? Dear all, Does R have function or method to finish the following task. Say i have a dataset. The response variable is Y, and the indepedent variables are X1, X2, X3, and YEAR. See an example. Y X1X2X3 X4 YEAR 13.4 2.8 3.5 2.5 1.8 1990 10.51.82.4 2 3 1991 . In ecology, Y may be not only related with X1, X2, X3 in the same year as Y, but also may be related with X1, X2, X3 and Y in the previous one , two or more years as Y. But which year has the closest relationship is not know and this may be one of the analysis aim. Take Year=1995 as an example, Y_1995 may be related with X1_1995 , X2_1995 , X3_1995, X1_1994 , X2_1994 , X3_1994, Y_1994, (previous one year) X1_1993 , X2_1993 , X3_1993, Y_1993 (previous two years) ... ... (previous more years) Pay attention to the situation that Y itself may also affect its own value of the next several years. Anybody knows whether R have functions or methods to finish the above task. I hope i have explained it clearly. Any suggestions or help are greatly appreciated. [[alternative HTML version deleted]] __ R-help@r-project.orgmailto: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-http://www.r-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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 using R Commander for text file import
I'd like to report another instance...one of my students has had the exact same error. I've checked the data, at it is a clean .csv file, with no quotation marks at all. I am currently at a loss at how to figure out what might be going wrong. -- View this message in context: http://www.nabble.com/error-using-R-Commander-for-text-file-import-tp21928664p22375641.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] R code -column headings
Hello, I have been noticing that some of my column headings are missing. Can you give me a clue as to how to 1] replace Var1 and Var 2 by Region and type ie do it right the first time x-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4) rownames(x)=c( Northeast, Midwest, South, West ) colnames(x)=c(Public, Private) as.data.frame(as.table(x)) 2] add a column heading for region when I use addmargins(x) addmargins(x) #margin.table(x,1) #margin.table(x,2) Thank you. Sincerely, Mary A. Marion __ 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 apply a function to slices of multidimensional arrays, and not just iterating through single elements
Dimitris, Domenico, It seems I was using apply in a wrong way. Thank you! TK 2009/3/6 Domenico Vistocco visto...@unicas.it: If I well understand, maybe you have still apply at your disposal: arrayA - 1:60 dim(arrayA) - c(3,4,5) apply(arrayA, 2, sum) You have the same result of: res-numeric(4);for (i in 1:4) res[i]-sum(arrayA[,i,]) Ciao, domenico PS: have a look at plyr package for more slicing and applying functions Todor Kondic wrote: Hello, If I want to apply some f(x) to such chunks of the the array dim(A)==c(d1,d2,d3,..,dk,...,dn) which are defined by A[...,ik,...] (ik belongs to {1,..,dk}), for now I use iteration via 'for (i in dim(A)[k]) f(A[...,k,...])' . Is there any more elegant approach, e.g like in 'apply' function which you can use on margin of the array. Just in my case I want the entire slice defined by margin to be an argument to my f(x), not just element-by-element. If the former is too confusing: A - array dim(A)=c(3,4,5) f(x) - function; x is argument dim(x)=c(3,5) A has 4 slices of dim c(3,5) I want my result to be a vector c( f(A[,1,]), f(A[,2,]), f(A[,3,]), f(A[,4,]) ) Until now I was doing 'for (i in 1:4) res[i]-f(A[,i,])' . Is there a more efficient way of doing this, maybe some predefined function? Cheers, TK __ 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] Re peated ANOVA or nested ANOVA, or parallel one way ANOVA six times?
Thank you for your reply, Dieter. I will try it. Looks like a split-block experiment. You should check # 1.6 at the bottom of library\nlme\scripts\Ch01.R, the package nlme, and the book by Pinheiro/ Bates. Dieter __ R-help@r-project.org mailing list PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Repeated-ANOVA-or-nested-ANOVA%2C-or-parallel-one-way-ANOVA-six-times--tp22370060p22377041.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.
Re: [R] error using R Commander for text file import
Dear Doug, Can you send me the file, along with information about the versions of the Rcmdr and R that you're using, and your OS? I suspect that the problem doesn't have to do with the file, but with the command that the Rcmdr is generating to read it, so some additional information would also be helpful, such as the path to the file. In fact, if you could send a read.table() or read.cvd() command that works to read the file, that might provide the clue I need. Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Doug Schwalm Sent: March-06-09 11:19 AM To: r-help@r-project.org Subject: Re: [R] error using R Commander for text file import I'd like to report another instance...one of my students has had the exact same error. I've checked the data, at it is a clean .csv file, with no quotation marks at all. I am currently at a loss at how to figure out what might be going wrong. -- View this message in context: http://www.nabble.com/error-using-R-Commander- for-text-file-import-tp21928664p22375641.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] error using R Commander for text file import
Dear Doug, Here's my guess: the path to your file has an apostrophe in it -- I'm able to duplicate the error in this case. If that's the case, then a work-around would be to move the file. Meanwhile, I'll look into fixing the problem. Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Doug Schwalm Sent: March-06-09 11:19 AM To: r-help@r-project.org Subject: Re: [R] error using R Commander for text file import I'd like to report another instance...one of my students has had the exact same error. I've checked the data, at it is a clean .csv file, with no quotation marks at all. I am currently at a loss at how to figure out what might be going wrong. -- View this message in context: http://www.nabble.com/error-using-R-Commander- for-text-file-import-tp21928664p22375641.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] Highly Connected Nodes in Igraph
Hello R Help Team, I have created graph from weighted adjecency matrix .Is there a way I can find highly connected nodes in Igraph like the Package RBGL does. nathan -- View this message in context: http://www.nabble.com/Highly-Connected-Nodes-in-Igraph-tp22377522p22377522.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.
Re: [R] Highly Connected Nodes in Igraph
Nathan, if you have a weighted adjacency matrix, then you don't need graph packages for this, just do rowSums(data) or rowSums(data != 0) depending you want the sum of the weights of the adjacent edges, or just the number of adjacent edges. Or optionally colSums instead of rowSums if your graph is directed. Best, Gabor On Fri, Mar 6, 2009 at 7:00 PM, Sur Nathan surendar.swaminat...@gmail.com wrote: Hello R Help Team, I have created graph from weighted adjecency matrix .Is there a way I can find highly connected nodes in Igraph like the Package RBGL does. nathan -- View this message in context: http://www.nabble.com/Highly-Connected-Nodes-in-Igraph-tp22377522p22377522.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. -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ 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 code -column headings
Answer to your first question: x-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4) rownames(x)=c( Northeast, Midwest, South, West ) colnames(x)=c(Public, Private) y - as.data.frame(as.table(x)) names(y)[1:2] - c(Region, Type) y RegionType Freq 1 Northeast Public 266 2 Midwest Public 359 3 South Public 533 4 West Public 313 5 Northeast Private 555 6 Midwest Private 504 7 South Private 502 8 West Private 242 On Fri, Mar 6, 2009 at 12:13 PM, Mary A. Marion mam...@virginia.edu wrote: Hello, I have been noticing that some of my column headings are missing. Can you give me a clue as to how to 1] replace Var1 and Var 2 by Region and type ie do it right the first time x-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4) rownames(x)=c( Northeast, Midwest, South, West ) colnames(x)=c(Public, Private) as.data.frame(as.table(x)) 2] add a column heading for region when I use addmargins(x) addmargins(x) #margin.table(x,1) #margin.table(x,2) Thank you. Sincerely, Mary A. Marion __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] c() coverts real numbers to integers?
Hello, I know I am forgetting to do something silly. I typed coordinates in vectors (as below) but when I call them in R they come out as integers, and I want them to be real numbers. I have tried using as.numeric, as.real, etc... but they are still read by R as integers. STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) What am I doing wrong? Thanks for your help, John __ 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] c() coverts real numbers to integers?
There are real numbers: STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) str(STX) num [1:4] 16.1 16.1 16.1 16.1 str(STY) num [1:4] 2.04 2.02 1.99 1.98 So what is your question? On Fri, Mar 6, 2009 at 1:47 PM, John Poulsen jpoul...@zoo.ufl.edu wrote: Hello, I know I am forgetting to do something silly. I typed coordinates in vectors (as below) but when I call them in R they come out as integers, and I want them to be real numbers. I have tried using as.numeric, as.real, etc... but they are still read by R as integers. STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) What am I doing wrong? Thanks for your help, John __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] c() coverts real numbers to integers?
STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) STX [1] 16.0962 16.1227 16.0921 16.1498 STY [1] 2.0387 2.0214 1.9877 1.9846 Did you perhaps redefine c()? Or: options()$digits If not, then what do these say: str(STX) str(STY) On Mar 6, 2009, at 1:47 PM, John Poulsen wrote: I know I am forgetting to do something silly. I typed coordinates in vectors (as below) but when I call them in R they come out as integers, and I want them to be real numbers. I have tried using as.numeric, as.real, etc... but they are still read by R as integers. STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) What am I doing wrong? David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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 code -column headings
To do that be sure to give each dimension, itself, a name when the matrix is defined: mat -matrix(c(266, 359, 533, 313, 555, 504, 502, 242), nrow = 4, dimnames = list(Region = c(Northeast, Midwest, South, West), Type = c(Public, Private))) as.data.frame(as.table(mat)) addmargins(mat) On Fri, Mar 6, 2009 at 12:13 PM, Mary A. Marion mam...@virginia.edu wrote: Hello, I have been noticing that some of my column headings are missing. Can you give me a clue as to how to 1] replace Var1 and Var 2 by Region and type ie do it right the first time x-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4) rownames(x)=c( Northeast, Midwest, South, West ) colnames(x)=c(Public, Private) as.data.frame(as.table(x)) 2] add a column heading for region when I use addmargins(x) addmargins(x) #margin.table(x,1) #margin.table(x,2) Thank you. Sincerely, Mary A. Marion __ 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] R and vim (gvim) on ubuntu
Dear all - I do fret this to be a revealing beginner question - fortunately, this mailing list have been good to me in the paste .-) I am looking for a good R editor/environment in ubuntu. To that end, I have decided to dive into gvim as the modality offered here seems to make sense for editing. I want to use Johannes Ranke's vim r-plugin, but I can't make it work. I have the plugin installed, and this confirmed vim-addons I set the new file to r :set ft=r I open a terminal and start R R Then when I press F2 in vim - nothing happens (some text flashes at the botom of the screen - but I can't read it. It's not an error messages though) when I try to run an R command eg, x - rnorm(100,10,5) vim returns this error: ~/.pipe E212: can't open file for wirting What have I done wrong? I suspect maybe it's got something to do the funnel.pl - but I have installed the script from Johannes Ranke's repository - so there should be no need to install funnel.pl? Any help much appreciated Sincerely, Andreas -- View this message in context: http://www.nabble.com/R-and-vim-%28gvim%29-on-ubuntu-tp22377215p22377215.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] c() coverts real numbers to integers?
Hello, I know I am forgetting to do something silly. I typed coordinates in vectors (as below) but when I call them in R they come out as integers, and I want them to be real numbers. I have tried using as.numeric, as.real, etc... but they are still read by R as integers. STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) What am I doing wrong? Thanks for your help, John __ 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] c() coverts real numbers to integers?
Thanks! That solved it. I obviously had done something stupid. I just redefined my options(digits=7) and they are all there. Sorry for the silly question, and thanks for the suggestion towards options(). Thanks! John David Winsemius wrote: STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) STX [1] 16.0962 16.1227 16.0921 16.1498 STY [1] 2.0387 2.0214 1.9877 1.9846 Did you perhaps redefine c()? Or: options()$digits If not, then what do these say: str(STX) str(STY) On Mar 6, 2009, at 1:47 PM, John Poulsen wrote: I know I am forgetting to do something silly. I typed coordinates in vectors (as below) but when I call them in R they come out as integers, and I want them to be real numbers. I have tried using as.numeric, as.real, etc... but they are still read by R as integers. STX-c(16.0962, 16.1227, 16.0921, 16.1498) STY-c(2.0387, 2.0214, 1.9877, 1.9846) What am I doing wrong? David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Highly Connected Nodes in Igraph
Hello, please post to the list instead of posting me directly. I am sorry to say, but I don't really know what you want to do. First you asked about highly connected nodes, and now about clustering. Perhaps you could give an example with the input and the expected output. Btw, if you know how to do it with RBGL, then why don't you do it with RBGL? Gabor On Fri, Mar 6, 2009 at 7:45 PM, surendar.swaminat...@gmail.com wrote: Hello Gabor, Thank you for the reply.I used your program to do SNA betweennes,Closenness,Eigen Vector. I think I did not put the question properly.What I would like to do is clustering based on Co-authorship network. If I have 5 nodes and all the nodes have written one paper 2,3,4 have written 4 papers together. I want to create cluster based on the node 2,3,4.I have been looking arnd for over a week now.Could not find a way to solve this problem. I have 393 such nodes to cluster based on the number of times the authors have published with the other authors. Gábor Csárdi-2 wrote: Nathan, if you have a weighted adjacency matrix, then you don't need graph packages for this, just do rowSums(data) or rowSums(data != 0) depending you want the sum of the weights of the adjacent edges, or just the number of adjacent edges. Or optionally colSums instead of rowSums if your graph is directed. Best, Gabor On Fri, Mar 6, 2009 at 7:00 PM, Sur Nathan surendar.swaminat...@gmail.com wrote: Hello R Help Team, I have created graph from weighted adjecency matrix .Is there a way I can find highly connected nodes in Igraph like the Package RBGL does. nathan -- View this message in context: http://www.nabble.com/Highly-Connected-Nodes-in-Igraph-tp22377522p22377522.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. -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ 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. Quoted from: http://www.nabble.com/Highly-Connected-Nodes-in-Igraph-tp22377522p22377754.html -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ 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] portable R editor
You might also look at http://www.portableapps.com for a portable version of several editors, including gVim, Notepad++ and SciTE which all have some level of support for R -- I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, it's a way of looking at life through the wrong end of a telescope. Which is what I do, and that enables you to laugh at life's realities. - Dr. Suess From: r-help-boun...@r-project.org on behalf of Werner W. Sent: Wed 3/4/2009 6:39 AM To: r-help@r-project.org Subject: Re: [R] portable R editor Many, many thanks for all the answers! Notepad++ looks very promising although it does not have a project file management facility. But it has a very clean appearance. I'll have to look into SciTE which also sounds quite good. There seem to be some good alternatives. Meanwhile, I found a freeware application which helps to make Tinn-R truly portable: JauntePE (http://www.portablefreeware.com/?id=1452) virtualizes access to the registry and file system and can easily be used to make also the ini settings portable. Thus, everything will be on the USB stick. Thanks again, Werner -- View this message in context: http://www.nabble.com/portable-R-editor-tp22291017p22328322.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. [[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] R on netbooks et al?
Liaw, == Liaw, Andy andy_l...@merck.com writes: Are you sure that's dual atoms? AFAIK it has a single Atom N270 (single core) at 1.6GHz. With hyper-threading, you may see two cpus. Yep - that is exactly what is going on. Mike __ 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] Thousand separator on axis
Is there an easy way to add a thousand separator mark on the axis of a plot? The best solution I've found so far is the following: y - seq(0, 10, 1) plot(y, yaxt = n, ylab = ) axis(2, at = y, labels = formatC(y, big.mark = , format = d), las=2) But that seems like quite a hassle to do every time around. Is there a way to get the same output using less parameteres? [[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] PCA and categorical data
On Fri, Mar 06, 2009 at 09:46:17AM -, Ted Harding wrote: On 06-Mar-09 09:25:26, Prof Brian Ripley wrote: You might want to look into correspondence analysis, which has several variants of PCA designed for categorical data. In particular, have a look at the results of RSiteSearch(correspondence) I can recommend the packages ca and FactoMineR http://cran.r-project.org/web/packages/ca/index.html http://cran.r-project.org/web/packages/FactoMineR/index.html http://www.jstatsoft.org/v20/i03 http://www.jstatsoft.org/v25/i01 -- Hans Ekbrand (http://sociologi.cjb.net) h...@sociologi.cjb.net GPG Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E signature.asc Description: Digital signature __ 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] Interaction term not significant when using glm???
Dear all, I have a dataset where the interaction is more than obvious, but I was asked to give a p-value, so I ran a logistic regression using glm. Very funny, in the outcome the interaction term is NOT significant, although that's completely counterintuitive. There are 3 variables : spot (binary response), constr (gene construct) and vernalized (growth conditions). Only for the FLC construct after vernalization, the chance on spots should be lower. So in the model one would suspect the interaction term to be significant. Yet, only the two main terms are significant here. Can it be my data is too sparse to use these models? Am I using the wrong method? # data generation testdata - matrix(c(rep(0:1,times=4),rep(c(FLC,FLC,free,free),times=2), rep(c(no,yes),each =4),3,42,1,44,27,20,3,42),ncol=4) colnames(testdata) -c(spot,constr,vernalized,Freq) testdata - as.data.frame(testdata) # model T0fit - glm(spot~constr*vernalized, weights=Freq, data=testdata, family=binomial) anova(T0fit) Kind regards Joris [[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] R on netbooks et al?
chaogai chao...@xs4all.nl [Thu, Mar 05, 2009 at 07:04:19PM CET]: I'm having similar experiences on my Acer Aspire One. Everything will work good. Only thing that takes a lot of time is compiling R if you are in the habit of doing so. On the Fedora version that came with my Acer Aspire One, I am even thinking of compiling R itself as the current R version is 2.6.0 ... Otherwise, everything seems fine and the keyboard is indeed the greatest letdown so far (the tiny left mouse button a close second). -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:johan...@huesing.name from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi) __ 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] frequency of subsequent events
Hello, The example shows a sequence of songtypes a bird has sang. The entire list contains several thousand songs which the bird has produced consecutively. Is there any convenient way in R to produce a contingency table which shows how often a special song type was sang after a special other songtype? Or within a determined frame of e.g. 10 consecutively produced songs? Example: Nr Songtype 1 S1 2 S2 3 S3 4 S1 5 S1 6 S2 7 S4 Contingency table: S1 S2 S3 S4 subsequent songs S1 1 2 0 0 S2 0 0 1 1 S3 1 0 0 0 S4 0 0 0 0 Preceding Songs Greetings Michael #adBox3 {display:none;} Heute schon gefreeMailt? Jetzt kostenlose E-Mail-Adresse sichern! http://email.freenet.de/dienste/emailoffice/produktuebersicht/basic/mail/index.html?pid=6831 [[alternative(swapped) 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] Interpreting GLM coefficients
Hi all, I´m fitting GLM´s and I can´t interprete the coefficients when I run a model with interaction terms. When I run the simpliest model there is no problem: Model1-glm (Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month, family = poisson(log)) # Fishes, Year, Hours, and Fishers are numeric, Kind.Geographic, Kind.Fishers, Zone.2 and Month are factors with 4, 3, 5 and 12 levels respectively. Model1$coefficients (whith Helmert contrasts): (Intercept) Year IYear^2 Kind.Geographic1 Kind.Geographic2 Kind.Geographic3Kind.Fishers1Kind.Fishers2 Zone.21 Zone.22 Zone.23 Zone.24 -4.416915e+02 4.758455e-01-1.270986e-04-5.436199e-01 -1.068809e-01-1.498580e-01 2.958462e-01 1.316589e-01 -1.328204e-01-1.605802e-01 5.281869e-03 7.422885e-02 Hours Fishers Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 9.772076e-02-2.709955e-03-1.586887e-01-1.887837e-02 -5.183241e-03 5.870942e-02 7.075386e-02 2.061223e-02 7.372268e-03-1.204835e-02-5.047994e-03 2.441498e-02 Month11 -5.665261e-03 So I can write, for example: y = -4.416915e+02 + -1.270986e-04*x^2 + 4.758455e-01*x # And add this function to a plot(Year,Fishes). My problem is to understand the coefficients for the model with interaction: Model2-glm(Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month + Year:Kind.Geographic + Year:Kind.Fishers + Year:Zone.2 + Year:Hours + Year:Fishers + Year:Month + Kind.Geographic:Hours + Kind.Fishers:Hours + Zone.2:Hours + Hours:Fishers + Hours:Month +Kind.Geographic:Fishers + Zone.2:Fishers + Fishers:Month , poisson (log)) Model2$coefficients (with Helmert contrast): (Intercept) Year I(Year^2) Kind.Geographic1 Kind.Geographic2 Kind.Geographic3Kind.Fishers1Kind.Fishers2 1.641473e+03-1.748703e+00 4.664752e-04-6.721427e+00 1.856033e+01 -3.762727e-02 2.903564e+01 9.022858e+01 Zone.21 Zone.22 Zone.23 Zone.24Hours Fishers Month1 Month2 8.110814e-02-1.902803e+01 8.335792e+00-3.661641e+00-7.824623e+00 7.088065e-01 2.479387e+03 8.346729e+02 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 4.052680e+02 2.384440e+02 1.570644e+02 1.032445e+02 7.930499e+01 6.487925e+01 5.592869e+01 3.888328e+01 Month11Year:Kind.Geographic1 Year:Kind.Geographic2Year:Kind.Geographic3 Year:Kind.Fishers1 Year:Kind.Fishers2 Year:Zone.21 Year:Zone.22 4.801656e+01 3.397984e-03 -9.443234e-03 NA-1.449305e-02 -4.470212e-02-6.269309e-05 9.421045e-03 Year:Zone.23 Year:Zone.24 Year:Hours Year:Fishers Year:Month1 Year:Month2 Year:Month3 Year:Month4 -4.184866e-03 1.854810e-03 3.257250e-03-4.103058e-04-1.264934e+00 -4.255907e-01-2.069909e-01-1.216459e-01 Year:Month5 Year:Month6 Year:Month7 Year:Month8 Year:Month9 Year:Month10 Year:Month11 Kind.Geographic1:Hours -8.015823e-02-5.278291e-02 -4.054404e-02-3.313487e-02-2.846036e-02 -1.973118e-02-2.410902e-02 1.341231e-01 Kind.Geographic2:Hours Kind.Geographic3:Hours Kind.Fishers1:Hours Kind.Fishers2:HoursZone.21:Hours Zone.22:HoursZone.23:Hours Zone.24:Hours 5.806418e-02 NA 1.318444e-02-1.234521e-01 7.961319e-04 1.622411e-02-5.357266e-04 7.749412e-03 Hours:Fishers Hours:Month1 Hours:Month2 Hours:Month3 Hours:Month4 Hours:Month5 Hours:Month6
Re: [R] frequency of subsequent events
?lag ?xtabs songseq - read.table(textConnection(NrSongtype 1 S1 2 S2 3 S3 4 S1 5 S1 6 S2 7 S4), header=TRUE, stringsAsFactors=FALSE) songseq$precsong -c(NA,lag(songseq$Songtype)[1:6]) # need to drop last entry xtabs( ~ precsong + Songtype, data=songseq) Songtype precsong S1 S2 S3 S4 S1 1 2 0 0 S2 0 0 1 1 S3 1 0 0 0 #may want to set extra levels if S4 song type does not have a subsequent -- David Winsemius, MD Heritage Laboratories West Hartford, CT On Mar 6, 2009, at 3:14 PM, miwei...@freenet.de wrote: Hello, The example shows a sequence of songtypes a bird has sang. The entire list contains several thousand songs which the bird has produced consecutively. Is there any convenient way in R to produce a contingency table which shows how often a special song type was sang after a special other songtype? Or within a determined frame of e.g. 10 consecutively produced songs? Example: Nr Songtype 1 S1 2 S2 3 S3 4 S1 5 S1 6 S2 7 S4 Contingency table: S1 S2 S3 S4 subsequent songs S1 1 2 0 0 S2 0 0 1 1 S3 1 0 0 0 S4 0 0 0 0 Preceding Songs Greetings Michael __ 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] a general question
Hi everyone, Although this question is more related to ChIP and ChIP-seq, it could be probably anchored in a more general statistical context. The question is : what method is better to assess the significance of the change in a signal (the signal can be DNA binding, for instance) given the background and 2 conditions. . condition1 (eg no treatment) : background = 1; signal = 5; . condition2 (eg hormonal treatment) : background = 3; signal = 6. The methods can be : a. substract the background : i.e. (signal_treatment - background_treatment) / (signal_no_treatment - background_no_treatment) b. calculate the fold change: i.e. (signal_treatment / background_treatment) / (signal_no_treatment / background_no_treatment) c. any other method ? i.e. (signal_treatment - signal_no_treatment) / ( background_treatment - background_no_treatment) Thank you very much. Bogdan [[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] Problem in Map function
Hi list, I have a real problem with plotting US state map. When I try to plot the northern state, there will be some blank space in the top of graph (see case 1 example), and when I plot southern states, there will be a blank space in the bottom of plot (see case 2). I spent almost 2 days to figure out a solution, but could not. Would you help me if you know what the problem is? Regards, Alireza # #case 1 library(maps) require(mapproj) longlatLimit-c(-107,-93,40,52) par(plt=c(0,1,0,1),cex=1,cex.main=1) #Set plotting parameters #map(projection=azequalarea, type=n,xlim=longlatLimit[1:2],ylim=longlatLimit[3:4]) map(projection=azequalarea, type=n,xlim=longlatLimit[1:2],ylim=longlatLimit[3:4]) bound-c(floor(longlatLimit[1]), ceiling(longlatLimit[2]), floor(longlatLimit[3]), ceiling(longlatLimit[4])) #sure AZ map.grid(lim=bound,col=light grey) # #case 2 library(maps) require(mapproj) longlatLimit-c(-107,-93,25,37) par(plt=c(0,1,0,1),cex=1,cex.main=1) #Set plotting parameters #map(projection=azequalarea, type=n,xlim=longlatLimit[1:2],ylim=longlatLimit[3:4]) map(projection=azequalarea, type=n,xlim=longlatLimit[1:2],ylim=longlatLimit[3:4]) bound-c(floor(longlatLimit[1]), ceiling(longlatLimit[2]), floor(longlatLimit[3]), ceiling(longlatLimit[4])) #sure AZ map.grid(lim=bound,col=light grey) [[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] Interpreting GLM coefficients
One thing I notice immediately is a number of NA values for your coefficients. If I were you, I would try a model with less parameters, and use the anova() function to compare models, to see if the extra terms really improve the model. e.g. fit1 - glm(Y~X1+X2+X3,...) fit2 - glm(Y~X1+X2+X3+X1:X2,...) anova(fit1, fit2, test=F) If you checked all these, understanding the interaction terms will be most easy if you normalized your numeric data before the analysis. For the interpretations, you just fill in some values to get an idea. For example : given the model : Y= a+b1*X1+b2*X2+b3*X1*X2 Say X1 and X2 are numeric : interpretation of the main term : Y increases with b2 for an increase of 1 unit in X2, given X1 is average. interpretation of the interaction term : For an X1 value of n units from the mean, X2 increases with b2+n*b3 (n is negative when value is lower than the mean). In a Y ~ X2 plot, you can make this visible by plotting 3 different functions : one for a low X1 value, one for an average X1 value and one for a high X1 value. This gives you an indication of the effect of X1 on X2. for an interaction between a categorical terms or a categorical and a numerical, you follow exact the same reasoning, but keep in mind that the reference level represents a 0, and the mentioned level represents a 1. Fill in the values in the equation, and you can understand the meaning of the terms. Then again, you can plot a seperate function Y~X1 for every level of a certain factor. This isn't a straight answer on your question, but I'm afraid there is none. I hope this helps you with building your model. Kind regards. Joris On Fri, Mar 6, 2009 at 11:04 PM, Pablo Pita Orduna pp...@udc.es wrote: Hi all, I´m fitting GLM´s and I can´t interprete the coefficients when I run a model with interaction terms. When I run the simpliest model there is no problem: Model1-glm (Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month, family = poisson(log)) # Fishes, Year, Hours, and Fishers are numeric, Kind.Geographic, Kind.Fishers, Zone.2 and Month are factors with 4, 3, 5 and 12 levels respectively. Model1$coefficients (whith Helmert contrasts): (Intercept) Year IYear^2 Kind.Geographic1 Kind.Geographic2 Kind.Geographic3Kind.Fishers1Kind.Fishers2 Zone.21 Zone.22 Zone.23 Zone.24 -4.416915e+02 4.758455e-01-1.270986e-04-5.436199e-01 -1.068809e-01-1.498580e-01 2.958462e-01 1.316589e-01 -1.328204e-01-1.605802e-01 5.281869e-03 7.422885e-02 Hours Fishers Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 9.772076e-02-2.709955e-03-1.586887e-01-1.887837e-02 -5.183241e-03 5.870942e-02 7.075386e-02 2.061223e-02 7.372268e-03-1.204835e-02-5.047994e-03 2.441498e-02 Month11 -5.665261e-03 So I can write, for example: y = -4.416915e+02 + -1.270986e-04*x^2 + 4.758455e-01*x # And add this function to a plot(Year,Fishes). My problem is to understand the coefficients for the model with interaction: Model2-glm(Fishes ~ Year + I(Year^2) + Kind.Geographic + Kind.Fishers + Zone.2 + Hours + Fishers + Month + Year:Kind.Geographic + Year:Kind.Fishers + Year:Zone.2 + Year:Hours + Year:Fishers + Year:Month + Kind.Geographic:Hours + Kind.Fishers:Hours + Zone.2:Hours + Hours:Fishers + Hours:Month +Kind.Geographic:Fishers + Zone.2:Fishers + Fishers:Month , poisson (log)) Model2$coefficients (with Helmert contrast): (Intercept) YearI(Year^2) Kind.Geographic1 Kind.Geographic2 Kind.Geographic3 Kind.Fishers1Kind.Fishers2 1.641473e+03-1.748703e+00 4.664752e-04 -6.721427e+00 1.856033e+01 -3.762727e-02 2.903564e+01 9.022858e+01 Zone.21 Zone.22 Zone.23 Zone.24Hours Fishers Month1 Month2 8.110814e-02-1.902803e+01 8.335792e+00 -3.661641e+00-7.824623e+00 7.088065e-01 2.479387e+03 8.346729e+02 Month3 Month4 Month5 Month6 Month7Month8 Month9 Month10 4.052680e+02 2.384440e+02 1.570644e+02 1.032445e+02 7.930499e+01 6.487925e+01 5.592869e+01 3.888328e+01 Month11Year:Kind.Geographic1Year:Kind.Geographic2 Year:Kind.Geographic3 Year:Kind.Fishers1 Year:Kind.Fishers2 Year:Zone.21 Year:Zone.22
Re: [R] R and vim (gvim) on ubuntu
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 when I try to run an R command eg, x - rnorm(100,10,5) vim returns this error: ~/.pipe E212: can't open file for wirting Hi Andreas, I'd recommend to use this script instead. It uses screen to communicate R and vim, it works well. http://www.vim.org/scripts/script.php?script_id=2551 Best, - -Jose - -- Jose Quesada, PhD. Max Planck Institute, Center for Adaptive Behavior and cognition, Berlin http://www.josequesada.name/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQIVAwUBSbG4b2MobUVGH+HKAQLovRAAv/X2tRiZwRB6m+MCLG1wuBDyR5mVDmIH Ox+yrWxusxS+5ezHjasR9usVsF6PxN7C+mK9zdeFQhxrO93F8dDsCvW1B+Qq51f4 s6+lY9pPmn7SKTfIpr6PlkvLVf38y++yMLvqMCnXfu+PXENe6degY+KEtykCbQDa /gtE00zu/RYY5VslJj3/DQncJjBR7zvmyDkVTKZA7j4BTKlP6N48JDRgjd1IThrd oyUVV4JM87Sy/1rqx1/WXVV6F+9fcmRV/nF9RWjFyNaT8ILlNlrhHR6EtDj8mz0h vUs831YxUWu4o9aaioZsbMNAFQRX9uyUf+LjXj7TyRlznJgQ7ih+HJmOb7/dJD4d vQpgFQUNU31+oYwk75zvtO8tSqNsUp5qHBaZ8dSZjCEoSGARSRukhtyfLK92VrCz 2J9aSajOFUZ4/HKsu+1TJhYjOcZXgFXJo8qUQPKBt973t3N7lvIlE9/F/rq7u8Si eC5tyrm6LyUNXKKbjaS9jOyXBWfI+P3zj+i3Qo/2nmetegtmgNxYuTJlu8DFtiik gPS+BDXycrw2f8jOOJxZJ/25nsynTFQh6rAy89ZAu7GqeVFsJlwe5Gh7M64xAflG vhmnpESTFhVEGxu+CC71/PO1imbd69WDE69drF9UxTHQ7Bp6mGhI4E/1+0uXgCfN 6fJVnAMdJ9w= =iPvx -END PGP SIGNATURE- __ 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] Thousand separator on axis
Waldir Leôncio wrote: Is there an easy way to add a thousand separator mark on the axis of a plot? The best solution I've found so far is the following: y - seq(0, 10, 1) plot(y, yaxt = n, ylab = ) axis(2, at = y, labels = formatC(y, big.mark = , format = d), las=2) But that seems like quite a hassle to do every time around. Is there a way to get the same output using less parameteres? Sure: just write a function to do it. Assuming y is the only thing that varies, myplot - function(y) { plot(y, yaxt = n, ylab = ) axis(2, at = y, labels = formatC(y, big.mark = , format = d), las=2) } then myplot(y) is all you need to type. (If you want to be able to specify titles, etc., just include a ... arg to myplot.) Duncan Murdoch __ 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] Fatal error: unable to restore saved data in .Rdata
To r-help Forum: I have downloaded R 2.8.1 and stalled it on my WinXP platform in folder: C:\Program Files\R\R-2.8.1\bin\R.exe R has worked properly with my data files and packages, which one call, past. However, this week I decided to move the data files and packages to different location: C:\SIDATA Now I am experiencing crashes in R and I receive the following error messages: Error: object 'as.zoo' not found whilst loading namespace 'past' This message is followed by: Fatal error: unable to restore saved data in .Rdata Yet. when run I R from command line by clicking the following sequence, start, run, open and enter the location of C:\Program Files\R\R-2.8.1\bin\R.exe, the program works properly from the Rterm screen. Please advise me on how to correct this problem since my preferred way of using R from GUI interface. Looking forward to recommendations from this forum on how to correct this problem. Best regards, Andy [[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] NonLinear Programming in R - QUERY
Hi All, I'll appreciate your help on this. Do you know of any package that can be used to solve optimization problems subject to general *non-linear* equality constraints. Thanks! Lars. [[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] merge data frames with same column names of different lengths and missing values
Hello, I'm switching over from SAS to R and am having trouble merging data frames. The data frames have several columns with the same name, and each has a different number of rows. Some of the values are missing from cells with the same column names in each data frame. I had hoped that when I merged the dataframes, every column with the same name would be merged, with the value in a complete cell overwriting the value in an empty cell from the other data frame. I cannot seem to achieve this result, though I've tried several merge adaptations: x - data.frame(item1=c(NA,NA,3,4,5), item2=c(1,NA,NA,4,5), id=1:5) y - data.frame(item1=c(NA,2,NA,4,5,6), item2=c(NA,NA,3,4,5,NA), id=1:6) merge(x,y,by=id) #I lose observations here (n=1 in this example), and my items are duplicated - I do not want this result id item1.x item2.x item1.y item2.y 1 1 NA 1 NA NA 2 2 NA NA 2 NA 3 3 3 NA NA 3 4 4 4 4 4 4 5 5 5 5 5 5 merge(x,y,by=c(id,item1,item2)) #again I lose observations (n=4 here) and do not want this result id item1 item2 1 4 4 4 2 5 5 5 merge(x,y,by=c(id,item1,item2),all.x=T,all.y=T) #my rows are duplicated and the NA values are retained - I instead want one row per ID id item1 item2 1 1NA 1 2 1NANA 3 2 2NA 4 2NANA 5 3 3NA 6 3NA 3 7 4 4 4 8 5 5 5 9 6 6NA In reality I have multiple data frames with numerous columns, all with this problem. I can do the merge seamlessly in SAS, but am trying to learn and stick with R for my analyses. Any help would be greatly appreciated. Steve Lubitz Cardiovascular Research Fellow, Brigham and Women's Hospital and Massachusetts General Hospital __ 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] multivariate integration and partial differentiation
Could somebody share some tips on implementing multivariate integration and partial differentiation in R? For example, for a trivariate joint distribution (cumulative density function) of F(x,y,z), how to differentiate with respect to x and get the bivariate distribution (probability density function) of f(y,z). Or integrate f(x,y,z) with respect to x to get bivariate distribution of (y,z). Your sharing is appreciated. Wei-han Liu [[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.