Re: [R] Is there any good tools to facilitate us to create R functions?
Hello Zhijie, You can many specific commands and tricks by using R commander's menus: install.packages(Rcmdr) library(Rcmdr) However, I can not stress enough that if you want to be proficient and sound in your work with R, you will have to invest time reading the documentation (see documentation section here http://www.r-project.org/) and perhaps an introductory book such as the ones recommended in the R project site. Good luck! Francisco zhijie zhang wrote: Dear R users, We have some programs for the specific task in our research, but they were very commonly used. We want to make some functions for them, anybody can recommend any good tools to facilitate us to create R functions even without going deep into the theories of R functions ? Any suggestions or help are greatly appreciated. __ R-help@stat.math.ethz.ch 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] Quadratic Programming
Read the posting guide at http://www.R-project.org/posting-guide.html and try the suggestions under Do your homework before posting: You probably won't have to go past bullet 3 to find the answer to your question. Regards, Francisco Tobias Schlottmann wrote: Hi there, Is it basically possible to solve a non-convex quadratic programming with optimal solution by any way? What could be the way? How can be this problem dealt with? Could you guide me to some references please? I thank you very much for eny help. Tobi - Boardwalk for $500? In 2007? Ha! - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] several plots on several pages - bug in par(mfg())?
Hello Rainer, You need to catch the cases where the call to plot generates an error. Using your example: ## Set layout to three rows and only one column par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) ) ## First row par(mfg=c(1,1)) er-try( plot(runif(ff)), silent=T ) ## plot fails due to something. if (inherits(er, try-error)) frame() else plot(runif(100)) ## Second row par(mfg=c(2,1)) try( plot(runif(100)) ) ##actually is plotted in first row ## Third row par(mfg=c(3,1)) plot(runif(1000)) ## plotted in third row See ?try ?inherits and ?frame Notice that you will have to change plot(runif(ff)) to whatever plot you are calling. I hope this helps, Francisco Rainer M. Krug wrote: Greg Snow wrote: Oops, I read further down in your original post and see that you already knew about par(mfg=c(2,1)). To get it to advance to page 2 for the 4th plot try calling plot.new() which should move you to the next page, then doing par(mfg=c(1,1)) should cause the next graph to be at the top. Hope this helps, Thanks - I found plot.new() and it is working. But: If the first plot command fails, par(mfg=c(2,1)) does NOT move to the second one - if you try the code below, you will see. Is this a bug or am I doing something wrong? ## Set layout to three rows and only oine column par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) ) ## First row par(mfg=c(1,1)) try( plot(runif(ff)) ) ## plot fails due to something. ## Second row par(mfg=c(2,1)) try( plot(runif(100)) ) ##actually is plotted in first row ## Third row par(mfg=c(3,1)) plot(runif(1000)) ## plotted in third row __ R-help@stat.math.ethz.ch 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] CDF of a gamma distribution
pgamma(q=50,shape=5.1379,rate=0.017541) Francisco Jake Verschuyl wrote: Hi there, I have some bird flight height data that follows a gamma distribution. The data (x) goes from 0 to 700 meters (n=1055). The calculated parameters calculated from the fitdistr(x) are (shape = 5.1379, rate = 0.017541), and therefore the scale (1/rate) = 57.00929. I would like to calculate the cumulative density (or proportion of the curve) of the function at x= 50 meters. Is that possible, and are there any functions that will help? Thanks! Jake Verschuyl Ecologist P.O. Box 2561, Mount Vernon, WA 98273 Tel: 360.899.5156 Fax: 360.899.5146 P Please consider the environment before printing this email. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] test for contingency table when there are many zeros
fisher.test(tt) Francisco gallon li wrote: Here is my table tt A B 1 297 398 2 470 376 3 30 23 4 3 3 5 0 0 b/c two cells are zero, I can't use chisq.test() in R which gives the following output; chisq.test(tt) Pearson's Chi-squared test data: tt X-squared = NaN, df = 4, p-value = NA Warning message: Chi-squared approximation may be incorrect in: chisq.test(tt) What function should I use then? Any suggestion? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] presence/absence matrix
See ?table i.e. x sample # species 11 a 21 b 32 a 42 c 53 b table(x) species sample # a b c 1 1 1 0 2 1 0 1 3 0 1 0 Regards, Francisco Francisco J. Zagmutt [EMAIL PROTECTED] wrote: I have a table such that: sample # species 1a 1b 2a 2c 3b and i would like to build a matrix with species names (i.e. a b and c) as field names and samples (i.e. 1,2 and 3) as row names and 1/0 as inner values such as: a b c 1 1 1 0 2 1 0 1 3 0 1 0 I am currently using Rcmdr package for managing datasets but need a function about I tried to use stack function but only with worst results Thanks Duccio __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] random number generation
Hello Hadi, See ?rgamma The Gamma distribution usually takes two parameters, shape and scale, not the mean and st. deviation. If you have data, you can estimate those parameters using MLE methods, which are nicely provided in MASS: library(MASS) fitdistr(yourdata,Gamma) Once you have your parameters you can generate random values using rgamma i.e. rgamma(1000,10,1) will generate 1000 random samples from a Gamma distribution with shape = 10 and scale = 1. If you only have the mean and standard deviation you can approximate the shape and scale parameters using: scale=variance/mean shape=mean^2/var Remember the variance is equal to sd^2 I hope this helps, Francisco J. Zagmutt PS: Please read the posting guide (see the link at the bottom of this email). It really helps people trying to help you :-) Hadi Darzian Azizi wrote: Hi there, I am relatively new user of R. I need to generate random number following Gamma distribution with mean 14 und st.dev 3. I read the help-text but I can not understand it well. Regards, Azizi [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] maintaining specified factor contrasts when subsetting in lmer
See ?relevel Regards, Francisco Afshartous, David wrote: All, I'm using lmer for some repeated measures data and have specified the contrasts for a time factor such that say time 3 is the base. This works fine. However, when I next use the subset argument to remove the last two time values, the output indicates that the specified contrast is not maintained (see below). I can solve this by creating a new dataframe for the subset of interest and redefining the constrasts, but I was wondering if there is a direct method that allows me to continue w/ the subset argument? (perhaps via supplying a contrast argument to lmer directly, but this doesn't seem possible based on the defintion of this argument in model.matrix.default). Thanks, Dave z - rnorm(24, mean=0, sd=1) time - factor(paste(Time-, rep(1:6, 4), sep=)) Patient - rep(1:4, each = 6) drug - factor(rep(c(D, P), each = 6, times = 2)) ## P = placebo, D = Drug dat.new - data.frame(time, drug, z, Patient) ### specify the contrast as time 3: contrasts(dat.new$time) - contr.treatment(6, base=3) dimnames(contrasts(dat.new$time))[[1]] - as.character(levels(dat.new$time)) dimnames(contrasts(dat.new$time))[[2]] - as.character(levels(dat.new$time)[-3]) fm1 - lmer(z ~ drug + time + (1 | Patient), data = dat.new ) Fixed effects: Estimate Std. Error t value (Intercept) -0.182774 0.464014 -0.39390 drugP -0.281103 0.352309 -0.79789 timeTime-1 0.150505 0.606462 0.24817 timeTime-2 0.612016 0.606462 1.00916 timeTime-4 0.775342 0.606462 1.27847 timeTime-5 0.093741 0.606462 0.15457 timeTime-6 0.452442 0.606462 0.74604 ## time 3 is the base as specified fm2 - lmer(z ~ drug + time + (1 | Patient), data = dat.new, subset = dat.new$time !=Time-6 dat.new$time != Time-5) Fixed effects: Estimate Std. Error t value (Intercept) 0.052975 0.500675 0.10581 drugP -0.451593 0.447818 -1.00843 timeTime-2 0.461511 0.633310 0.72873 timeTime-3 -0.150505 0.633310 -0.23765 timeTime-4 0.624837 0.633310 0.98662 ### time 3 no longer the base; was expecting to see the fixed effects for time-1, time-2, and time-4, w/ Intercept ### representing time-3 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] probabilty plot
Hi Zeng, I just glanced at the link, but I think this is what you are after: x=rnorm(1000)#1000 random samples from N(0,1) y=rlnorm(1000)#1000 random samples from Lognormal(0,1) fx=ecdf(x)#Empirical cumulative density function of x fy=ecdf(y)#Empirical cumulative density function of y #Histogram of data hist(x) hist(y) n=seq(-4,30,.1)#Quantiles to be applied to the F(x) plot(fx(n), fy(n))#Probability plot If you are testing data against a known distribution (i.e. Normal) you may want to use the distribution function for that distribution (i.e. pnorm for the Normal distr) instead of the ecdf since that will provide you with an exact answer. i.e. plot(pnorm(n), fy(n)) Now, QQ plots are usually more useful to compare distributions since they are more sensitive to small discrepancies in the data. Take a look at qqplot and qqnorm for examples of how to create qqplots in R I hope this helps. Francisco along zeng wrote: Hi all, I am a freshman of R,but I am interested in it! Those days,I am learning pages on NIST,with url http://www.itl.nist.gov/div898/handbook/eda/section3/probplot.htm, I am meeting a problem about probability plot and I don't know how to plot a data set with R. Could somebody tell me the answer,and a example is the best! I will look forward to your answer. Thank you very much. __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Expand duplicated observations
I think this will do what you want x=c(1,2,3) rep(x,x) [1] 1 2 2 3 3 3 Regards Francisco M. P. Papadatos wrote: Dear all, I am trying to expand duplicated observations. I need to replace each observation in the dataset with n copies of the observation, where n is equal to the required expression rounded to the nearest integer. If the expression is less than 1 or equal to missing, it is interpreted as if it were 1, and the observation is retained but not duplicated. Example From c(1,2,3) To c(1,2,2,3,3,3) Thank you in advance. Best wishes, Martin __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] the biggest integer R can display in complete form but not scientific form
Also, look at options(digits) to set the number digits to be printed in the console, i.e. pi [1] 3.141593 options(digits=22) pi [1] 3.141592653589793 Regards Francisco Roland Rau wrote: 李俊杰 wrote: Dear R-lister, One of my friends wanted to produce random number which is 64 bits. He did it with Fortune. I think R can do it also. But I don't know how to display a very big integer in the complete form but not scientific form. And what's the biggest integer R can display in complete form ? Thanks in advance, Li Junjie I guess the biggest integer R can represent (if this is what you mean) is machine dependent and you can find it out via: .Machine help(.Machine) I hope this helps, Roland __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 get column/row info from a dist object?
But the dist object is not structured with rows and columns. i.e. x=1:4 d=dist(x) 1 2 3 2 1 3 2 1 4 3 2 1 str(d) Class 'dist' atomic [1:6] 1 2 3 1 2 1 ..- attr(*, Size)= int 4 ..- attr(*, Diag)= logi FALSE ..- attr(*, Upper)= logi FALSE ..- attr(*, method)= chr euclidean ..- attr(*, call)= language dist(x = x) So, AFAIK if you want to get references for rows and columns you need to make it an object that indeed has rows and columns, i.e. a matrix. See ?which to obtain the reference you want in a matrix. Regards, Francisco Pedro Mardones wrote: Dear R users; Is it possible to get the row and column number of a particular entry in a dist object? Let's say that I want to find the position of the value 1.1837 (the last entry on the dist object below), that is [6,3]. Can I get those values without transforming the object to a matrix?, i.e. working with the dist object only. 12 3 2 0.23935864 3 0.56655914 0.71923104 4 0.15272561 0.37926989 0.43931332 5 0.17728654 0.13355685 0.73025495 6 0.61783536 0.52055379 1.18374889 Thanks for any idea PM __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Random Sequence
There are many ways to do this. The first that comes to my mind is sample(c(1,-1),100,TRUE). Notice that sample also has a prob argument that may be useful for you. Francisco Anup Nandialath wrote: Dear Friends, I'm trying to generate a sequence of 100 observations with either a 1 or -1. In other words the sequence should look something like this. y = 1 1 -1 1 -1 -1 -1 1 1 .. Can somebody please give me some direction on how I can do this in R. Thanks Anup Don't get soaked. Take a quick peak at the forecast __ [EMAIL PROTECTED] 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. __ [EMAIL PROTECTED] 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] generating lognormal variables with given correlation
This reference may be relevant for you: Connover, W.J., Iman, R.L. A distribution-free approach to inducing rank correlation among input variables. Technometric, 3, 311-334, 1982. Also, you may want to look at a more modern approach implemented in the copula package: install.packages(copula) library(help=copula) I hope this helps, Francisco, Karl Ove Hufthammer wrote: Mollet, Fabian: I would like these (lognormal distributed) parameters to be correlated, that is, I would like to have pairwise samples of 2 parameters with a given correlation coefficient. I have seen that a covariance matrix can be fixed when generating random variables from a multivariate normal distribution e.g. by the function mvrnorm. Is there a function to do the same for a multivariate lognormal distribution? I don't know about any, but you should be aware that not all values of the correlation is possible with lognormal distributions. For example, if both variables have a standard lognormal distribution, they can't have correlation less than 1/e = -0.37. As the variance of the two distributions increase, the absolute value of the maximum and minimum correlation possible decrease (to zero). Using the normal product-moment correlation as a measure of dependence rarely makes much sense unless the association between the variables is linear. __ R-help@stat.math.ethz.ch 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] Cohen's Kappa
Cohen, J. (1960). A coefficient of agreement for nominal scales. Educational and Psychological Measurement, 20, 37-46. Cohen, J. (1968). Weighted kappa: Nominal scale agreement with provision for scaled disagreement or partial credit. Psychological Bulletin, 70, 213-220. Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University Christian Schulz wrote: Hi, im little bit confused about Cohen's Kappa and i should be look into the Kappa function code. Is the easy formula really wrong? kappa=agreement-chance/(1-chance) many thanks christian ### true-negativ:7445 false-positive:3410 false-negativ:347 true-positiv:772 classification-aggrement:68,6% kappa=agreement-chance/(1-chance) = (0.686-0.5)/0.5=0.372 ..with function from library(vcd) Kappa(matrix(c(7445,3410,347,772),nrow=2)) value ASE Unweighted 0.1686882 0.011235188 Weighted 0.1686882 0.007979293 __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] why are my multiple box whisker plots so small?
Please remember to add a sample of reproducible code when you post to this list (as recommended in the posting guide). You probably want to use the lattice package i.e. library(lattice) ?bwplot Francisco Ellen Husain wrote: Hi all, I'm sure this is reallly basic, but I just can get it to work. I want to plot six box whisker plots together to make one figure so that they appear one below the next. I can do this using par(mfrow=c(6,1)), but each boxwhisker plots end up vertically compressed to the point where I can't see the actual bars, and there is a large amount of white space between each one. I have tried reducing the margins using mar, but nothing happens. I've also tried using plt to make the plot area bigger, but this has no effect either. Can anyone help? Many thanks in advance, Ellen. -- __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] estimate variance
assuming your data is called dat, you can use: tapply(dat$sc, INDEX=list(p=dat$p, aa=dat$aa), var) see ?tapply and ?var I hope this helps Francisco Aimin Yan wrote: I have data like this aap sc met p1 34 met p1 56 met p2 45 met p2 33 ser p1 34 ser p1 56 ser p2 45 ser p2 33 I want to estimate the following variances for: sc in p1 for met sc in p2 for met sc between p1 and p2 for met sc for met sc in p1 for ser sc in p2 for ser sc between p1 and p2 for ser sc for ser Does anybody how to write code for this? __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] I do not understand this
I use thunderbird as my newsreader and I see the thread just fine. So, don't worry, nobody has deleted what you regard as a useful contribution. Regards Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University Tom Backer Johnsen wrote: A few days ago there was a thread on calling R from Delphi to which there were several useful responses. Now I responded as well, with what I regard as a useful contribution. Shortly after that, I was not able to able to see the thread in my newsreader (Thunderbird). Suddenly, yesterday I could see the thread again, and now it has vanished, at least from my sight. Now. Is there an error in my reader, or more likely, an error in my use of the reader. Or, has the thread been deleted for some reason. I wonder ... Tom __ R-help@stat.math.ethz.ch 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 use read.xls in R
Or alternatively you can use xlsReadWrite package install.packages(xlsReadWrite) library(xlsReadWrite) read.xls(sampledata.xls) Regards, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University Gabor Grothendieck wrote: You need perl installed for it to work. Although you normally would not need to use them note the verbose= and perl= arguments on the read.xls command. If you don't want to install perl try using RODBC: library(RODBC) z - odbcConnectExcel(/a.xls) dd - sqlFetch(z,Sheet1) close(z) On 12/7/06, Lisa Wang [EMAIL PROTECTED] wrote: Hello there, In gdata package, read.xls is to be used for reading excel data (from windows). The following is my code:('C:/session/sampledata.xls' is where the file is stored) data1-read.xls('C:/session/sampledata.xls',sheet=1) and I got the following error message: Error in system(cmd, intern = !verbose) : perl not found Could you please tell me what I have done wrong and how I should do it? Thanks a lot Lisa Wang Princess Margaret Hospital, Toronto, Ca tel:416 946 4551 __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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@stat.math.ethz.ch 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] identify extremes positions of values into matrix
Oi Milton, Is this what you are after? x=read.table(miltondat.txt) x V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 1 1 1 0 0 3 0 0 0 0 0 1 1 1 0 0 4 0 0 0 0 0 0 0 0 0 0 5 0 0 2 2 2 0 0 0 0 0 6 0 0 0 2 2 2 0 0 0 0 7 0 0 2 2 2 2 2 2 0 0 8 0 0 0 0 0 0 0 0 0 0 idx=which(x==2,arr.ind=T) #Index of observations with values == 2 . Notice the use of arr.ind=t to get the rows and columns of the observations idx row col 5 5 3 7 7 3 5 5 4 6 6 4 7 7 4 5 5 5 6 6 5 7 7 5 6 6 6 7 7 6 7 7 7 7 7 8 range(idx[,row]) #gives you the min and max of the rows with x==2 [1] 5 7 range(idx[,col])#gives you the min and max of the columns with x==2 [1] 3 8 You can refine this and wrap it in a function to make reports in a more suitable form Regards Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Milton Cezar Ribeiro [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] identify extremes positions of values into matrix Date: Fri, 3 Nov 2006 11:25:32 -0300 (ART) Hi R-friends around world! I have a matrix that looks like bellow one. Each cell are filled with values 0, 1 or 2. In fact I have a lot of 512x512 matrices, with values varying from 0 to 999. I need to retrieve the left and right columns and the top and botton lines of the matrix where occours for example the value 2. Column and row labels are included at the example. 1234567890 1 00 2 011100 3 011100 4 00 5 002220 6 000222 7 002200 8 00 At this example, the right answer are: collumns 3 and 8 lines 5 and 7 Any idea of how can I solve this? Kind regards, Miltinho - Música para ver e ouvir: You're Beautiful, do James Blunt [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. _ Try Search Survival Kits: Fix up your home and better handle your cash with Live Search! __ R-help@stat.math.ethz.ch 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] Individual Based Model and/or Cellular automata
Prezado Milton, There is a good article with examples of ABM models in R-news 3/3 2003 here: http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf The authors of that article later developed a package to facilitate the development of ecological models, called simecol. Try: install.packages(simecol) library(simecol) ?simecol Regards, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Milton Cezar Ribeiro [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Individual Based Model and/or Cellular automata Date: Wed, 1 Nov 2006 23:15:41 -0300 (ART) Hi R-gurus, Is there someone working with Individual-Based-Models (IBM) or Agent-Based-Models (ABM) with our withour Cellular Automata (CA) in R? I´m looking for develop some ecological applications, Kind regards, Miltinho Brazil - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. _ Try Search Survival Kits: Fix up your home and better handle your cash with Live Search! __ R-help@stat.math.ethz.ch 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] ncp in dt
dt calculates the density function from the student's t distribution. If you want to perform a standard t-test you may want to look at the t.test() function included in the stats package. Cheers, Francisco From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: Re: [R] ncp in dt Date: Wed, 1 Nov 2006 13:09:50 -0500 (EST) i meant dt function in my email below. my aopolgies. On Wed, 1 Nov 2006 [EMAIL PROTECTED] wrote: i just wanted to know if the non centraility parameter as it is referred to in the dt test is what i would think of as mu zero if i was doing a test of a hypothesis that the mean was equal to mu zero and the variance was unknown. thanks. __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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. _ Stay in touch with old friends and meet new ones with Windows Live Spaces __ R-help@stat.math.ethz.ch 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] binom.test
Ethan, You need to explain why you think this is not the right function to use. R is doing exactly what you are asking it to do. Now is up to you to choose the methodology you feel is correct. For a good discussion on your particular issue I recommend you the following reference: A. Agresti and B. A. Coull, Approximate is better than exact for interval estimation of binomial proportions, The American Statistician, vol. 52, no. 2, pp. 119126, 1998. Once you figure out the right function to use see if the function is available in R. If not readily available, and if after searching through R's documentation and the forum archives you still can't find a way to perform the calculation, then is time to get back to this forum. Regards, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Ethan Johnsons [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] binom.test Date: Fri, 20 Oct 2006 17:18:02 -0400 A quick question, please. 46 e coli lab samples are tested, 6 of them returned positive. So, the best point estimate for p is 6/46 = 0.1304348. For a 95% CI for p, I thought binom.test would give me the correct result, but it seems it is not the right function to use. What is the R function for this? binom.test(x=6, n=46, p=4/16, conf.level = 0.95) Exact binomial test data: 6 and 46 number of successes = 6, number of trials = 46, p-value = 0.0621 alternative hypothesis: true probability of success is not equal to 0.25 95 percent confidence interval: 0.04940735 0.26256502 sample estimates: probability of success 0.1304348 thx much, ej __ R-help@stat.math.ethz.ch 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. _ Get today's hot entertainment gossip __ R-help@stat.math.ethz.ch 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] binom.test
You can also plot an uncertainty distribution of p, using an uninformed prior (uniform(0,1)), using beta(s+1, n-s+1) i.e. x - seq(0.091, 0.469, length=100) plot(x, dbeta(.x, shape1=13, shape2=39), xlab=x, ylab=Density, main=Uncertainy distribution for p: beta(a = 12+1, b = 50-12+1), type=l) Cheers, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Chuck Cleland [EMAIL PROTECTED] To: Ethan Johnsons [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] binom.test Date: Thu, 19 Oct 2006 11:27:35 -0400 Ethan Johnsons wrote: R-experts: A quick question, please. From a lab exp, I got 12 positives out of 50. To get 90% CI for this , I think binom.test might be the one to be used. Is there a better way or function to calculate this? binom.test(x=12, n=50, p=12/50, conf.level = 0.90) Exact binomial test data: 12 and 50 number of successes = 12, number of trials = 50, p-value = 1 alternative hypothesis: true probability of success is not equal to 0.24 90 percent confidence interval: 0.1447182 0.3596557 sample estimates: probability of success 0.24 You might consider binconf() in the Hmisc package too: library(Hmisc) binconf(12, 50, method=all) PointEstLowerUpper Exact 0.24 0.130610 0.381691 Wilson 0.24 0.142974 0.374127 Asymptotic 0.24 0.121621 0.358379 thx much ej __ R-help@stat.math.ethz.ch 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch 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. _ Stay in touch with old friends and meet new ones with Windows Live Spaces __ R-help@stat.math.ethz.ch 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] Question about random sampling in R
To add to the nice explanation by Marc, you can access the source directly from the web at https://svn.r-project.org/R/trunk/src/main/random.c If you prefer to look directly in the source tarball, notice the file is called random.c Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Marc Schwartz [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: tom soyer [EMAIL PROTECTED] CC: r-help r-help@stat.math.ethz.ch Subject: Re: [R] Question about random sampling in R Date: Thu, 19 Oct 2006 13:10:20 -0500 On Thu, 2006-10-19 at 12:07 -0500, tom soyer wrote: Hi, I looked up the help file on sample(), but didn't find the info I was looking for. When sample() is used to resample from a distribution, e.g., bootstrap, how does it do it? Does it use an uniform distribution, e.g., runif(), or something else? And, when the help file says:sample(x) generates a random permutation of the elements of x (or 1:x), would I be correct if I translate the statement as follows: it means that the order of sequence, which was generated from a uniform distribution, would look like a random normal distribution. Thanks, Tom In the simplest case, where you have not specified a set of probability weights, sample() uses a uniform distribution, such that each element has an equal probability of being selected. In the case of sampling WITHOUT replacement (the default), each element in the vector has an equal probability of being selected. Once selected, that element is removed from the sampling space and the process is repeated with the remaining elements until all elements have been selected. So: sample(10) [1] 3 8 5 9 7 1 4 2 10 6 yields a random permutation of 1:10. In the case of 'replace = TRUE', which is sampling WITH replacement, after an element is selected it is retained in the sampling space, thus can be selected multiple times. So: sample(10, replace = TRUE) [1] 1 4 1 8 7 8 6 7 5 9 If you specify a set of probability weights from the sampling vector, then the probability for each element in being selected is affected accordingly. In the case of bootstrapping, sampling WITH replacement is used. You might find the following post helpful in this scenario: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67421.html If you want to investigate further, you can review the C source code for the relevant R functions in random.c in the R source tarball. The file will be in ../src/main. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Newbie: Selecting data
Welcome to the R community! I see you already learned some of the data selection methods using []. You can use the same principles to subset data i.e. dat=read.table(clipboard) #reading the data you posted, after copied to my clipboard dat start therms gas KWHs elect temp days 1 10-Jun-98 9 16.84 613 63.80 75 40 2 20-Jul-98 6 15.29 721 74.21 76 29 3 18-Aug-98 7 15.73 597 62.22 76 29 4 16-Sep-98 42 35.81 460 43.98 70 33 5 19-Oct-98105 77.28 314 31.45 57 29 6 17-Nov-98106 77.01 342 33.86 48 30 subDat=dat[dat$temp65,] #Subsetting only days with temp65. Notice the use of commas and $ here subDat start therms gas KWHs elect temp days 5 19-Oct-98105 77.28 314 31.45 57 29 6 17-Nov-98106 77.01 342 33.86 48 30 You can also use the higher level function subset i.e. subDat=subset(dat, temp 65) subDat start therms gas KWHs elect temp days 5 19-Oct-98105 77.28 314 31.45 57 29 6 17-Nov-98106 77.01 342 33.86 48 30 I would encourage you to invest some time reading the pdf manual available in the main console under Help-Manuals (in pdf) - An Introduction to R I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Zembower, Kevin [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Newbie: Selecting data Date: Thu, 19 Oct 2006 16:12:54 -0400 I've been working with R for all of about 8 hours, so anyone with more experience than this should be able to help me. General comments about my methods of work are also welcomed. I have a table that I've imported thusly: w - read.table(woodford.data, header=T) w start thermsgas KWHs elect temp days 1 10-Jun-98 9 16.84 613 63.80 75 40 2 20-Jul-98 6 15.29 721 74.21 76 29 3 18-Aug-98 7 15.73 597 62.22 76 29 4 16-Sep-98 42 35.81 460 43.98 70 33 5 19-Oct-98105 77.28 314 31.45 57 29 6 17-Nov-98106 77.01 342 33.86 48 30 snip [This is real data on my house.] 'days' is number of days in bill, 'temp' is average temperature in Fahrenheit. I'd like to see if there is a relationship between the gas burned (therms) and the number of heating degree days. I compute therms per day and heating degree days like this: thermsperday - w[,2]/w[,7] hdd - (w[,6] -65)*w[,7] However, I only want the data for the months in which the average temperature is less than 65 (otherwise, it's a cooling degree day). I tried ifelse, but couldn't get it to work. What simple technique am I overlooking? Thanks so much for your help and suggestions, especially for your patience with a newbie. -Kevin Kevin Zembower Internet Services Group manager Center for Communication Programs Bloomberg School of Public Health Johns Hopkins University 111 Market Place, Suite 310 Baltimore, Maryland 21202 410-659-6139 __ R-help@stat.math.ethz.ch 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. _ Get today's hot entertainment gossip __ R-help@stat.math.ethz.ch 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] barplot question
Try RSiteSearch(rotate barplot labels) Then read the first thread for an example of what you want to do. Cheers Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Leeds, Mark (IED) [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] barplot question Date: Tue, 17 Oct 2006 17:15:43 -0400 i'm doing a bar plot and there are 16 column variables. is there a way to make the variable names go down instead of across when you do the barplot ? because the names are so long, the barplot just shows 3 names and leaves the rest out. if i could rotate the names 90 degrees, it would probably fit a lot more. or maybe i can use space to make the horizontal width longer ? I looed up ?barlot but i'm not sure. when 1st and 2nd are on the bottom, things look fine but i'm not as interesed in those 2 barplots. i didn't use any special options. i just did barplot(probsignmatrix) barplot(t(probsignmatrix)) barplot(probsignmatrix,beside=T) barplot(t(probsignmatrix),beside=T) i put probsignmatrix below in case someone wants to see what i mean because it may not be clear. i don't expect anyone to type it in but rounding would still show what i mean. thanks a lot. pcount pmpppcount pmmppcount pmmmpcount pcount mcount pppmmcount ppmmmcount ppmppcount ppmmpcount pppmpcount ppmpmcount pmpmpcount pmpmmcount pmmpmcount pmppmcount 1st 0.03477157 0.02842640 0.03157360 0.03365482 0.04010152 0.03553299 0.03989848 0.04182741 0.02817259 0.03203046 0.02781726 0.02218274 0.01771574 0.02289340 0.02583756 0.02390863 2nd 0.04648895 0.02901495 0.03092490 0.03064044 0.04108420 0.03998700 0.03958062 0.04059655 0.03039662 0.03027471 0.02901495 0.02170026 0.01601105 0.02287874 0.02165962 0.02267555 This is not an offer (or solicitation of an offer) to buy/sell the securities/instruments mentioned or an official confirmation. Morgan Stanley may deal as principal in or own or act as market maker for securities/instruments mentioned or may advise the issuers. This is not research and is not from MS Research but it may refer to a research analyst/research report. Unless indicated, these views are the author's and may differ from those of Morgan Stanley research or others in the Firm. We do not represent this is accurate or complete and we may not update this. Past performance is not indicative of future returns. For additional information, research reports and important disclosures, contact me or see https://secure.ms.com/servlet/cls. You should not use e-mail to request, authorize or effect the purchase or sale of any security or instrument, to send transfer instructions, or to effect any other transactions. We cannot guarantee that any such requests received via ! e-mail will be processed in a timely manner. This communication is solely for the addressee(s) and may contain confidential information. We do not waive confidentiality by mistransmission. Contact me if you do not wish to receive these communications. In the UK, this communication is directed in the UK to those persons who are market counterparties or intermediate customers (as defined in the UK Financial Services Authority's rules). [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] strange error in mtrace
I vaguely remember seeing a bug report for the debug library a few days ago but I can't find the thread. I think it was a compatibility issue with 2.4.0 but the mantainer was already working on it. Maybe somebody else can provide a link to the specific posting? I am sorry I can't be of more assistance. Best regards, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Vladimir Eremeev [EMAIL PROTECTED] Reply-To: Vladimir Eremeev [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] strange error in mtrace Date: Tue, 17 Oct 2006 18:33:45 -0800 Dear useRs, I am experiencing very strange error with Mark Bravington's package debug. I haven't seen them before. Here is the sample session library(debug) Loading required package: mvbutils MVBUTILS: no tasks vector found in ROOT Loading required package: tcltk Loading Tcl/Tk interface ... done x-function() return(1) mtrace(x) x() Error in attr(value, row.names) - rlabs : row names must be 'character' or 'integer', not 'double' mtrace(x,FALSE) x() [1] 1 mtrace(x) x() Error in attr(value, row.names) - rlabs : row names must be 'character' or 'integer', not 'double' This happened with any function, which I tried to debug. I use R 2.4.0 on Linux and on Windows. debug version is 1.1.0, mvbutils version is 1.1.1 on both systems. Linux R was compiled from sources. The packages were installed from the Internet repositories using install.packages function on both systems. update.packages only asks for repository for current session, and does nothing, which means, that everything is of the latest version. What could be wrong? --- Best regards, Vladimirmailto:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] positive semi-definite matrix
Take a look at make.positive.definite in the corpcor package. The implementation is very similar to what Duncan suggested. Regards, Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Duncan Murdoch [EMAIL PROTECTED] To: roger bos [EMAIL PROTECTED] CC: RHelp r-help@stat.math.ethz.ch Subject: Re: [R] positive semi-definite matrix Date: Fri, 21 Jul 2006 09:44:42 -0400 On 7/21/2006 8:59 AM, roger bos wrote: I have a covariance matrix that is not positive semi-definite matrix and I need it to be via some sort of adjustment. Is there any R routine or package to help me do this? I think you need to be more specific about what have and what you want, but if the matrix is symmetric and nearly positive semi-definite (but not exactly because of rounding error), you might try something like fixit - function(A) { eig - eigen(A, symmetric = TRUE) eig$values - pmax(0, eig$values) return(eig$vectors %*% diag(eig$values) %*% t(eig$vectors)) } Rounding error means this is not guaranteed to be positive semi-definite, but it will be very close. Duncan Murdoch __ R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Write a summary or a longer text to a graphical device
?text ?plotmath Cheers Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Torsten Mathies [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Write a summary or a longer text to a graphical device Date: Thu, 13 Jul 2006 22:39:37 +0200 How can I write a text, such as a result of a function or an explanation to a graphic device? When I try plot, I'm unable to reduce the axes. Greetings torsten __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] distribution of daily rainfall values in binned categories
Hi Martin I agree with all your previous concerns. I was just answering her question about visualizing frequencies for a continuous variable that is artificially categorized. However, she did mention the word *distribution* (a part that I obviously ignored when I posted my answer) so your comments are more than appropriate. I am surprised nobody else jumped with the usual discussion about violin plots and his friends ;-) Cheers Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Martin Maechler [EMAIL PROTECTED] Reply-To: Martin Maechler [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] distribution of daily rainfall values in binned categories Date: Wed, 28 Jun 2006 10:39:58 +0200 FJZ == Francisco J Zagmutt [EMAIL PROTECTED] on Wed, 28 Jun 2006 03:51:31 + writes: FJZ Hi Etienne, FJZ Somebody asked a somehow related question recently. FJZ http://tolstoy.newcastle.edu.au/R/help/06/06/29485.html FJZ Take a look at cut? table? and barplot? FJZ i.e. # Creates fake data from uniform(0,30) set.seed(1) ## - added by MM x=runif(50, 0,30) # Creates categories rain=cut(x,breaks=c( 0, 1,2.5,5, 10, 20, Inf)) # Creates contingency table of categories tab=table(rain) # Plots frequencies of rainfall barplot(tab) No, no, no! Do not confuse histograms with bar plots! - barplot() is {one possibility} for visualizing discrete (categorical, factor) data, - hist() is for visualizing *continuous* data (*) As Jim Porzak replied, do use hist(): the example really is a matter of visualization of a continuous distribution which should *not* be done by a barplot. Instead, e.g., hist(x, breaks = c(0, 1,2.5,5, 10,20, max(pretty(max(x, freq = TRUE, col = gray) will give a graphic similar to the above --- BUT also warns you about the hidden deception (aka sillyness) of *both* graphics: Namely, the above hist() call warns you with Warning message: the AREAS in the plot are wrong -- rather use freq=FALSE in: and finally, hist(x, breaks = c(0, 1,2.5,5, 10,20, max(pretty(max(x, col=gray) gives you a more honest graphic --- which -- for the runif() example -- may finally lead to you to realize that using unequal break may really not be such a good idea. Note however that for the OP rainfall data, that may well be different and if I look at rainfall data, I find I would rather view hist(log10( rainfall )) or then plot(density( log10( rainfall ) )) Martin Maechler, ETH Zurich (*) From statistical point of view, histograms just density estimators, and -- as known for a while -- have quite some drawbacks. Hence they should nowadays often be replaced by plot(density(.), ..) From: etienne [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] distribution of daily rainfall values in binned categories Date: Tue, 27 Jun 2006 11:28:59 -0700 (PDT) Hi, I'm a newbie in using R and I would like to have a few clues as to how I could compute and plot a distribution of daily rainfall intensity in different categories. I have daily values (mm/day) for several years and I need to show the frequency of 0-1, 1-2.5, 2.5-5, 5-10, 10-20, 20+ mm/day. Can this be done easily? Thanks, Etienne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html FJZ __ FJZ R-help@stat.math.ethz.ch mailing list FJZ https://stat.ethz.ch/mailman/listinfo/r-help FJZ PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reading a matrix from a file
Dear Cuau More details on your posting would have helped. From your example it seems that the matrix you are trying to import is just a comma Separated text file. If that's the case, you can use read.csv and matrix to import those numbers and then make a matrix in R. Assuming the matrix has 3 rows and 4 columns you can do the following: x=read.csv(mymatrix.txt, header=FALSE) #Reads your file dim(x) #Tells you the dimensions of object x in rows and columns [1] 3 4 newMat= as.matrix(x) #Creates matrix from imported data is.matrix(newMat) #Tests whether the object newMat is of class matrix [1] TRUE I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Cuau [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] reading a matrix from a file Date: Tue, 27 Jun 2006 08:06:36 -0700 (PDT) Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as one big String with no divitions. I tried using strsplit(String) to split it but eventhough is working I'm not able to put the output of the above into a matrix. Below is an example of what I have done INfile-file(mTest.txt, r) readLines(INfile)-matrix matrix [1] 1, 2, 3 strsplit(matrix, ,)-splitLine splitLine [[1]] [1] 1 2 3 netMatrix -matrix(c(splitLine), nrow=1,ncol=3) netMatrix [,1] [,2] [,3] [1,] Character,3 Character,3 Character,3 Does anyone have an idea how can I read a matrix and store it in the form of a matrix. thks -Cuau Vital - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] supplying dynamic main argument to plot?
Hi Dave, Try using paste within main i.e. x=rnorm(100) y=runif(100) k=sample(1:10,10, replace=T) for(i in k){ plot(x,y, xlab=gamma, ylab=r1, main=paste(Patient, i, sep= )) Sys.sleep(1) } In this eaxmple I am just plotting the same x,y values on each figure but you can easily plot the observations for each patient by subetting your data by the K variable. See ?[ for more details on subsetting. I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Afshartous, David [EMAIL PROTECTED] To: Afshartous, David [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: [R] supplying dynamic main argument to plot? Date: Tue, 27 Jun 2006 16:19:12 -0400 All, Simple question but I don't seem to be able to find the answer in the documentation: When using plot within a loop, is there any way to supply the argument to main dynamically, i.e., so that the title is Patient k below as the loop cycles through each value of k? plot(x,y, xlim=c(0,250), ylim=c(0,1000), xlab=gamma, ylab=r1, main=Patient k) thanks dave ps - I'm running windows. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] distribution of daily rainfall values in binned categories
Hi Etienne, Somebody asked a somehow related question recently. http://tolstoy.newcastle.edu.au/R/help/06/06/29485.html Take a look at cut? table? and barplot? i.e. #Creates fake data from uniform(0,30) x=runif(50, 0,30) #Creates categories rain=cut(x,breaks=c( 0, 1,2.5,5, 10, 20, Inf)) #Creates contingency table of categories tab=table(rain) #Plots frequencies of rainfall barplot(tab) I hope this helps! Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: etienne [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] distribution of daily rainfall values in binned categories Date: Tue, 27 Jun 2006 11:28:59 -0700 (PDT) Hi, I'm a newbie in using R and I would like to have a few clues as to how I could compute and plot a distribution of daily rainfall intensity in different categories. I have daily values (mm/day) for several years and I need to show the frequency of 0-1, 1-2.5, 2.5-5, 5-10, 10-20, 20+ mm/day. Can this be done easily? Thanks, Etienne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Query about getting a table of binned values
Dear Lalitha Take a look at ?cut and ?table. Cut will create categories of your continuous Age variable and table will create a contingency table of the categorized values against Type i.e. #Creates practice data frame dat=data.frame(Type=sample(c(TypeA,TypeB,TypeC),100,replace=T),Age=runif(100)) #Creates table tab=table(dat$Type, cut(dat$Age,seq(0,1,.02))) You can use the labels argument within cut to get a more pretty output I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: lalitha viswanath [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Query about getting a table of binned values Date: Tue, 20 Jun 2006 13:57:07 -0700 (PDT) Hi I am working with a dataset of age and class of proteins #Age 0 0.0 0.677 #Class Type A Type B . . . Type K I wish to get a table that reads as follows 0-0.02 0.02-0.04 0.04-0.06 . 0.78-0.8 Type A15 20 5 8 Type B 86 . . . Type K 10 7 I would appreciate your input regarding the appropriate functions to use for this purpose regards Lalitha __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Determine the data type of a function to an argument
Look at ?class and perhaps is?. i.e. x=c(1,2,3) class(x) [1] character x=c(1,2,3) class(x) [1] numeric I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Alex Restrepo [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Determine the data type of a function to an argument Date: Tue, 20 Jun 2006 15:48:03 -0500 Hello All: How can I determing the types of args passed to an R function? For example, given the following: calculate - function(...) { args - list(...) argName = names(args) if (arg1 == character) cat(arg1 is a character) else cat(arg1 is numeric) if (arg2 == character) cat(arg2 is a character) else cat(arg2 is a numeric) } value = calculate(arg1='222' arg2=333) Programatically, how can I determine if arg1 is a character and arg2 is numeric? Many Thanks: Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unique?
Hi Cameron You need to be more specific when you ask a question so you can get a better answer. Anyhow, when you say that you want to retain all the other variables do you mean that you want to create a new column in the dataset that contains the calculated sum? If that is the case you can use a construction like: set.seed(1) step4-data.frame(TRIPID=rep(c(111,222,333),3),CONVUNIT=rpois(9,40)) result-tapply(step4$CONVUNIT,INDEX=step4$TRIPID,FUN=sum) step4[,SUM]=result[match(step4[,TRIPID],names(result))] step4 TRIPID CONVUNIT Sum 1111 36 122 2222 48 121 3333 48 129 4111 42 122 5222 30 121 6333 43 129 7111 44 122 8222 43 121 9333 38 129 Cheers Francisco From: Guenther, Cameron [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] Subject: RE: [R] Unique? Date: Thu, 11 May 2006 12:08:31 -0400 It is close but not quite what I want. I need to retain all of the other variables as well. Cameron Guenther, Ph.D. Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [EMAIL PROTECTED] -Original Message- From: Francisco J. Zagmutt [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 10, 2006 6:06 PM To: Guenther, Cameron; r-help@stat.math.ethz.ch Subject: RE: [R] Unique? If you only care about the sum of CONVUNIT by each TRIPID then you can use tapply i.e.: step4-data.frame(TRIPID=rep(c(111,222,333),3),CONVUNIT=rpois(9,40)) result-tapply(step4$CONVUNIT,INDEX=step4$TRIPID,FUN=sum) result 111 222 333 115 107 123 Is this what you wanted to do? I can't think of anything faster than tapply for your problem. I hope this helps Francisco From: Guenther, Cameron [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Unique? Date: Wed, 10 May 2006 17:02:33 -0400 Hello, I have sample data set that looks like: YEAR MONTH DAY CONTINUESPL TIMEFISH TIMEUNIT AREACOUNTY DEPTH DEPUNIT GEARTRIPID CONVUNIT 1992 1 26 1 SP0073928 8 H7 25 4 NA 100 02163399054 161 1992 1 26 1 SP0073928 8 H7 25 4 NA 100 02163399054 8 1992 1 26 2 SP0004228 8 H7 25 4 NA 100 02163399054 161 1992 1 26 2 SP0004228 8 H7 25 4 NA 100 02163399054 8 1992 1 25 NA SP0052652 8 H7 25 4 NA 100 02163399057 85 1992 1 26 NA SP0037940 8 H7 25 4 NA 100 02163399058 70 1992 1 27 NA SP0072357 8 H7 25 4 NA 100 02163399059 15 1992 1 27 NA SP0072357 8 H7 25 4 NA 100 02163399059 20 1992 1 27 NA SP0026324 8 H7 25 4 NA 100 02163399060 8 1992 1 28 1 SP0072357 8 H7 25 4 NA 100 02163399062 200 How can I use unique to extract the rows that have repeated tripid's only, not a unique value for each variable but only for TRIPID. I then want to condense the unique values by summing the CONVUNIT for each unique value of TRIPID. I posted a similar question last week and received a sufficient answer of how to do this without using uniqe. The solution below worked just fine on this sample data set but the full data set has 446,000 rows of data and my computer and R simply cannot handle this follwing code on data this large. conds-by(Step4,Step4$TRIPID,function(x) replace(x[1,],CONVUNIT,sum(x$CONVUNIT))) Step5-do.call(rbind,conds) Thank you, Cameron Guenther, Ph.D. Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] count repetitions
See ?rle i.e.: x=c(0,0,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,0,0) rle(x) Run Length Encoding lengths: int [1:7] 2 3 1 3 1 4 5 values : num [1:7] 0 1 0 1 0 1 0 I hope this helps Francisco From: Jean-Pierre GERBAL [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] count repetitions Date: Thu, 11 May 2006 17:42:55 +0200 bonjour, i have a serie : x-sample(c(0,1),50,T) and i want to count the length of each repetition of 0 and of 1 (00111011100 give 2313145)... who have an idea ? merci :-) jean-pierre __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Now another question regarding the Foreign package
Dear David I suspect you downloaded 'foreign' but you didn't load it to your workspace. To do that you have to use library(foreign). Then you can have access to the functions in that package. In addition to the manuals that come with R (Help-Manuals (in pdf)) there is a wealth of reading material available on the R homepage under 'Documentation'. A good starting point is to buy one of the books recommended in the books section. I hope this helps Francisco From: David Kaplan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Now another question regarding the Foreign package Date: Thu, 11 May 2006 15:42:34 -0400 Hi, Because I'm new to R and trying to move off of SPSS, I have another question. I downloaded the Foreign package which I understand reads in various datasets from programs such as SPSS and SAS. There isn't much documentation that I can find regarding the specifics of this in the online docs, but I assume that it is like read.table. So, here is what I wrote and here is what I got. bw2 - read.spss(c:\birthwt.sav) Error: couldn't find function read.spss Any thoughts? Thanks again for your help. David [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unique?
If you only care about the sum of CONVUNIT by each TRIPID then you can use tapply i.e.: step4-data.frame(TRIPID=rep(c(111,222,333),3),CONVUNIT=rpois(9,40)) result-tapply(step4$CONVUNIT,INDEX=step4$TRIPID,FUN=sum) result 111 222 333 115 107 123 Is this what you wanted to do? I can't think of anything faster than tapply for your problem. I hope this helps Francisco From: Guenther, Cameron [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Unique? Date: Wed, 10 May 2006 17:02:33 -0400 Hello, I have sample data set that looks like: YEAR MONTH DAY CONTINUESPL TIMEFISH TIMEUNIT AREACOUNTY DEPTH DEPUNIT GEARTRIPID CONVUNIT 1992 1 26 1 SP0073928 8 H 7 25 4 NA 100 02163399054161 1992 1 26 1 SP0073928 8 H 7 25 4 NA 100 021633990548 1992 1 26 2 SP0004228 8 H 7 25 4 NA 100 02163399054161 1992 1 26 2 SP0004228 8 H 7 25 4 NA 100 021633990548 1992 1 25 NA SP0052652 8 H 7 25 4 NA 100 0216339905785 1992 1 26 NA SP0037940 8 H 7 25 4 NA 100 0216339905870 1992 1 27 NA SP0072357 8 H 7 25 4 NA 100 0216339905915 1992 1 27 NA SP0072357 8 H 7 25 4 NA 100 0216339905920 1992 1 27 NA SP0026324 8 H 7 25 4 NA 100 021633990608 1992 1 28 1 SP0072357 8 H 7 25 4 NA 100 02163399062200 How can I use unique to extract the rows that have repeated tripid's only, not a unique value for each variable but only for TRIPID. I then want to condense the unique values by summing the CONVUNIT for each unique value of TRIPID. I posted a similar question last week and received a sufficient answer of how to do this without using uniqe. The solution below worked just fine on this sample data set but the full data set has 446,000 rows of data and my computer and R simply cannot handle this follwing code on data this large. conds-by(Step4,Step4$TRIPID,function(x) replace(x[1,],CONVUNIT,sum(x$CONVUNIT))) Step5-do.call(rbind,conds) Thank you, Cameron Guenther, Ph.D. Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Concatenating data frame
And adding to Jim's solution, you may be able to further improve the speed of your code by pre-allocating the list size i.e result - vector(list,100) for (i in 1:100){ result[[i]] - data.frame(id=sample(letters,1), value=i) } newDataFrame - do.call('rbind', result) Cheers Francisco From: jim holtman [EMAIL PROTECTED] To: Charles Cheung [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Concatenating data frame Date: Wed, 10 May 2006 19:02:15 -0400 Put the intermediate results in a list and then use do.call: result - list() for (i in 1:100){ result[[i]] - data.frame(id=sample(letters,1), value=i) } newDataFrame - do.call('rbind', result) On 5/10/06, Charles Cheung [EMAIL PROTECTED] wrote: Hello, I have searched through the R-help archive and find that the easiest way to concatenate data records in a dataframe is to use rbind() I know we can do that using rbind, but it is slow when we are doing rbind thousands of times to a growing list, each time adding one or two records to the ever growing existing data because in existingRecords-rbind(existingRecords, aNewRecordToBeAdded), I am making a copy of the data each time rbind is called! Is there a way to avoid these data copying? Thank you in advance! Charles __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lwd - Windows
Dear Prof Brian Ripley Thanks for replying to my question. I am sorry but it is still not clear to me if there is a way to handle an intermediate line width. In my windows system when I create a figure with 4 plots par(mfrow=c(2,2),lwd=1) the lines look a bit too thin and using lwd=2 makes them look a bit too thick, and if I use 1.5 it makes no difference. i.e par(mfrow=c(2,2)) plot(sin,lwd=1)#Too thin plot(sin,lwd=1.5)#Same as lwd=1 plot(sin,lwd=1.99)#Same as lwd=1 plot(sin,lwd=2)#Too thick Regards Francisco From: Prof Brian Ripley [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: R-help@stat.math.ethz.ch Subject: Re: [R] lwd - Windows Date: Wed, 26 Apr 2006 11:34:05 +0100 (BST) On Wed, 26 Apr 2006, Francisco J. Zagmutt wrote: Dear all Is there a way or trick in windows to plot a line width that is not an integer i.e 1.5? I am aware that the documentation for window devices states Line widths as controlled by par(lwd=) are in multiples of the pixel size, and multiples 1 are silently converted to 1 but I was wondering if there is a workaround this. That's not what it says in R 2.3.0 (nor in my copy of 2.2.1)! ?windows says Line widths as controlled by 'par(lwd=)' are in multiples of 1/96inch. Multiples less than 1 are allowed, down to one pixel width. Also, IMHO the documentation for lwd in par may need some clarification since it states: The line width, a positive number, defaulting to 1. The interpretation is device-specific, and some devices do not implement line widths less than one. Perhaps it would be useful for the users to describe the behavior for the most important devices, and also to state that the number is an integer (at least for windows) and not just a positive number? False premise. Please don't ask for the documentation to be changed to your personal misreading of it. -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lwd - Windows
Dear all Is there a way or trick in windows to plot a line width that is not an integer i.e 1.5? I am aware that the documentation for window devices states Line widths as controlled by par(lwd=) are in multiples of the pixel size, and multiples 1 are silently converted to 1 but I was wondering if there is a workaround this. Also, IMHO the documentation for lwd in par may need some clarification since it states: The line width, a positive number, defaulting to 1. The interpretation is device-specific, and some devices do not implement line widths less than one. Perhaps it would be useful for the users to describe the behavior for the most important devices, and also to state that the number is an integer (at least for windows) and not just a positive number? version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R Thanks Francisco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] the difference between x1 and x1
Is this what you are after? floor(data[,model.list]) Or I just didn't understand what you are trying to accomplish? cheers Francisco PS: try to avoid using names that are already reserved to a function like data See ?data From: Chad Reyhan Bhatti [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] the difference between x1 and x1 Date: Thu, 20 Apr 2006 18:02:02 -0500 (CDT) Hello, I am not sure what to write in the subject line, but I would like to take a character string that is a variable in a data frame and apply a function that takes a numeric argument to this character string. Here is a simplified example that would solve my problem. Imagine I have my data stored in a data frame. x1 - x2 - x3 - x4 - x5 - rnorm(20,0,1); data - as.data.frame(cbind(x1,x2,x3,x4,x5)); I have a vector containing the variables of interest as such. model.list - c(x1,x3,x4); model.list[1] [1] x1 I would like to loop through this vector and apply the floor() function to each variable. In the current form the elements of model.list do not represent the variables in the data frame. floor(model.list[1]) Error in floor(model.list[1]) : Non-numeric argument to mathematical function floor(eval(model.list[1])) Error in floor(eval(model.list[1])) : Non-numeric argument to mathematical function s - expression(paste(floor(,model.list[1],),sep=)) s expression(paste(floor(, model.list[1], ), sep = )) eval(s) [1] floor(x1) I have tried the obvious (to me) without success. Perhaps someone could suggest a solution and some tidbits for me to read up on about the how and why. Thanks, Chad R. Bhatti __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R debugging options
RSiteSearch(debug) or RSiteSearch(debugging) will give you a lot or relevant information. I personally use library(debug) extensivelly and it should do all the taks you asked about. There is a nice article describing the debug lilbrary in the 2003/3 issue of R News http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf Cheers Francisco From: Larry Howe [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: Re: [R] R debugging options Date: Mon, 17 Apr 2006 20:29:47 -0400 On Monday April 17 2006 19:45, Larry Howe wrote: Hello, What options are available for me to debug my R scripts? For example I normally do something like source(myfunctions.R) function1(height, weight) myfunctions.R is a large R source file that contains many functions. function1 is the main function in myfunctions.R. It calls many other user-written functions that are also in myfunctions.R. I only want to debug the R scripts. I do not need to get into the code of R itself. I would like to be able to: - see the source as I am debugging - execute line-by-line - see and modify variables - have the option to either descend into function calls, or not - have the option to either descend into loops, or not Maybe this is asking too much but I thought I would lay out my dreams and then you can tell me what is really possible. Forgot to mention: I am working in linux and solaris. Other people here are working in windows. So I am interested in options for either platform. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about McNemar
Please consider using R's built-in help capabilities before posting a question. help.search(McNemar) RSiteSearch(McNemar) Regards Francisco From: XinMeng [EMAIL PROTECTED] Reply-To: XinMeng [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] about McNemar Date: Thu, 13 Apr 2006 10:50:26 +0800 Hello sir: How can I perform McNemar (paired chi square test) by using R? Thanks! -- *** Xin Meng Capitalbio Corporation National Engineering Research Center for Beijing Biochip Technology BioPharma-informatics Software Dept. Research Engineer Tel: +86-10-80715888/80726868-6438 Fax: +86-10-80726790 [EMAIL PROTECTED] Address:18 Life Science Parkway, Changping District, Beijing 102206, China __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Determining frequancy of events
This is not a very generic option, but for your example you can use unique and cbind to create a new dataframe with the results i.e a-c(1,2,3,1,5) b-c(2,2,2,2,2) c-c(2,3,4,2,6) f=as.integer(table(paste(a,b,c)))#Stores only frequency data.frame(unique(cbind(a,b,c)),freq=f) a b c freq 1 1 2 22 2 2 2 31 3 3 2 41 4 5 2 61 I hope this helps Francisco From: Philip Bermingham [EMAIL PROTECTED] To: Philip Bermingham [EMAIL PROTECTED] CC: r-help r-help@stat.math.ethz.ch Subject: [R] Determining frequancy of events Date: Sun, 2 Apr 2006 18:10:37 -0400 I have a smiple set of values: a-c(1,2,3,1,5) b-c(2,2,2,2,2) c-c(2,3,4,2,6) Then I use data.frame(table(paste(a,b,c)))to determine the frequancy of each set of values occures and get the result: Var1 Freq 1 1 2 22 2 2 2 31 3 3 2 41 4 5 2 61 This is exactly what I need although the paste function puts the values into a string. I want to split the var1 into three variables while hanging onto the frequancy count so the result would be like: v1 v2 v3 Freq 1 1 2 2 2 2 2 2 3 1 3 3 2 4 1 4 5 2 6 1 What is the best way to do this? Thanks in advance, Philip. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Glm poisson
Why are you trying to extract the values by calling a function with the name of the value? glm objects are stored as a list i.e. str(pAmeir_1) Hence, you can extract what you need by selecting the values on the list i.e. pAmeir_1$df.null pAmeir_1$null.deviance Cheers Francisco From: Guenther, Cameron [EMAIL PROTECTED] To: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: [R] Glm poisson Date: Mon, 27 Mar 2006 12:07:04 -0500 Hello, I am using the glm model with a poisson distribution. The model runs just fine but when I try to get the null deviance for the model of the null degrees of freedom I get the following errors: null.deviance(pAmeir_1) Error: couldn't find function null.deviance df.null(pAmeir_1) Error: couldn't find function df.null When I do: names(pAmeir_1) [1] coefficients residuals fitted.values [4] effects R rank [7] qrfamilylinear.predictors [10] deviance aic null.deviance [13] iter weights prior.weights [16] df.residual df.null y [19] converged boundary model [22] call formula terms [25] data offsetcontrol [28] methodcontrasts xlevels It tells me that the values are there but I can not access them. Any comments would be greatly appreciated. Thank you Cameron Guenther, Ph.D. Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] transparent background for PDF
Hi Dennis Out of curiosity, how did you import the pdf to Power Point? I am running windows so it may be different (and completelly irrelevant to you!) but when I want to place a pdf image in a PPT slide I copy the file to the clipboard and then paste it in Power Point. Then in Power Point you can right click on the image- show picture toolbar and then use the tool Set Transparent Color. That will give you a transparent background but you may not get be the best quality, so in general I prefer to save the image as a bmp or some other format and then insert that into Power Point directly using the Insert menu in PPT. I hope this helps Francisco From: Jari Oksanen [EMAIL PROTECTED] To: Dennis Fisher [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] transparent background for PDF Date: Fri, 24 Mar 2006 21:11:52 +0200 On 24 Mar 2006, at 20:30, Dennis Fisher wrote: Colleagues Running R2.2.1 on either a Linux (RedHat 9) or Mac (10.4) platform. I created a PDF document using pdf(FILENAME.pdf, bg=transparent, version=1.4). I then imported the graphic into PowerPoint - background was set to a non-transparent color. I was hoping that the inserted graphic would be transparent - instead, it had a white background. According to my experience, this is a feature of PowerPoint which seems to be incapable to display transparent background in PDF. This also concerns transparent background PDF's from other programmes than R. This experience is from Linux Mac (pdf) and PP in Mac (never tried that with PowerPoint on Linux...). cheers, jari oksanen -- Jari Oksanen, Oulu, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] new to R
Hi Linda Did you already get a reply to your question? If not, try adding a new line at the end of the text (just hit enter after 69,the last number in your data and save the file). You also want to use the argument sep in read.table Since you have a comma at the end of each row you can either manually delete that and use read.table, or just import it the way it is and then delete the last variable (V4) created because of the extra comma i.e z- read.table(q.txt, sep=,) z V1 V2 V3 V4 1 1 2 3 NA 2 33 44 88 NA 3 23 43 69 NA #V4 is an artifact from your extra comma at the end of each row newz-z[,-4] #Deletes V4 I hope this helps Francisco From: linda.s [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] new to R Date: Thu, 23 Mar 2006 01:05:21 -0800 z - read.table(c:/temp/q.txt) Warning message: incomplete final line found by readTableHeader on 'c:/temp/q.txt' what does that mean? my q.txt is like: 1, 2, 3, 33, 44, 88, 23, 43, 69, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Modified KS test to handle ties.
RSiteSearch(KS ties) turned this: http://finzi.psych.upenn.edu/R/library/Matching/html/ks.boot.html Does this help? Best Francisco From: Steve Su [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Modified KS test to handle ties. Date: Wed, 22 Mar 2006 11:28:06 +1100 Dear All, I wonder if there is now an implementation of a modified KS test that can handle ties? Steve. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] removing NA from a data frame
Hi Sam If you are new to R it will definitively pay off to start from the basics. Go to the help menu- manuals in pdf and select An Introduction to R. After you read that document you will be able to answer your questions :-) Good luck! Francisco From: Sam Steingold [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] removing NA from a data frame Date: Fri, 17 Mar 2006 15:17:51 -0500 Hi, It appears that deal does not support missing values (NA), so I need to remove them (NAs) from my data frame. how do I do this? (I am very new to R, so a detailed step-by-step explanation with code samples would be nice). Some columns (variables) have quite a few NAs, so I would rather drop the whole column than sacrifice all the rows (observations) which have NA in that column. How do I remove a column from a data frame? Thanks! -- Sam Steingold (http://www.podval.org/~sds) on Fedora Core release 4 (Stentz) http://ffii.org http://www.mideasttruth.com http://pmw.org.il http://www.dhimmi.com http://www.honestreporting.com http://www.jihadwatch.org Don't hit a man when he's down -- kick him; it's easier. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it
Thanks Gabor, that's what I understood but then why do I get these results? library(zoo) 12*as.numeric(as.yearmon(2006-03-07)-as.yearmon(2006-02-07)) [1] NA Warning messages: 1: NAs introduced by coercion 2: NAs introduced by coercion 12*as.numeric(as.yearmon(2006-03-07)-as.yearmon(2006-02-07)) [1] -12 12*as.numeric(as.yearmon(as.Date(2006-03-07))-as.yearmon(as.Date(2006-02-07))) [1] 1 version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R I am sure I am missing somehting, but what is it?? Thanks Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Fri, 10 Mar 2006 21:01:55 -0500 as.yearmon has a character method so its not necessary to convert it to Date first: print(as.yearmon.character) function (x, ...) as.yearmon(as.Date(x, ...)) On 3/10/06, Francisco J. Zagmutt [EMAIL PROTECTED] wrote: Gabor, please correct me if I am wrong but shouldn't you use as.Date to change the date string to a Date class before you call as.yearmon? i.e. 12* as.numeric(as.yearmon(as.Date(2006-03-07))-as.yearmon(as.Date(2006-02-07))) That returns 1 in Windows XP Regards Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Smith, Phil [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Fri, 10 Mar 2006 13:38:12 -0500 zoo has the yearmon class which will convert a date to a year + 0/12 to 11/12 to represent the month, disregarding the day, so: library(zoo) 12 * as.numeric((as.yearmon(2006-03-07) - as.yearmon(2006-02-06))) # 1 On 3/10/06, Smith, Phil [EMAIL PROTECTED] wrote: Hi R-people: I need a function to compute the number of months between 2 dates, in the same way a mother would do it. For example, if a kid is born on February 6, the number of months between that date and March 7 is exactly 1 month, although it is only 29 days. Thank you! Phil Smith CDC [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it
Right! I updated zoo and the example worked. I should have started by updating the library in the first place...I slept well and I had my cup of coffee this morning so I don't really have any excuse :-) Thanks Gabor! Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Sun, 12 Mar 2006 21:13:50 -0500 Maybe you have an old version of zoo? When I run the first one I get 1. I am using R 2.2.1 under Windows XP and checking the Built: line of library(help = zoo) I am using the verson of zoo version built on Feb 6, 2006: 12*as.numeric(as.yearmon(2006-03-07)-as.yearmon(2006-02-07)) [1] 1 In the second example you are not giving it a date but are subtracting a bunch of numbers and giving that to as.yearmon. On 3/12/06, Francisco J. Zagmutt [EMAIL PROTECTED] wrote: Thanks Gabor, that's what I understood but then why do I get these results? library(zoo) 12*as.numeric(as.yearmon(2006-03-07)-as.yearmon(2006-02-07)) [1] NA Warning messages: 1: NAs introduced by coercion 2: NAs introduced by coercion 12*as.numeric(as.yearmon(2006-03-07)-as.yearmon(2006-02-07)) [1] -12 12*as.numeric(as.yearmon(as.Date(2006-03-07))-as.yearmon(as.Date(2006-02-07))) [1] 1 version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R I am sure I am missing somehting, but what is it?? Thanks Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Fri, 10 Mar 2006 21:01:55 -0500 as.yearmon has a character method so its not necessary to convert it to Date first: print(as.yearmon.character) function (x, ...) as.yearmon(as.Date(x, ...)) On 3/10/06, Francisco J. Zagmutt [EMAIL PROTECTED] wrote: Gabor, please correct me if I am wrong but shouldn't you use as.Date to change the date string to a Date class before you call as.yearmon? i.e. 12* as.numeric(as.yearmon(as.Date(2006-03-07))-as.yearmon(as.Date(2006-02-07))) That returns 1 in Windows XP Regards Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Smith, Phil [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Fri, 10 Mar 2006 13:38:12 -0500 zoo has the yearmon class which will convert a date to a year + 0/12 to 11/12 to represent the month, disregarding the day, so: library(zoo) 12 * as.numeric((as.yearmon(2006-03-07) - as.yearmon(2006-02-06))) # 1 On 3/10/06, Smith, Phil [EMAIL PROTECTED] wrote: Hi R-people: I need a function to compute the number of months between 2 dates, in the same way a mother would do it. For example, if a kid is born on February 6, the number of months between that date and March 7 is exactly 1 month, although it is only 29 days. Thank you! Phil Smith CDC [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it
Gabor, please correct me if I am wrong but shouldn't you use as.Date to change the date string to a Date class before you call as.yearmon? i.e. 12* as.numeric(as.yearmon(as.Date(2006-03-07))-as.yearmon(as.Date(2006-02-07))) That returns 1 in Windows XP Regards Francisco From: Gabor Grothendieck [EMAIL PROTECTED] To: Smith, Phil [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] difference between 2 dates: IN MONTHS the way Motherscompute it Date: Fri, 10 Mar 2006 13:38:12 -0500 zoo has the yearmon class which will convert a date to a year + 0/12 to 11/12 to represent the month, disregarding the day, so: library(zoo) 12 * as.numeric((as.yearmon(2006-03-07) - as.yearmon(2006-02-06))) # 1 On 3/10/06, Smith, Phil [EMAIL PROTECTED] wrote: Hi R-people: I need a function to compute the number of months between 2 dates, in the same way a mother would do it. For example, if a kid is born on February 6, the number of months between that date and March 7 is exactly 1 month, although it is only 29 days. Thank you! Phil Smith CDC [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] trimming a factor
RSiteSearch(trim) or RSiteSearch(trim space) will get you there. Francisco From: Dan Chan [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] trimming a factor Date: Fri, 10 Mar 2006 15:52:03 -0500 Hi, I have the following dataframe. The County Column has many empty spaces at the end. I want to cut out the empty space and put them back into the dataframe. How can this be done? head(DailyCounty) Date County GFCPer GFCEquip Acre nFires Date2 1 2001-01-04 00:00:00 Appling 11 0.20 1 2001-01-04 2 2001-01-05 00:00:00 Appling 22 0.13 1 2001-01-05 3 2001-01-06 00:00:00 Appling 11 3.41 1 2001-01-06 4 2001-01-07 00:00:00 Appling 11 0.18 1 2001-01-07 5 2001-01-10 00:00:00 Appling 11 5.10 1 2001-01-10 6 2001-01-16 00:00:00 Appling 11 0.48 1 2001-01-16 sub(' +$','',levels(DailyCounty$County)) Appling sub(' +$','',DailyCounty$County) [1] 1 Thank you! Daniel Chan Meteorologist Georgia Forestry Commission P O Box 819 Macon, GA 31202 Tel: 478-751-3508 Fax: 478-751-3465 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] shift / rota
a = c(1,2,3) a [1] 1 2 3 rev(a) [1] 3 2 1 PS: a in your example is not a list; i.e class(a) From: Omar Lakkis [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] shift / rota Date: Thu, 9 Mar 2006 15:51:51 -0500 How to do a shift/rotate os a list? if a = c(1,2,3) what is the best way to make a equal c(3,1,2) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] labelling dots in plots
Take a look at ?identify Francisco From: Anne Katrin Heinrichs [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] labelling dots in plots Date: Wed, 15 Feb 2006 18:43:20 +0100 Hello, I would like to label outliers (or all dots) in a plot plot(as.matrix(ValAddInd_byYear), as.matrix(Cons_Elec_Ind_byYear)) ideally by the 30 different row.names, but anything else (x or y values, for example) would already be helpful. I've tried various things with pch, but they didn't work and I can't find anything else. Any hint appreciated! Thanks, Katrin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Tranferring R results to word prosessors
Take a look at the facilities to write HTML output in library(R2HTML). If you write an HTML file, you can then easily copy and paste it into your Word document, or from MS Word you can use the Insert menu. i.e. library(R2HTML) x=ftable(Titanic, row.vars = 1:3) HTML(x,Titanic.html) Then from MS Word use Insert- File and select Titanic.html and see the results. I hope this helps Francisco From: Tom Backer Johnsen [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Tranferring R results to word prosessors Date: Thu, 09 Feb 2006 15:41:09 +0100 I have just started looking at R, and are getting more and more irritated at myself for not having done that before. However, one of the things I have not found in the documentation is some way of preparing output from R for convenient formatting into something like MS Word. An example: If you use summary(lm()) you get nice output. However, if you try to paste that output into the word processor, all the text elements are separated by blanks, and that is not optimal for the creation of a table (in the word processing sense). Is there an option to generate tab-separated output in R ? That would solve the problem. Tom ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ | ++ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] explanation of data sets variables
library(boot) ?city Francisco From: Kuba [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] explanation of data sets variables Date: Wed, 08 Feb 2006 00:35:51 +0100 Dear all, where I can find explanation of data sets variables, for example what does (u,x) variables means in city data? Thank you in advance, Kuba Jennifer Anistron, Mark Rufallo, Shirley Maclaine, Kevin Costner, Kathy Bates w komedii romantycznej Z UST DO UST. W kinach od 10 lutego! http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fzustdoust.htmlsid=651 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] footnote in postscript lattice
After you create your xyplot use library(grid) panel.text(grid.locator(),label=My label) Cheers Francisco PS: How is good ol' David these days? From: Dean Sonneborn [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] footnote in postscript lattice Date: Thu, 26 Jan 2006 15:46:28 -0800 I would like to add a footnote to this graph but do not see a footnote command in the package:lattice documentation. I would like to note the span=.8 as the footnote. postscript(file= C:/Documents and Settings/dsonneborn/My Documents/Slovak/output/pcb_tables/smooth_PCB_lines_four.ps, bg=transparent, onefile=FALSE, pointsize=20,paper=letter, horizontal=TRUE, family=Helvetica,font=Helvetica) xyplot(AWGT ~ lipid_adj_lpcb2_cent | malex*romanix, data=pcb_graph3, auto.key = list(lines = TRUE, points = TRUE), ylab=Birth Weight, xlab=Lipid Adjusted PCB, par.settings = list(superpose.symbol = list(col = colr, pch = plotchar), superpose.line = list(col = colr, pch = plotchar, lty = 1)), type=c(p, smooth), span=.8) dev.off() thanks -- Dean Sonneborn, MS Programmer Analyst Department of Public Health Sciences University of California, Davis (530) 754-9516 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] In which application areas is R used?
If it hasn't been mentioned yet, and if you want to consider this as a separate discipline from the ones mentioned below, we also use it for simulation modeling and risk analysis. Francisco From: John Maindonald [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] In which application areas is R used? Date: Tue, 24 Jan 2006 06:35:00 +1100 (EST) If anyone has a list of application areas where there is extensive use of R, I'd like to hear of it. My current short list is: Bioinformatics Epidemiology Geophysics Agriculture and crop science John Maindonald Mathematical Sciences Institute, Australian National University. [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Loop through factors without changing to numerics
An example would have helped to give you a better answer. You can use characters in the seq argument of the for loop. i.e x=letters[1:4] x [1] a b c d for(i in x) {print(i)} [1] a [1] b [1] c [1] d Is this what you were looking for? Francisco From: Chia, Yen Lin [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Loop through factors without changing to numerics Date: Thu, 19 Jan 2006 16:42:00 -0800 Hi all, If I want to write a for loop to loop through a set of factors, which are not coded in 1,2,3, for e.g in character, possible to write the for loop without changing it to categorical variables? I saw the manual mentions for loop will take a list, but I'm not sure how to create a list here. Any input will be appreciated. Thanks. Yen Lin [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Poisson and negative binomial models with truncation
Did you try RSiteSearch(zero-inflated)? Francisco From: Katrin Bernath [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Poisson and negative binomial models with truncation Date: Mon, 16 Jan 2006 14:15:14 +0100 I am fitting count data models with zero-truncated data. Are there commands in R to adjust the Poisson model (glm(y~x, poisson)) and the negative binomial model (glm.nb(y~x)) for truncated distributions? Thanks in advance! Katrin Bernath - Katrin Bernath Eidg. Forschungsanstalt WSL Abteilung Ökonomie Zürcherstrasse 111 CH-8903 Birmensdorf Telefon +41-44-739 25 46 Fax +41-44-739 25 88 [EMAIL PROTECTED] http://www.wsl.ch/economics __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can I ask for the C code inside an R function using .C?
If you have a slow connection and/or you don't want to download the entire source code you can find the sources for R on this site https://svn.r-project.org/R/trunk/ Francisco From: Liaw, Andy [EMAIL PROTECTED] To: 'Yingfu Xie' [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] Can I ask for the C code inside an R function using .C? Date: Fri, 13 Jan 2006 11:13:51 -0500 Source code for R and all CRAN packages are on CRAN. If you want the C or Fortran code used in R or add-on packages, you need to download the source (the .tar.gz files). You won't see the code if you just install the binary. Andy From: Yingfu Xie Hello, all, It is a general question, but I couldn't find the answer elsewhere. I am using an R function using .C but don't understand one of its behaviors without the C code. I am wondering the so-called 'open source'. It doesn't include the C code together with the R function, does it? So what I want to ask is whether it is justified, possible or polite to ask for the C code behind the R function. Sorry if I miss anything! Thank you as always! Regards, Yingfu ### This message has been scanned by F-Secure Anti-Virus for Mic...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can I ask for the C code inside an R function using .C?
Well, if you have a slow modem connection and you are an average user that doesn't want (or doesn't know how) to compile the source code, you may spend half an hour or more downloading the windows binary. Then you realize you want to see a .C function and you will have to spend another 15 to 20 minutes downloading the source tar.gz...OR you can lookup the specific function in the mentioned website in a fraction of the time. Off course, overall if you check C or Fortran functions all the time you may want to have a local copy of the source. I think is great that users have that flexibility, hence they should be aware of both options. Cheers Francisco , you may prefer just to visit a web site and see the specific function that you want to learn about, rather than waiting another 15 to 20 minutes to download the source tar.gz. From: Liaw, Andy [EMAIL PROTECTED] To: 'Francisco J. Zagmutt' [EMAIL PROTECTED],[EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Can I ask for the C code inside an R function using .C? Date: Fri, 13 Jan 2006 13:26:02 -0500 Just wondering: How do people with slow connections get R? The Windows binary is about 25MB, while the source .tar.gz is only 13.7MB. Andy From: Francisco J. Zagmutt If you have a slow connection and/or you don't want to download the entire source code you can find the sources for R on this site https://svn.r-project.org/R/trunk/ Francisco From: Liaw, Andy [EMAIL PROTECTED] To: 'Yingfu Xie' [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] Can I ask for the C code inside an R function using .C? Date: Fri, 13 Jan 2006 11:13:51 -0500 Source code for R and all CRAN packages are on CRAN. If you want the C or Fortran code used in R or add-on packages, you need to download the source (the .tar.gz files). You won't see the code if you just install the binary. Andy From: Yingfu Xie Hello, all, It is a general question, but I couldn't find the answer elsewhere. I am using an R function using .C but don't understand one of its behaviors without the C code. I am wondering the so-called 'open source'. It doesn't include the C code together with the R function, does it? So what I want to ask is whether it is justified, possible or polite to ask for the C code behind the R function. Sorry if I miss anything! Thank you as always! Regards, Yingfu ### This message has been scanned by F-Secure Anti-Virus for Mic...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to plot two dataset in one fig?
If I understand your question, to superimpose two lines in a same plot, in the first call to plot() you want to set the plot(ylim) argument with a range that will fit both of your lines. Then use lines() to add the second lowess line on the plot. Or matplot() will automate the process for you. Take a look at savePlot() to save your final figure. Francisco From: Wei Qiu [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] How to plot two dataset in one fig? Date: Fri, 18 Nov 2005 16:38:48 -0500 (EST) Hi all, I am new in R tool. I would like to plot two dataset in in fig. Here is what I did for both a and b data sets jpeg(file=a.jpeg) dat-read.table('a', header=F, sep=',') dim(dat) y-dat[,1] y-y[!is.na(y)] plot(y);lines(lowess(y, f=0.05), col = (red), lwd=5) dev.off Two questions: 1. How I can save this lowess smooth data? 2. Once I have the smooth a and b data, How I can put two smooth data sets in one fig even they have different Y ranger value? Any input will be greatly appreciated. Lucy __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] discontinuous y-axis (ordinate with a -/ /-)
axis.break() in the plotrix package will do that. You still have to modify the axis scale. Cheers Francisco From: jobst landgrebe [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] discontinuous y-axis (ordinate with a -/ /-) Date: Thu, 17 Nov 2005 11:40:01 +0100 Dear List, can anyone tell me how to plot a discontinuous y-axis (ordinate with a -/ /- break sign) to fit in data with a wide range without the need of logarthimic transformation? My data are distributed like this: (abscissa: 1:10) 1. vector to plot Min. 1st Qu. MedianMean 3rd Qu.Max. 4.030 5.987 6.865 19.520 16.200 88.000 2. vector to plot Min. 1st Qu. MedianMean 3rd Qu.Max. 0.000 2.112 2.620 2.976 4.303 7.030 I have just this one 88 outlier and cannot log-transform the data (reviewers want plain data). I would be glad to get help. Yours sincerely, Jobst Landgrebe -- Dr. Jobst Landgrebe Universität Göttingen Abt. Biochemie 2 Heinrich-Düker-Weg 12 37073 Göttingen Germany --- tel: 0551/39-5902 oder -2316 fax: 0551/39-5979 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] change some levels of a factor column in data frame according to a condi
Hi Gesman There may be more elegant ways to do this but here is one option: d=data.frame(crit1=gl(2,5), crit2=factor(letters[1:10]), x=rnorm(10)) #Creates data levels(d$crit2)=c(levels(d$crit2),Small)#Adds the level Small to the factor crit2. d2=d[order(d$crit1,d$x),]#Sorts x ascending, by crit1 idx=do.call(rbind,by(d2,d$crit1,head,2))#selects the 2 smallest by crit1 and merges the results by row d2[d2$x %in% idx$x,'crit2']=Small #Changes the desired crit2 to Small Cheers Francisco From: Gesmann, Markus [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] change some levels of a factor column in data frame according to a condition Date: Mon, 14 Nov 2005 20:05:38 + Dear R-users, I am looking for an elegant way to change some levels of a factor column in data frame according to a condition. Lets look at the following data frame: data.frame(crit1=gl(2,5), crit2=factor(letters[1:10]), x=rnorm(10)) crit1 crit2 x 1 1 a -1.06957692 2 1 b 0.24368402 3 1 c -0.24958322 4 1 d -1.37577955 5 1 e -0.01713288 6 2 f -1.25203573 7 2 g -1.94348533 8 2 h -0.16041719 9 2 i -1.91572616 10 2 j -0.20256478 Now I would like to find for each level in crit1 the two smallest values of x and change the levels of crit2 to small, so the result would look like this: crit1 crit2 x 1 1 small -1.06957692 2 1 b 0.24368402 3 1 c -0.24958322 4 1 small -1.37577955 5 1 e -0.01713288 6 2 f -1.25203573 7 2 small -1.94348533 8 2 h -0.16041719 9 2 small -1.91572616 10 2 j -0.20256478 Thank you for advice! Markus Gesmann LNSCNTMCS01*** The information in this E-Mail and in any attachments is CON...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to make automatically each level from data.frame to vector
Looking at the results that you are expecing I think that you just want to have only the record from black colored people. If that't the case, for this dataset the easiest way is to subset the data i.e data(HairEyeColor) x=as.data.frame(HairEyeColor) x2=x[x$Hair==Black,1:3] x2 Hair EyeSex 1 Black Brown Male 5 Black Blue Male 9 Black Hazel Male 13 Black Green Male 17 Black Brown Female 21 Black Blue Female 25 Black Hazel Female 29 Black Green Female Is this what you needed? Francisco From: Muhammad Subianto [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] how to make automatically each level from data.frame to vector Date: Sat, 12 Nov 2005 21:37:27 +0100 Dear R-helpers, Suppose I have dataset like this below: data(HairEyeColor) dfHEC - as.data.frame(as.table(HairEyeColor)) my.dfHEC - data.frame(Hair=rep(dfHEC$Hair,dfHEC$Freq), Eye=rep(dfHEC$Eye,dfHEC$Freq), Sex=rep(dfHEC$Sex,dfHEC$Freq)) my.dfHEC my.dfHEC$Hair my.dfHEC$Eye my.dfHEC$Sex and I know all levels for Hair, Eye and Sex. In my case, I want to expand.grid all attributes but in Hair I only include Black hair: Hair.e - c(Black) Eye.e - c(Brown,Blue,Hazel,Green) Sex.e - c(Male,Female) #I can do like, dfHEC.Black - expand.grid(Hair.e,Eye.e,Sex.e) dfHEC.Black My question is how to make automatically each level from data.frame to vector. I don't want to make definition for each level again (Hair.e, Eye.e, Sex.e). In the others word, how can I make expand.grid (each level) from data.frame automatically if Hair is only (Black). The result I need like, Var1 Var2 Var3 1 Black Brown Male 2 Black Blue Male 3 Black Hazel Male 4 Black Green Male 5 Black Brown Female 6 Black Blue Female 7 Black Hazel Female 8 Black Green Female Thanks in advance. Best, Muhammad Subianto __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to convert strings back to values?
Examples of the code you used would have helped i.e. We don't know how you transposed your matrix. Did you use t()? In any event, as.integer() may be what you need. Francisco From: Illyes Eszter [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] how to convert strings back to values? Date: Wed, 9 Nov 2005 21:55:44 +0100 (CET) Dear All, It's Eszter from Hungary, a total beginner with R. My problem is the following: I have a dataset with binary values as a comma separated textfile. The samples are in the coloumns and the species are in the rows. I have to transpose it for the further PCoA analysis. There is no problem with reading the dataset. When I transpose the dataset, the original values become strings (instead of 0,1,0,0,1 I have 0,1,0,0,1). The distance matrix cannot be counted from the transposed dataset, I have 2 error messages: Warning in vegdist(tdf1, method = jaccard, binary = FALSE, diag = FALSE, : results may be meaningless because input data have negative entries Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric I do not understand the first, since I have only 1 and 0 in the dataset. I guess I have the second because of the strings instead of values in the dataset. Could you please help me solving these problems? I could not find anything about these in the manuals. Thank you, cheers: Eszter p.s. This is a new problem, last week I worked with a similar dataset and I did not get any error message like these. _ Menõ csengõhangok (MP3 is!) és színes képek a mobilodra. Nálunk szinte mindent megtalálsz, KLIKK IDE! www.oplogo.hu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] spatial epidemiology
It depends on what you want to do. There are many spatial packages that can be used for a variety of epidemiological analyses. Take a look at this link http://sal.uiuc.edu/csiss/Rgeo// for a nice summary of the current spatial tools in R. If you are looking for something that will perform scan statistics along the lines of SaTScan, the package DCluster will probably be your best option. Follow this link http://finzi.psych.upenn.edu/R/library/DCluster/html/00Index.html for a list of options available in this package Finally, try RSiteSearch(spatial epidemiology) for some interesting threads on the subject I hope this helps Francisco From: Hongyu Sun [EMAIL PROTECTED] To: rHELP R-help@stat.math.ethz.ch Subject: [R] spatial epidemiology Date: Tue, 08 Nov 2005 13:54:56 -0600 Hi, All: Does R have such packages for spatial epidemiology? Many thanks, __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] someone knows how to title a image.plot() in a layout?
What error are you getting? What did you try? If you want to get meaningful help you need to provide examples of what you did and didn't work. Read the bottom of the message that you just sent and you will notice that we ask you to read the posting guide Cheers Francisco From: Andreas Lehnert [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] someone knows how to title a image.plot() in a layout? Date: Mon, 7 Nov 2005 16:53:18 +0100 (MET) Hello R, I tried to get 4 image.plot() in one layout. But when I try to label it with main or sub there is an error. What am I doing wrong? Please help Thanks, Andy -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] frequency() source code
From: Duncan Murdoch [EMAIL PROTECTED] To: bob mccall [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch r-help@stat.math.ethz.ch Subject: Re: [R] frequency() source code Date: Mon, 07 Nov 2005 18:30:25 -0500 On 11/7/2005 6:11 PM, bob mccall wrote: Greetings: I am looking for the source code for the frequency function. I grepped the following dirs but no luck. R-2.2.0/src/appl/* R-2.2.0/src/main/* R-2.2.0/src/nmath/* R-2.2.0/src/library/stats/* Does anybody know the file name?? Here's how I would look for it: In R, type frequency, and I get: frequency function (x, ...) UseMethod(frequency) environment: namespace:stats So frequency is a generic function. That's all the source there is. Now I'm probably interested in a particular method. Let's say the default one. So I try frequency.default Error: object frequency.default not found Oops, looks like it's hidden in a namespace. Try again: getAnywhere(frequency.default) A single object matching 'frequency.default' was found It was found in the following places registered S3 method for frequency from namespace stats namespace:stats with value function (x, ...) if (!is.null(xtsp - attr(x, tsp))) xtsp[3] else 1 environment: namespace:stats Now that's probably enough information, but if I really wanted to see the source (as opposed to the above deparsed version, which won't have any comments in it), then I'd know to look in src/library/stats/R, since it's in namespace:stats, and it's R code. I'd grep or do another search of the files there and find it in src/library/stats/R/ts.R (and it turns out there aren't any comments after all, but it might be useful to look at the other functions in that file anyway). Now if someone were running from a binary install in Windows, they wouldn't have a full copy of the source directories; they need to download that separately from the binary builds. ...or, they can look at the source code directly at https://svn.r-project.org/R/trunk/src/library/stats/R/ts.R Cheers Francisco Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] newbie graphics question: Two density plots in same frame ?
To plot two Kernel densities you can use matplot: x1-density(rnorm(100)) x2-density(rnorm(100)) matplot(cbind(x1$y,x2$y), type=l) Or if both distributions are really very similar and you don't have to adjust the axes you can simply use plot(x1) lines(x2, col=red) Finally if you want to have two histograms in the same picture (I would not recomend it tough since the distributions are similar so the overlapping will make it very messy) you can use the argument add within hist hist(rnorm(100), col=red) hist(rnorm(100), col=blue, add=T) I hope this helps Francisco From: Alpert, William [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] newbie graphics question: Two density plots in same frame ? Date: Thu, 3 Nov 2005 11:45:21 -0500 I swear I've scoured the help files and several texts before posting what feels like a dumb newbie question. How can I draw two kernel density plots in the same frame ? I have similar variables in two separate data frames, and I would like to show their two histograms/densities in a single picture. Same units, scale, range for both, so I'm simply trying to draw one and then add the other to the picture. Nothin' fancy. Bill Alpert Sr. Editor Barron's 212.416.2742 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] breaks in hist()
Hi Leaf The word even can be interpreted in several ways but I will give it a shot. If you want to specify the breakpoints to represent the aggregation in your data you can use the argument breaks within histogram i.e. x=c(runif(95,0,0.2),runif(5,.21,2)) hist(x, breaks=seq(0,2,.1), freq=F )#It will use breakpoints at 0,0.1,0.2,...2 or you can also suggest a pre-defined number of cells i.e. hist(x, breaks=7, freq=F ) You can also add a density line over the histogram using lines lines(density(x, bw=.1)) Alternativelly, you can use some more basic visualization like a stem-and-leaf plot stem(x) I hope this helps Francisco From: Leaf Sun [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch r-help@stat.math.ethz.ch Subject: [R] breaks in hist() Date: Wed, 2 Nov 2005 10:48:45 -0700 Dear listers, A quick question about breaks in hist(). The histogram is highly screwed to the right, say, the range of the vector is [0, 2], but 95% of the value is squeezed in the interval (0.01, 0.2). My question is : how to set the breaks then make the histogram look even? Thanks in advance, Leaf __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] question about sm.density
Please read the documentation before posting a question. If you read the documentation for sm.density you will see that the argument props will do what you want. i.e. y - cbind(rnorm(50), rnorm(50)) sm.density(y, display = slice, props=95) Regards Francisco From: Cunningham Kerry [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] question about sm.density Date: Thu, 27 Oct 2005 18:47:28 -0700 (PDT) How can I draw a 95% contour in sm.density? For example, y - cbind(rnorm(50), rnorm(50)) sm.density(y, display = slice) will give 25%, 50% and 75% contours automatically, but no reference on other values. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to write and read an array ?
check ?dput and ?dget Cheers Francisco From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] how to write and read an array ? Date: Thu, 27 Oct 2005 19:00:10 +0200 Hi, Apologies if the question is too simple but I didn't find the answer by myself. I'm able to create a 3-dimensionnal array A and to write it with write.table() ... but, after that, I don't find how to read it with read.table() getting the right 3 dimensions. I tried to use as.array(), to force the dim, etc but it didn't work. (It's probably obvious ... ?) Thanks for your info or pointer. Vincent __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Can anyone please tell me how to strip the white spaces from acharacter
I addition to all the many good options presented you can also use trimWhiteSpace{limma} which is just a higher level call to sub() x=scan(clipboard, what=character) Read 6 items x [1] AIR ABCB ABXA ACMR ADCT ADEX trimWhiteSpace(x) [1] AIR ABCB ABXA ACMR ADCT ADEX Cheers Francisco From: roger bos [EMAIL PROTECTED] To: ([EMAIL PROTECTED]) R-help@stat.math.ethz.ch Subject: [R] Can anyone please tell me how to strip the white spaces from acharacter vector? Date: Tue, 25 Oct 2005 08:51:48 -0400 for example: a$tic[1:10] [1] AIR ABCB ABXA ACMR ADCT ADEX [7] ABM AFCE AG ATG Can anyone please tell me how to strip the white spaces from a$tic? Thanks, Roger [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] goodfit par estimates
Are you trying to obtain the MLE parameter estimates? If so, in your example you just need to use fit$par. Cheers Francisco From: Elizabeth Lawson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] goodfit par estimates Date: Thu, 20 Oct 2005 10:37:19 -0700 (PDT) Hey, Does anyone know if there is a way to get back from goodfit what it estimated the parameters to be? I used the code fit-goodfit(round(data$PLX_NRX),type=nbinomial and got a pretty good fit. I could not however duplicate this good fit with any parameter estimates that I had. Any ideas??? Thanks, Elizabeth Lawson - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] histogram - one bin for all values larger than a certain value
x=runif(100,0,40) hist(x, breaks=c(0,1,2,3,4,5,6,7,8,9,10,40)) Is this what you had in mind? Francisco From: Florian Defregger [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] histogram - one bin for all values larger than a certain value Date: Mon, 26 Sep 2005 15:36:21 +0200 Dear all, I wonder if I can put together a histogram where one bin contains all the values that are larger than a certain specified value. Example: I have values ranging from 0 to 40 and I want 10 bins from 0 to 10, i.e. for the intervals [0,1), [1,2) , ..., [9,10). And then I want one last bin which contains all the values larger than 10, i.e. for the interval [10, 40). Thanks, Florian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Identical data frames
you just said t. identical() will compare *strict* equality i.e. d1=data.frame(x=,y=1:30) d2=d1 identical(d1,d2) [1] TRUE d1=data.frame(x=letters,y=1:26) d2=data.frame(x=c(aa,letters[2:26]), y=1:26) identical(d1,d2) [1] FALSE #because The first row of d2$x was aa and in d1 was a Cheers Francisco From: Marc Bernard [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Identical data frames Date: Wed, 21 Sep 2005 16:07:13 +0200 (CEST) Dear All, Is there any R function to test if two data frames, say df1 and df2, having the same row names and the same column names are identiques? Thanks in advance, Bernard - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Add function to histogram?
To be more precise, when using hist(prob=T) the y axis shows the densities. If you want relative frequencies (proportions) you can use the histogram(x, type=) function in the package lattice or write your own function. Cheers Francisco From: Vincent Goulet [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: Re: [R] Add function to histogram? Date: Wed, 21 Sep 2005 17:10:55 -0400 Le 20 Septembre 2005 09:53, Robert Lundqvist a écrit : Is there any neat way to add a curve (frequency function or the like) to a histogram or other plots? I haven't found one yet... The one key thing here is not to forget prob=TRUE in the call to hist(), to ensure that the y-axis is scaled in proportions, not in frequencies. -- Vincent Goulet, Professeur agrégé École d'actuariat Université Laval, Québec [EMAIL PROTECTED] http://vgoulet.act.ulaval.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] accessing source code in R packages
or getAnywhere() From: ronggui.wong [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch r-help@stat.math.ethz.ch Subject: Re: [R] accessing source code in R packages Date: Thu, 22 Sep 2005 10:03:45 +0800 R is open source. You can download the source code from CRAN. If you mean at the R prompt, usually you see the code for a function by typing the name of the function at the R prompt, without parentheses. `Usually' because some methods are delibrately `hidden' from users, and should only be accessed through their generics. There are still ways to get around that. sometimes,the getS3method is helpfull. library(MASS) princomp.default Error: object princomp.default not found getS3method(princomp,default) function (x, cor = FALSE, scores = TRUE, covmat = NULL, subset = rep(TRUE, nrow(as.matrix(x))), ...) { snip However, the code you get at the R prompt is not the _source_, as it does not contain any original comments. You need to go to the source I refer to above. Andy From: [EMAIL PROTECTED] Hi, I am new the R world and would like to know how can I access source codes of standard functions in R? Thanks, Ritesh. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html = = = = = = = = = = = = = = = = = = = = Ö Àñ£¡ ronggui.wong [EMAIL PROTECTED] 2005-09-22 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help with estimating parameters with nls
RSiteSearch(Dagum) Francisco From: Uri Iskin [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] help with estimating parameters with nls Date: Tue, 20 Sep 2005 15:44:07 -0300 Dear helpeRs, I have a vector containing values of incomes and I would like to estimate the three parameters of a Dagum distribution. Dagum himself recommends to use nonlinear least-squares method. I have read nls, optim (and the posting guide!) and still have not succeded. sipcf is my sorted vector of incomes with 3065 obs. fda is a vector of the empirical cumulative distribution probabilities: fda - vector(length=length(sipcf)) for (I in 1:length(sipcf)){ fda[i] - sum(sipcf = sipcf[i])/length(sipcf) } fdae is the cdf: fdae - function(x){ fda[sum(sipcf=x)] } dagfda is the cdf of Dagum: dagfda - function(x,a,b,p){ (1+(x^(-a)*b^a))^(-p) } start values I am using: a=1.9 b=0.34 p=1.3 I am trying to get the parameters estimates with nls and optim, but all I get are errors. Could you help me showing how to get them? Thank you in advance! Uri Iskin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Teaching R - In front of the computer?
Adding to Uwe's comment, in my experience is also useful to use a text editor that connects to R (i.e. in Windows you have Tinn-R, jgr, SciViews) so people can see the function arguments as they type. People are accustomed to this feature from Excel so it helps them to fell more comfortable with the syntax. And yes, some students used to the mainstream point-and-click software can be REALLY slow so you may want to plan for that! Good luck! Francisco From: Uwe Ligges [EMAIL PROTECTED] To: Rau, Roland [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Teaching R - In front of the computer? Date: Mon, 19 Sep 2005 16:14:57 +0200 Rau, Roland wrote: Dear R-Users, given you have been teaching R to students (grad level, mainly social science background, no previous programming experience, 80% know SPSS), what are your experiences concerning the style of teaching? Do you prefer to stand in front of the class like in normal lectures and you show them slides? Or do you you explain some concept (for example things like mydata[order(var1, var2),]) and show it directly on the computer via beamer/projector and also the students have to enter it on the computers in front of them. Any experiences you can share are highly appreciated. I like to teach using a projector and people sitting in front of other machines beeing able to try out some of the nonsense I am telling. Of course, they need more exercises than just the few minutes in between my sentences. I am always noth using slides and showing the examples in R directly. For all other stuff, it is the same as with other courses and lectures. If this is a one-week course, I'd like to propose 1.5 hours course + 1.5 hours exercise in the morning and the same again in the afternoon. If this is a whole-term course, you may be able to let people do homework, but always talk about their results and show them hoe to do it in a good fashion. Unfortunately, for courses with lots of poeple (say 90, for the first-years' R course I am teaching) it is impossible that people are sitting in front of a computer for some reasons: not enough machines, no big rooms, and too much noise caused by both machines and people. The really important fact from my point of view: Give people many *exercises* and the *time* to work on these exercises. Expect that people without any programming experience will be much slower than you imagine in your worst nightmares. ;-) Uwe Ligges Thanks, Roland + This mail has been sent through the MPI for Demographic Rese...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Variable descriptions of a built-in dataset
Or the longer version help(Boston) Cheers Francisco From: Gabor Grothendieck [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Jun Ding [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Variable descriptions of a built-in dataset Date: Sun, 18 Sep 2005 01:33:15 -0400 ?Boston On 9/17/05, Jun Ding [EMAIL PROTECTED] wrote: Hi, everyone, Is there a way to get the detailed variable descriptions of a built-in dataset? By using attributes(Boston) I can get the names of each variables of a builtin dataset 'Boston'(in package MASS), but I don't know what each variable means. Can some body tell me how I can get more detailed information about each variable? Thank you! Jun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Scan and Lists
Hi Michael An example of your list would have helped. Anyhow, why do you want to read a list? If you created a list object in R and want to save it and then read it back in other session or in some other time a good option is to write an ASCII representation of the object using dput and then recreate it using dget i.e. mylist= list(x=cars[,1], y=cars[,2]) dput(mylist,mylist) mylistback=dget(mylist) $x [1] 4 4 7 7 8 9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14 14 15 15 [26] 15 16 16 17 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24 24 24 25 $y [1] 2 10 4 22 16 10 18 26 34 17 28 14 20 24 28 26 34 34 46 [20] 26 36 60 80 20 26 54 32 40 32 40 50 42 56 76 84 36 46 68 [39] 32 48 52 56 64 66 54 70 92 93 120 85 If you want to read some other type of data take a look at the higher lever functions listed under ?read.table and the functions at library(help=foreign) I hope this helps Francisco PS: Nasty weather in Fort Collins today! From: Michael Lefsky [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Scan and Lists Date: Wed, 14 Sep 2005 15:06:17 -0600 This may be a newbie question - although I did search for this error message in the archives and via google and didn't see this error: The help page for scan indicates that among the types of data capable of being read are: The supported types are 'logical', 'integer', 'numeric', 'complex', 'character', 'raw' and 'list': 'list' values should have elements which are one of the first six types listed or 'NULL'. I have tried to use a list within a what list : f - scan(file=c:/test/testout.csv,what=list(hi=0.0,bye=,wave=list(1:1000)),sep=,,skip=1) and the following error is returned: c:/test/testout.csv, what = list(hi = 0, bye = , : unimplemented type 'list' in 'extractItem' So, is my syntax confusing R, or is the documentation wrong, or is it some other, third, option? Thanks M -- Michael Lefsky College of Natural Resources Colorado State University - Out of the crooked timber of humanity, no straight thing was ever made- Immanuel Kant __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] fit data with gammadistribution
Somebody already did the job for you. Try fitdistr{MASS} i.e. x=scan(clipboard)#Read your data from clipboard sh=(mean(x))^2/var(x) sc=var(x)/mean(x) fitdistr(x,gamma, list(shape=sh, scale=sc)) Now you probably know that you have to be carfeul when estimating distribution parameters from such a small number of observations. PS: this is a very popular question so in the future before you post a question try RSiteSearch() i.e. RSiteSearch(fit gamma) gave me 273 hits Cheers Francisco From: Nadja Riedwyl [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] fit data with gammadistribution Date: Mon, 12 Sep 2005 12:58:00 +0200 hello my data is data2:2743 4678 21427 6194 10286 1505 12811 2161 6853 2625 14542 694 11491 14924 28640 17097 2136 5308 3477 91301 11488 3860 64114 14334 by calculating shape-(mean(data2))^2/var(data2) scale-var(data2)/mean(data2) i get the idea what the parameters of the gammadistribution would be. but if i try using the method mle() i get stock and i don't know, how to make it work. can anybody help me? thank you very much, indeed. Nadja I tried so fare ll-function(lambda,alfa) {n-24 x-data2 -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x) est-mle(minuslogl=ll,start=list(lambda=29827.51,alfa=0.4954725)) summary(est) NaN's are produced with optim, i just don't know how to avoid this! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R API call from delphi
Follow this thread http://finzi.psych.upenn.edu/R/Rhelp02a/archive/50598.html Cheers Francisco From: Laurent TESSIER [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] R API call from delphi Date: Thu, 8 Sep 2005 17:47:49 +0200 (CEST) Hello, Has anyone tried to call R API from Delphi under windows ? How was it done if it was ? Or has anyone any idea about how it could be done ? Thanks for your answers Laurent Tessier [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hotelling Test
Check some of the threads at RSiteSearch(Hotelling) Cheers Francisco From: Bill Donner [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject: [R] Hotelling Test Date: Wed, 7 Sep 2005 06:48:06 -0700 (PDT) Hello R-users, I've been looking for a function performing one and two sample Hotelling test for testing equality of mean vectors. Has anyone implemented such a function in R? thanks a lot, Bill == Bill Donner Statistician __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Interpolating / smoothing missing time series data
I don't have much experience in the subject but it seems that library(akima) should be useful for your problem. Try library(help=akima) to see a list of the functions available in the library. I hope this helps Francisco From: Gabor Grothendieck [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: David James [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Interpolating / smoothing missing time series data Date: Wed, 7 Sep 2005 22:19:17 -0400 On 9/7/05, David James [EMAIL PROTECTED] wrote: The purpose of this email is to ask for pre-built procedures or techniques for smoothing and interpolating missing time series data. I've made some headway on my problem in my spare time. I started with an irregular time series with lots of missing data. It even had duplicated data. Thanks to zoo, I've cleaned that up -- now I have a regular time series with lots of NA's. I want to use a regression model (i.e. ARIMA) to ill in the gaps. I am certainly open to other suggestions, especially if they are easy to implement. My specific questions: 1. Presumably, once I get ARIMA working, I still have the problem of predicting the past missing values -- I've only seen examples of predicting into the future. 2. When predicting the past (backcasting), I also want to take reasonable steps to make the data look smooth. I guess I'm looking for a really good example in a textbook or white paper (or just an R guru with some experience in this area) that can offer some guidance. Venables and Ripley was a great start (Modern Applied Statistics with S). I really had hoped that the Seasonal ARIMA Models section on page 405 would help. It was helpful, but only to a point. I have a hunch (based on me crashing arima numerous times -- maybe I'm just new to this and doing things that are unreasonable?) that using hourly data just does not mesh well with the seasonal arima code? Not sure if this answers your question but if you are looking for something simple then na.approx in the zoo package will linearly interpolate for you. z - zoo(c(1,2,NA,4,5)) na.approx(z) 1 2 3 4 5 1 2 3 4 5 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Creating very small plots (2.5 cm wide) in Sweave
Others may propose more elegant solutions but, in windows one quick an dirty option would be to change the argument 'pin' and 'fin' within par to get an image of exactly 1 inch (2.54 cm) i.e. y - c(40, 46, 39, 44, 23, 36, 70, 39, 30, 73, 53, 74) x - c(6, 4, 3, 6, 1, 5, 6, 2, 1, 8, 4, 6) par(pin=c(1,1), fin=c(1,1)) plot(x, y, xlab=, ylab=) abline(h=mean(y), col=red) #Save the plot in bmp format savePlot(myplot, bmp) and then manually crop the picture using your favorite picture package or even within a word processor. I hope this helps Francisco From: Andrew Robinson [EMAIL PROTECTED] To: R-Help Discussion r-help@stat.math.ethz.ch Subject: [R] Creating very small plots (2.5 cm wide) in Sweave Date: Thu, 8 Sep 2005 13:40:17 +1000 Hi everyone, I was wondering if anyone has any code they could share for creating thumbnail plots in Sweave. For example, I'd like a plot like the following: y - c(40, 46, 39, 44, 23, 36, 70, 39, 30, 73, 53, 74) x - c(6, 4, 3, 6, 1, 5, 6, 2, 1, 8, 4, 6) opar - par(mar=c(3,3,0,0)) plot(x, y, xlab=, ylab=) abline(h=mean(y), col=red) par(opar) to come out about 2.5 cm wide. Thanks for any assistance, Andrew -- Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and StatisticsFax: +61-3-8344-4599 University of Melbourne, VIC 3010 Australia Email: [EMAIL PROTECTED]Website: http://www.ms.unimelb.edu.au __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Testing if all elements are equal in a vector/matrix
Hi Doran The documentation for isTRUE reads 'isTRUE(x)' is an abbreviation of 'identical(TRUE,x)' so actually Vincent's solutions is cleaner than using identical :) Cheers Francisco From: Doran, Harold [EMAIL PROTECTED] To: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] Testing if all elements are equal in a vector/matrix Date: Mon, 29 Aug 2005 15:49:20 -0400 See ?identical -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vincent Goulet Sent: Monday, August 29, 2005 3:35 PM To: r-help@stat.math.ethz.ch Subject: [R] Testing if all elements are equal in a vector/matrix Is there a canonical way to check if all elements of a vector or matrix are the same? Solutions below work, but look hackish to me. x - rep(1, 10) all(x == x[1]) # == operator does not provide for small differences [1] TRUE isTRUE(all.equal(x, rep(x[1], length(x # ugly [1] TRUE Best, Vincent -- Vincent Goulet, Associate Professor École d'actuariat Université Laval, Québec [EMAIL PROTECTED] http://vgoulet.act.ulaval.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multiple plots in png output
I don't run R on Linux but my first suggestion would be to download the latest version of R and if you still observe the problem post a new thread with specific code examples. Cheers Francisco From: Karen L. Updegraff [EMAIL PROTECTED] Reply-To: Karen L. Updegraff [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] multiple plots in png output Date: Fri, 19 Aug 2005 13:25:13 -0500 (CDT) I am using R version 1.9.1 under Linux. In the past I have had no problem saving a multi-plot page to a postscript or png device. However, the last time I did this may have been under a previous version of R. Presently nothing I do seems to succeed in saving multi-plots, defined (for example) with mfrow=c(2,2) ... plot(..) .. plot(..) The same problem has occurred using hist() and plot(). These are not plots that lend themselves to a lattice format, so that is not really an option. The multi-plot page displays fine with the default (x11) graphics device but in the saved file only the last plot shows up. The only suggestion of a problem that I found in the R documentation was a warning that png and similar devices would tend to save only the last page of a multi-page plot, unles you used something like %d to indicate the file sequence. There are no details on how or where that option might be used. R documentation frequently seems to go out of its way to be opaque. Is this a bug that was introduced with v 1.9.1, and if so has it been fixed in more recent releases? Alternatively, is there a workaround which is not documented? Suggestions appreciated. Karen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] kernel smoothing of weighted data
You can also specify weights in sm.density() in the package sm. Cheers Francisco From: Prof Brian Ripley [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] kernel smoothing of weighted data Date: Tue, 16 Aug 2005 18:13:43 +0100 (BST) density() in the R-devel version of R allows weights. locfit() in the package of the same name also appears to be documented to. On Tue, 16 Aug 2005 [EMAIL PROTECTED] wrote: I want to use kde() or a similar function for kernel smoothing but I want to specify the weight of each of my data points. I do not want to specify the bandwidth on a point by point basis. The only kde() I found is from the recent package ks, and is for multivariate data -- if you want that, you did not say so and I've not looked for an answer there. This seems such a simple and obvious thing to want to do I am suspicious that there is not an obvious way to do it. The only discussion I have found is about negative weights(!) and says nothing about implementation. Can anyone suggest a package I have missed or suggest the best starting point for writing my own solution. The reason for wanting this is that I have a number of samples each of ~1000 data points from the same distribution but the samples are of slightly differing statistical weight and eventually each point in each sample may have its own statistical weight. I have searched the list but I am not subscribed to it so please make me an addressee of any reply. -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Archive Search on R Help Mailing List Help
Try accesing http://search.r-project.org/ directly or within R using RSiteSearch(utils). It is not the same site that you are asking for but you will find very useful information there (including a link to Robert King's archives). Francisco From: White, Charles E WRAIR-Wash DC [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Archive Search on R Help Mailing List Help Date: Sat, 6 Aug 2005 11:20:53 -0400 The link to the search engine at the University of Newcastle, Australia doesn't seem to be working. Is there someone who can either update the link or indicate when the service may be back? Thanks. Chuck __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convert numeric to factor
Why are you adding as.integer before the factor statement? You are forcing the variable to be an integer even tough you are passing factor within the statement. Try Lease$ID -factor(Lease$EarlyTermination) Cheers Francisco From: Haibo Huang [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [R] Convert numeric to factor Date: Wed, 3 Aug 2005 13:52:13 -0700 (PDT) Hi, I tried to do a logistic regression with polr(MASS). I thought I already converted the response to factor, but obvious I was wrong. Could anyone tell me what I did wrong and how to correct it? Thank you very much! Lease=read.csv(LeaseDummy.csv, header=TRUE) Lease$ID - as.integer(factor(Lease$EarlyTermination)) RegA=polr(ID~1+MSA+SIC.Code+TenantOption+LLOption+TOExercised, + data=Lease, method=c(logistic)) Error in polr(ID ~ 1 + MSA + SIC.Code + TenantOption + LLOption + TOExercised, : response must be a factor summary(RegA) Best, Ed. --- Jean Eid [EMAIL PROTECTED] wrote: if labda is the elements of the vector and you know what kexp is , you can use apply apply(your_vector, 1, function(x) 1- exp^(kexp^(-x))) HTH Jean On Wed, 3 Aug 2005, Rangesh Kunnavakkam wrote: I have a large vector of around 12597 elements and I wish to calculate p-value for each element using a formula of something like: p-value= 1- exp^(kexp^(-labda)) I was wondering someone could give some ideas how to implement for each element. thankyou very much Rangesh.K __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HOW to Create Movies with R with repeated plot()?
What platform are you working on? On windows you can also create an animated gif file using ImageMagik (http://www.imagemagick.org/) from the cmd or you can use the more user friendly UnFREEz downloadable at http://www.whitsoftdev.com/unfreez/ ot Microsoft GIF animator(search for it on google). All the software mentioned are free and I have used them in the past to animate R output. Take a look at RSiteSearch(movie) for other interesting threads. Cheers Francisco From: Martyn Plummer [EMAIL PROTECTED] To: Jan Verbesselt [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] HOW to Create Movies with R with repeated plot()? Date: Wed, 27 Jul 2005 15:23:54 +0200 On Wed, 2005-07-27 at 12:11 +0200, Jan Verbesselt wrote: Dear R-helpers, Is it possible to create a type of 'movie' in R based on the output of several figures (e.g., jpegs) via the plot() function. I obtained dynamic results with the plotting function and would like to save these as a movie (e.g., avi or other formats)? You can use ImageMagick tools to convert a set of bitmap files into an animated GIF. For example, in R, this creates 101 separate png files: x - seq(-1,1,length=101) y - x^2 png() for (i in 1:length(y)) { plot(x[1:i], y[1:i], xlim=c(-1,1), ylim=c(0,1), type=l) } dev.off() Then, on the command line (on Linux) this joins them together convert -delay 10 Rplot*.png Rplot.gif animate Rplot.gif You can also create MNG format, but this is less widely supported. Martyn --- This message and its attachments are strictly confidential. ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] poisson fit for histogram
Ups! Mr. Ripley is right. I ignored the OS in the posting. My appologies to Tom Isenbarger for the misleading answer. Regards Francisco From: Prof Brian Ripley [EMAIL PROTECTED] To: Francisco J. Zagmutt [EMAIL PROTECTED] CC: [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: Re: [R] poisson fit for histogram Date: Sat, 23 Jul 2005 08:29:28 +0100 (BST) What does fit.dist do that fitdistr (MASS) does not in this context? (It plots, but that is very easy to do in base R. However, to see if a Poisson fits you need a test of goodness-of-fit.) BTW, `decompress and store the files in your library folder' is on no OS (you did not mention one but Thomas did) the way to install a package. Even on Windows (where it might just work) there are simpler and better ways to do it, like using a menu. Note that Lindsey does not provide pre-compiled packages for MacOS X, the platform Thomas is using (and as they use Fortran, people have reported that they are tricky to install on MacOS X), and your recipe is `seriously' misleading there. On Fri, 22 Jul 2005, Francisco J. Zagmutt wrote: I would first reccomend you to update your version of R. Then download the libraries rmutil and gnlm from Jim Lindsey at http://www.luc.ac.be/~jlindsey/rcode.html decompress and store the files in your library folder. Sorry but you will have to donwload a package unless you seriously want to re-invent the wheel. Finally try library(gnlm) ?fit.dist() Cheers Francisco From: Thomas Isenbarger [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] poisson fit for histogram Date: Wed, 20 Jul 2005 10:40:51 -0500 I haven't been an R lister for a bit, but I hope to enlist someone's help here. I think this is a simple question, so I hope the answer is not much trouble. Can you please respond directly to this email address in addition to the list (if responding to the list is warranted)? I have a histogram and I want to see if the data fit a Poisson distribution. How do I do this? It is preferable if it could be done without having to install any or many packages. I use R Version 1.12 (1622) on OS X Thank-you very much, Tom Isenbarger -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html