Re: [R] R Error, very odd....
Katie2009 wrote: I'm trying to analyse some excel data in R. The problem is that when i input the data with the first column as absolute values, everything works fine, can analyse as normal. When I leave the first column unchanged to import negative numbers as well I get: Error in storage.mode(y) - double : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored You did not tell us anything how you got the data from Excel, so I have to guess. Try to re-arrange your Excel row so that the first (3 ? check the docs; which docs? your unknown function's) lines contain non-missing data. Dieter -- View this message in context: http://www.nabble.com/R-Error%2C-very-odd-tp23477195p23478090.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R Error, very odd....
I'm trying to analyse some excel data in R. The problem is that when i input the data with the first column as absolute values, everything works fine, can analyse as normal. When I leave the first column unchanged to import negative numbers as well I get: Error in storage.mode(y) - double : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored What can I do to get around this? I would like to analyse the data in R that does include the negative numbers. Thanks!! -- View this message in context: http://www.nabble.com/R-Error%2C-very-odd-tp23477195p23477195.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] working with groups of labels?
Good Morning, I have a graph with groups of variables. I have include the group names as variables so that I can have them positioned correctly. Unfortunately this means that the group names have to follow all of the same rules as the variables within the groups. I would rather have those group names left justified and bolded. I know that I can do this in an mtext() function using font=2 and adj=0, but I can never get the labels lined up exactly right. Is there a simpler way of getting one group of labels right justified and another group of labels left justified and still have them all automatically positioned correctly? Thanks, Phillip __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Error, very odd....
Katie2009 wrote: hi dieter, the method i'm using is in excel, copying the data, then in r w-read.delim(clipboard) w-as.data.frame(w) i've been doing a bit more fiddling, and have identified the 'class' of the column that i'm having trouble with, is classified as 'factor' whilst the rest are numeric. read.delim internally uses the same function as read.table, so you might consult that documentation: The number of data columns is determined by looking at the first five lines of input (or the whole file if it has less than five lines), or from the length of col.names if it is specified and is longer. This could conceivably be wrong if fill or blank.lines.skip are true, so specify col.names if necessary. So if the first lines are unusual, many things can happen. However, reading from the clipboard is not a very stable way to get Excel data; I would suggest to use library(RODBC) instead, or one of the other Excel readers. With RODBC, use named ranges, not worksheet names for a stable import. Dieter -- View this message in context: http://www.nabble.com/R-Error%2C-very-odd-tp23477195p23478576.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R package for estimating markov transition matrix from observations + confidence?
At 19:18 09/05/2009, U.H wrote: Dear R gurus, I have data for which I want to estimate the markov transition matrix that generated the sequence, and preferably obtain some measure of confidence for that estimation. RSiteSearch(markov, restrict = function) shows that there are numerous packages on CRAN with Markov in their name or documentation. Does any of them help? e.g., for a series such as 1 3 4 1 2 3 1 2 1 3 4 3 2 4 2 1 4 1 2 4 1 2 4 1 2 1 2 1 3 1 I would want to get an estimate of the matrix that generated it [[originally: [,1] [,2] [,3] [,4] [1,] 0.00 0.33 0.33 0.33 [2,] 0.33 0.00 0.33 0.33 [3,] 0.33 0.33 0.00 0.33 [4,] 0.33 0.33 0.33 0.00 ]] and the confidence in that estimation. I know that generating the cross--tab matrix is trivial, but if there is a package that does that and provides a likelihood as well, I'd appreciate knowing about it. Best, Uri Michael Dewey http://www.aghmed.fsnet.co.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Error, very odd....
hi dieter, the method i'm using is in excel, copying the data, then in r w-read.delim(clipboard) w-as.data.frame(w) i've been doing a bit more fiddling, and have identified the 'class' of the column that i'm having trouble with, is classified as 'factor' whilst the rest are numeric. if i just change that column to as.numeric of the column, this has appeared to have solved the problem. Has this changed that data at all though? Thanks. Dieter Menne wrote: Katie2009 wrote: I'm trying to analyse some excel data in R. The problem is that when i input the data with the first column as absolute values, everything works fine, can analyse as normal. When I leave the first column unchanged to import negative numbers as well I get: Error in storage.mode(y) - double : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored You did not tell us anything how you got the data from Excel, so I have to guess. Try to re-arrange your Excel row so that the first (3 ? check the docs; which docs? your unknown function's) lines contain non-missing data. Dieter -- View this message in context: http://www.nabble.com/R-Error%2C-very-odd-tp23477195p23478471.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with groups of labels?
I have a graph with groups of variables. I have include the group names as variables so that I can have them positioned correctly. Unfortunately this means that the group names have to follow all of the same rules as the variables within the groups. I would rather have those group names left justified and bolded. I know that I can do this in an mtext() function using font=2 and adj=0, but I can never get the labels lined up exactly right. Is there a simpler way of getting one group of labels right justified and another group of labels left justified and still have them all automatically positioned correctly? mtext accepts vector inputs, so you can specify different justifications for different labels, e.g. plot(1:10) mtext(c(foo, bar, baz), adj=c(0, 0.5, 1), side=1) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Unable to install R package
Hi all, I am unable to install R package on RHEL version 5.1. While running * ./configure* command following is printed on to the screen and no * makefile* is created. Can anyone help me out ??? Thanks in advance. ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu loading site script './config.site' loading build specific script './config.site' checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... missing checking for working autoconf... missing checking for working automake... missing checking for working autoheader... missing checking for gawk... gawk checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether ln -s works... yes checking for bison... no checking for byacc... no checking for ar... ar checking for a BSD-compatible install... /usr/bin/install -c checking for sed... /bin/sed checking for less... /usr/bin/less checking for perl... /usr/bin/perl checking whether perl version is at least 5.8.0... yes checking for dvips... /usr/bin/dvips checking for tex... /usr/bin/tex checking for latex... /usr/bin/latex checking for makeindex... /usr/bin/makeindex checking for pdftex... /usr/bin/pdftex checking for pdflatex... /usr/bin/pdflatex checking for makeinfo... /usr/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for texi2dvi... no checking for unzip... /usr/bin/unzip checking for zip... /usr/bin/zip checking for gzip... /usr/bin/gzip checking for firefox... /usr/bin/firefox using default browser ... /usr/bin/firefox checking for acroread... no checking for acroread4... no checking for evince... /usr/bin/evince checking for pkg-config... /usr/bin/pkg-config checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for gfortran... no checking for f95... no checking for fort... no checking for xlf95... no checking for ifort... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for gfortran... no checking for ftn... no checking for g95... no checking for f90... no checking for xlf90... no checking for pgf90... no checking for pghpf... no checking for epcf90... no checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl.exe... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking whether we are using the GNU C++ compiler... no checking whether g++ accepts -g... no checking how to run the C++ preprocessor... /lib/cpp configure: error: C++ preprocessor /lib/cpp fails sanity check See `config.log' for more details. Regards, Anupam [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ade4 and inertia of axis 2
Dear John, In RLQ (similarly to other methods in ade4), inertia are given by eigenvalues. Thus, the percentage of inertia are obtained simply by: rlq1$eig/sum(rlq1$eig)*100 For more details on outputs or RLQ, you can have a look at http://listes.univ-lyon1.fr/wws/arc/adelist/2009-03/msg1.html Lastly, if you have questions about ade4, please subscribe and send an email to adelist (http://listes.univ-lyon1.fr/wws/info/adelist) Cheers. John Poulsen wrote: Hello, Could someone please tell me how to find the estimate of inertia for the second axis of an RLQ analysis using ade4? Using the example from the ade4 package, I *suspect* that the inertia for the 2nd axis of the R table would be 4.139332 (see below results summary from rlq1). However, the row is labeled 12 not 2 which suggests this is not correct. In addition, this would mean that axis 2 of the RLQ would explain more than 100% of the inertia of the separate ordination for dudimil ((100*4.139)/dudimil$eig[2]=176%) which I believe is not supposed to occur. Could anyone set me straight by either letting me know how to get the inertia for axis 2 or that my thinking is perhaps wrong? Thanks, John data(aviurba) coa1 - dudi.coa(aviurba$fau, scannf = FALSE, nf = 2) dudimil - dudi.hillsmith(aviurba$mil, scannf = FALSE, nf = 2, row.w = coa1$lw) duditrait - dudi.hillsmith(aviurba$traits, scannf = FALSE, nf = 2, row.w = coa1$cw) rlq1 - rlq(dudimil, coa1, duditrait, scannf = FALSE, nf = 2) plot(rlq1) summary(rlq1) randtest.rlq(rlq1) summary(rlq1) Eigenvalues decomposition: eig covar sdR sdQ corr 1 0.4782826 0.6915798 1.558312 1.158357 0.3831293 2 0.1418508 0.3766308 1.308050 1.219367 0.2361331 Inertia coinertia R: inertia max ratio 1 2.428337 2.996911 0.8102800 12 4.139332 5.345110 0.7744148 Inertia coinertia Q: inertia max ratio 1 1.341791 2.603139 0.5154512 12 2.828648 4.202981 0.6730098 Correlation L: corr max ratio 1 0.3831293 0.6435487 0.5953384 2 0.2361331 0.5220054 0.4523576 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Stéphane DRAY (d...@biomserv.univ-lyon1.fr ) Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I 43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France Tel: 33 4 72 43 27 57 Fax: 33 4 72 43 13 88 http://pbil.univ-lyon1.fr/members/dray/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 3d Scatterplot using rgl
Hi, I am trying to plot a 3d scatter plot using the rgl package but am having trouble. I have a matrix containing x, y and z co-ordinates and a fourth element related to a count variable. I would like to plot the points using plot3d with the sizes of the points related to the fourth element in the matrix. Is this possible with plot3d or do I need to use something else? I include a small example of what I am trying to do swadt A B Crun1 run2 run3 run4 run5 run6 93 96 51 0.1 NA 0.1 NA NA NA 93 97 50 0.3 NA NA 0.1 NA NA 93 98 49 0.1 NA NA NA NA NA 94 95 51 NA NA NA NA NA 0.1 94 100 46 0.1 NA NA NA NA NA 94 96 50 2.1 0.1 1.0 0.7 0.8 0.4 94 97 49 3.2 0.9 1.9 1.9 1.6 1.6 94 98 48 0.9 NA 0.3 0.4 0.5 0.1 95 94 51 NA NA NA 0.1 0.1 NA 95 95 50 3.4 0.7 2.8 2.4 2.9 2.3 95 96 49 12.5 13.4 13.6 15.0 15.3 17.1 95 97 48 10.2 10.8 8.9 10.8 8.7 9.3 95 98 47 1.5 NA 0.9 0.7 0.8 0.1 96 93 51 0.1 NA NA NA NA NA If I use plot3d(swadt[,1],swadt[,2],swadt[,3],size=swadt[,4]) I get the following error Error in rgl.numeric(size) : size must be a single numeric value Is there a way of plotting this? Thanks Zoe Hoare [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R-2.9.0 on CentOS 5 installation?
Has anyone else had experience with CentOS and the latest version of R? $uname -r 2.6.18-92.1.22.el5 On occasion, I need to have the LD_LIBRARY_PATH environment variable which I set in ~/.bash_profile. Until R-2.9.0 that has worked fine, but now when I check with Sys.getenv(LD_LIBRARY_PATH), I see it's not set. It appears to me that it's not something that can be set after R has started. The problem doesn't exist with Fedora 8, nor with Mepis 6.5 in my experience, and I've been informed that Fedora 9 doesn't have the problem either. Has anyone else seen it? Particularly with CentOS. TIA -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function recommendation for this study...
Thank you for the suggestions, I'm sure irr is what I'm looking for. Thanks again. spencerg wrote: To look up observer agreement, you might consider the RSiteSearch package. The RSiteSearch.function looks only for matches in help pages of contributed packages. library(RSiteSearch) oa - RSiteSearch.function(observer agreement) attr(oa, hits) # 4 functions matching this term HTML(oa) # to open the results as a table in a web browser. An alternative search term for this is interrater reliability. ir.r - RSiteSearch.function(inter-rater reliability) attr(ir.r, hits) # 1 irr - RSiteSearch.function(interrater reliability) attr(irr, hits) # 19 ir..r - RSiteSearch.function(inter rater reliability) attr(ir..r, hits) # 1 In particular, this identified a package irr for interrater reliability. The development version of the RSiteSearch package on R-Forge includes a unionRSiteSearch function that allows one to combine all these searches. You can get this version using 'install.packages(RSiteSearch, repos=http://R-Forge.R-project.org;)'; if this gives you version 1.0-0, please wait 24 hours and try again, because this version contains a bug that I just fixed. The new version 1.0-1 should be available in 24 hours. With it, the following just worked for me: IRR - unionRSiteSearch(oa, unionRSiteSearch(ir.r, unionRSiteSearch(irr, ir..r) ) ) attr(IRR, hits) HTML(IRR) Hope this helps. Spencer Graves Murray Cooper wrote: Paul, I suggest looking up observer agreement. The description of your study sounds like a classical categorical observer agreement problem. I can't give a reference off the top of my head, but if you get stuck, e-mail me and I'll try and find a ref to get you started. Murray M Cooper, Ph.D. Richland Statistics 9800 N 24th St Richland, MI, USA 49083 Mail: richs...@earthlink.net - Original Message - From: Paul Heinrich Dietrich paul.heinrich.dietr...@gmail.com To: r-help@r-project.org Sent: Sunday, May 10, 2009 8:25 AM Subject: [R] Function recommendation for this study... Hi, I'm not used to thinking along these lines, and wanted to ask your advice: Suppose you have a sample of around 100, consisting of patients according to doctors, in which patients and doctors are given a questionnaire with categorical responses. Each patient somehow has roughly 3 doctors, or 3 rows of data. The goal is to assess by category of each question or DV the agreement between the patient and 3 doctors. For example, a question may be asked about how well the treatment is understood by the patient, and the patient answers with their perception, while the 3 doctors each answer with their perception. The person currently working on this has used a Wilcoxon Sign Rank test, and asked what I thought. Personally, I shy away from nonparametrics and prefer parametric Bayesian methods, but of course am up for whatever is most appropriate. I was concerned about using multiple Wilcoxon tests, one for each question, and wondering if there is a parametric method in R for something like this, and a method which is multivariate? Thanks for any suggestions. -- View this message in context: http://www.nabble.com/Function-recommendation-for-this-study...-tp23469646p23469646.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Function-recommendation-for-this-study...-tp23469646p23480875.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using ACE in the ape package
Having a problem running the ace command in ape. After reading my table into R and then putting the names of the rows in the table in same order as the tree I can't get ace to run and get the message Erreur dans as.matrix(x) : dims [produit 25] ne correspond pas à la longueur de l'objet [0] This is the command I am using and each of the vectors used in the snalysis. ERreconstruction - ace(car, tr, type=discrete, model=SYM) car [1] 4 1 7 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1 2 1 tr Phylogenetic tree with 32 tips and 31 internal nodes. Tip labels: Batis_maritima, Pentadiplandra_brazzeana, Tovaria_pendula, Reseda_lutea, Tropaeolum_majus, Carica_sp, ... Rooted; no branch lengths. Thanks for any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3d Scatterplot using rgl
Hi Zoé, try plot3d(swadt[,1],swadt[,2],swadt[,3],radius=swadt[,4],type=s) Hope this helps. regards. Olivier Zoe Hoare wrote: Hi, I am trying to plot a 3d scatter plot using the rgl package but am having trouble. I have a matrix containing x, y and z co-ordinates and a fourth element related to a count variable. I would like to plot the points using plot3d with the sizes of the points related to the fourth element in the matrix. Is this possible with plot3d or do I need to use something else? I include a small example of what I am trying to do swadt A B Crun1 run2 run3 run4 run5 run6 93 96 51 0.1 NA 0.1 NA NA NA 93 97 50 0.3 NA NA 0.1 NA NA 93 98 49 0.1 NA NA NA NA NA 94 95 51 NA NA NA NA NA 0.1 94 100 46 0.1 NA NA NA NA NA 94 96 50 2.1 0.1 1.0 0.7 0.8 0.4 94 97 49 3.2 0.9 1.9 1.9 1.6 1.6 94 98 48 0.9 NA 0.3 0.4 0.5 0.1 95 94 51 NA NA NA 0.1 0.1 NA 95 95 50 3.4 0.7 2.8 2.4 2.9 2.3 95 96 49 12.5 13.4 13.6 15.0 15.3 17.1 95 97 48 10.2 10.8 8.9 10.8 8.7 9.3 95 98 47 1.5 NA 0.9 0.7 0.8 0.1 96 93 51 0.1 NA NA NA NA NA If I use plot3d(swadt[,1],swadt[,2],swadt[,3],size=swadt[,4]) I get the following error Error in rgl.numeric(size) : size must be a single numeric value Is there a way of plotting this? Thanks Zoe Hoare [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/3d-Scatterplot-using-rgl-tp23480170p23481038.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] readBin: read from defined offset TO defined offset?
Hello, With the help of seek I can start readBin from any byte offset within my file that I deem appropriate. What I would like to do is to be able to define the endpoint of that read as well. Is there any solution to that already out there? Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with groups of labels?
Phillip Porter wrote: Good Morning, I have a graph with groups of variables. I have include the group names as variables so that I can have them positioned correctly. Unfortunately this means that the group names have to follow all of the same rules as the variables within the groups. I would rather have those group names left justified and bolded. I know that I can do this in an mtext() function using font=2 and adj=0, but I can never get the labels lined up exactly right. Is there a simpler way of getting one group of labels right justified and another group of labels left justified and still have them all automatically positioned correctly? Hi Phillip, I'm not exactly sure how you are positioning the labels. Is it possible to give us an example with some data that will produce a plot to show what you want? It shouldn't be too hard to do. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Partial Derivatives in R
Hi Spencer, Thanks for suggesting the genD function. In attempting it, I have rearranged my function from phat1 ~ ... to ... - 1, it apparently doesn't like the first one :) But when I run it, it tells me the partials are all zero. I'm trying out a simple MNL equation before I expand it to what I'm looking for. Here is what I tried (and I get different answers from a textbook solution, deriv(), and genD()): ### Variables for an observation x01 - rnorm(1,0,1) x02 - rnorm(1,0,1) ### Parameters for an observation b00.1 - rnorm(1,0,1) b00.2 - rnorm(1,0,1) b00.3 - 0 b01.1 - rnorm(1,0,1) b01.2 - rnorm(1,0,1) b01.3 - 0 b02.1 - rnorm(1,0,1) b02.2 - rnorm(1,0,1) b02.3 - 0 ### Predicted Probabilities for an observation phat1 - 0.6 phat2 - 0.3 phat3 - 0.1 ### Correct way to calculate a partial derivative partial.b01.1 - phat1 * (b01.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.2 - phat2 * (b01.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.3 - phat3 * (b01.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b01.1; partial.b01.2; partial.b01.3 [1] 0.04288663 [1] -0.1804876 [1] 0.1376010 partial.b02.1 - phat1 * (b02.1 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.2 - phat2 * (b02.2 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.3 - phat3 * (b02.3 - (b01.1*phat1+b01.2*phat2+b01.3*phat3)) partial.b02.1; partial.b02.2; partial.b02.3 [1] 0.8633057 [1] 0.3171978 [1] 0.1376010 ### Derivatives for MNL dp1.dx - deriv(phat1 ~ exp(b00.1+b01.1*x01+b02.1*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c(x01,x02)) dp2.dx - deriv(phat2 ~ exp(b00.2+b01.2*x01+b02.2*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c(x01,x02)) dp3.dx - deriv(phat3 ~ exp(b00.3+b01.3*x01+b02.3*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)), c(x01,x02)) attr(eval(dp1.dx), gradient) x01 x02 [1,] -0.01891354 0.058918 attr(eval(dp2.dx), gradient) x01 x02 [1,] -0.1509395 -0.06258685 attr(eval(dp3.dx), gradient) x01 x02 [1,] 0.169853 0.003668849 library(numDeriv) dp1.dx - function(x) {exp(b00.1+b01.1*x01+b02.1*x02) / + (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ + exp(b00.3+b01.3*x01+b02.3*x02)) - phat1} test - genD(dp1.dx, c(phat1,b00.1,b01.1,b02.1,x01,x02)); test $D [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,]000000000 0 0 0 0 0 [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [1,] 0 0 0 0 0 0 0 0 0 0 0 0 [,27] [1,] 0 $p [1] 6 $f0 [1] 0.05185856 $func function(x) {exp(b00.1+b01.1*x01+b02.1*x02) / (exp(b00.1+b01.1*x01+b02.1*x02)+exp(b00.2+b01.2*x01+b02.2*x02)+ exp(b00.3+b01.3*x01+b02.3*x02)) - phat1} $x [1] 0.6 1.401890082 -1.304531849 0.062833294 -0.143141379 [6] -0.005995477 $d [1] 1e-04 $method [1] Richardson $method.args $method.args$eps [1] 1e-04 $method.args$d [1] 1e-04 $method.args$zero.tol [1] 1.781029e-05 $method.args$r [1] 4 $method.args$v [1] 2 attr(,class) [1] Darray spencerg wrote: Have you considered genD{numDeriv}? If this does not answer your question, I suggest you try the RSiteSearch package. The following will open a list of options in a web browser, sorted by package most often found with your search term: library(RSiteSearch) pd - RSiteSearch.function('partial derivative') pds - RSiteSearch.function('partial derivatives') attr(pd, 'hits') # 58 attr(pds, 'hits')# 52 summary(pd) HTML(pd) HTML(pds) The development version available via 'install.packages(RSiteSearch, repos=http://R-Forge.R-project.org;)' also supports the following: pd. - unionRSiteSearch(pd, pds) attr(pd., 'hits')# 94 HTML(pd.) Hope this helps. Spencer Graves Paul Heinrich Dietrich wrote: Quick question: Which function do you use to calculate partial derivatives from a model equation? I've looked at deriv(), but think it gives derivatives, not partial derivatives. Of course my equation isn't this simple, but as an example, I'm looking for something that let's you control whether it's a partial or not, such as: somefunction(y~a+bx, with respect to x, partial=TRUE) Is there anything like this in R? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Partial-Derivatives-in-R-tp23470413p23481511.html Sent from the R help mailing list archive at Nabble.com.
[R] doubt
Hi Sir, I want to install the package cluster in R language. I could be installing, but I cant load that package.. I have faced the following warning in installing time.. Warning: cannot remove prior installation of package 'cluster' So, I tried to update the package, but again I faced the following issue update.packages() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.uk.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning message: In open.connection(con, r) : no fue posible conectarse a 'cran.r-project.org' en el pueto 80. Sample: utils:::menuInstallLocal() package 'cluster' successfully unpacked and MD5 sums checked Warning: cannot remove prior installation of package 'cluster' updating HTML package descriptions load(cluster) Error en load(cluster) : objeto 'cluster' no encontrado library(cluster) Error en library(cluster) : there is no package called 'cluster' library(clValid) Loading required package: cluster Error: package 'cluster' could not be loaded Además: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called 'cluster' update.packages() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.uk.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning message: In open.connection(con, r) : no fue posible conectarse a 'cran.r-project.org' en el pueto 80. Can you tell me for any suggestions... Thank you, Shanthi Rangasamy Ph. D. Student Electronics and Communications Department CEIT - IK4 Research Alliance Pº. Manuel Lardizábal, 15 20.018 Donostia-San Sebastián SPAIN Tel. +34 943 212 800 (Ext. 2804) Fax: +34 943 213 076 http://www.ceit.es/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] aggregate over x cases
Hello, I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block. For example block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 . Selecting only the the first two rows per trial should result in block trial x y 1 1 605 150 1 1 603 148 1 2 607 148 1 2 605 152 The data I am dealing with a x-y coordinates (samples) from an eye-tracking experiment. I receive the data in this format and need to eliminate unwanted samples. Thanks Jens Bölte __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Amsterdam course - Pharmacokinetic and pharmacodynamic modeling and simulation
LS, We would like to inform you about the new course Pharmacokinetic and pharmacodynamic modeling and simulation by Dr. Jan Freijer in Amsterdam, November 28th. The course is meant for users of R or S-PLUS in the bio-pharmaceutical sciences who would like to apply it to clinical trial simulations. You can find the full information on the course via: http://www.can.nl/events/details.php?id=57 Price for the course is EURO 395,- VAT excluded and you can subscribe via our web site, email, fax (+31 (0)20 5608448) or post (CAN - Nieuwpoortkade 25 - 1055 RX Amsterdam). If you have any questions, please feel free to contact me. Kind Regards, Dick Verkerk Check out our complete event list at: http://www.can.nl/events/ _ CANdiensten, Nieuwpoortkade 23-25, NL-1055 RX Amsterdam voice: +31 20 5608400 fax: +31 20 5608448 i...@can.nl _ Your Partner in Finance, Mathematics and Statistics! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate over x cases
try this, library(plyr) ddply(d, .(block, trial), function(.d) .d[1:2, ]) block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 2 607 148 4 1 2 605 152 HTH, baptiste On 11 May 2009, at 13:49, Jens Bölte wrote: Hello, I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block. For example block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 . Selecting only the the first two rows per trial should result in block trial x y 1 1 605 150 1 1 603 148 1 2 607 148 1 2 605 152 The data I am dealing with a x-y coordinates (samples) from an eye- tracking experiment. I receive the data in this format and need to eliminate unwanted samples. Thanks Jens Bölte ATT1.txt _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate over x cases
Try this: do.call(rbind, by(DF, DF[1:2], head, 2)) On Mon, May 11, 2009 at 7:49 AM, Jens Bölte boe...@psy.uni-muenster.de wrote: Hello, I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block. For example block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 . Selecting only the the first two rows per trial should result in block trial x y 1 1 605 150 1 1 603 148 1 2 607 148 1 2 605 152 The data I am dealing with a x-y coordinates (samples) from an eye-tracking experiment. I receive the data in this format and need to eliminate unwanted samples. Thanks Jens Bölte __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate over x cases
Here is a way of doing it: x block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 do.call(rbind, lapply(split(x, list(x$block, x$trial), drop=TRUE), head, 2)) block trial x y 1.1.1 1 1 605 150 1.1.2 1 1 603 148 1.2.7 1 2 607 148 1.2.8 1 2 605 152 On Mon, May 11, 2009 at 7:49 AM, Jens Bölte boe...@psy.uni-muenster.dewrote: Hello, I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block. For example block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 . Selecting only the the first two rows per trial should result in block trial x y 1 1 605 150 1 1 603 148 1 2 607 148 1 2 605 152 The data I am dealing with a x-y coordinates (samples) from an eye-tracking experiment. I receive the data in this format and need to eliminate unwanted samples. Thanks Jens Bölte __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readBin: read from defined offset TO defined offset?
Can you be more specific on how you want to define the endpoint of that read. What is the criteria you want to use? Can you read in a block and then search of the pattern? On Mon, May 11, 2009 at 7:05 AM, Johannes Graumann johannes_graum...@web.de wrote: Hello, With the help of seek I can start readBin from any byte offset within my file that I deem appropriate. What I would like to do is to be able to define the endpoint of that read as well. Is there any solution to that already out there? Thanks for any hints, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate over x cases
good point, i forgot about head (!), library(plyr) ddply(d, .(block, trial), head, 2) block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 2 607 148 4 1 2 605 152 On 11 May 2009, at 14:04, Gabor Grothendieck wrote: Try this: do.call(rbind, by(DF, DF[1:2], head, 2)) On Mon, May 11, 2009 at 7:49 AM, Jens Bölte boe...@psy.uni-muenster.de wrote: Hello, I have been struggling for quite some time to find a solution for the following problem. I have a data frame which is organized by block and trial. Each trial is represented across several rows in this data frame. I'd like to extract the first x rows per trial and block. For example block trial x y 1 1 1 605 150 2 1 1 603 148 3 1 1 604 140 4 1 1 600 140 5 1 1 590 135 6 1 1 580 135 7 1 2 607 148 8 1 2 605 152 10 1 2 600 158 . Selecting only the the first two rows per trial should result in block trial x y 1 1 605 150 1 1 603 148 1 2 607 148 1 2 605 152 The data I am dealing with a x-y coordinates (samples) from an eye- tracking experiment. I receive the data in this format and need to eliminate unwanted samples. Thanks Jens Bölte __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Select the rows in a dataframe that matches a criteria in another dataframe
On May 10, 2009, at 7:54 PM, David Winsemius wrote: ?subset ?%in% (I have gotten tired of converting dataframes that are presented in a non-executable form, such as is supported by the dput function. So, ... you should read those help pages and take the obvious path to success.) Something along the lines of: subset(df1, Firm %in% df2[df2$Audited==yes, Firm] ) #untested Looking at my untested code I can see one error already. (Perhaps) should be: subset(df1, Firm %in% df2[df2$Audited==yes, Firm] ) On May 10, 2009, at 5:52 PM, Cecilia Carmo wrote: Hi everyone! Thank you for the help you have been given to me, and here I'm with another problem with my dataframes: I have two dataframes (with much more observations), like these: Dataframe1 Firm Year cash 5004002002007 100 5004002002006 200 5004002002005 400 5004003002007 300 5004003002006 240 5004003002005 120 5004004002007 340 5004004002006 890 5004004002005 250 Dataframe 2 FirmAudited consolidate 500400200 yes no 500400300 yes yes 500400400 nono I want to make another dataframe equal to the dataframe1, but just with the firms «audited», or with the firms «audited» and «consolidate». For example, with the audited and consolidated, the output would be just firm 500400300, like this: Firm Year cash 5004003002007 300 5004003002006 240 5004003002005 120 I’ve tried intersect () but it gives me just the number of the firm, and it is not what I want. What I want is a dataframe with all the information, but just the firms that match my criteria. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] doubt
You might try again, assuming you are a Windows user, which was suggested by your choice of repositories but not actually stated by you. The repository may have been temporarily unavailable. It seems to be open for service now with a version of cluster that is 1.11.13. -- David Winsemius On May 11, 2009, at 7:22 AM, Rangasamy, Shanthi wrote: Hi Sir, I want to install the package cluster in R language. I could be installing, but I cant load that package.. I have faced the following warning in installing time.. Warning: cannot remove prior installation of package 'cluster' So, I tried to update the package, but again I faced the following issue update.packages() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.uk.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning message: In open.connection(con, r) : no fue posible conectarse a 'cran.r-project.org' en el pueto 80. Sample: utils:::menuInstallLocal() package 'cluster' successfully unpacked and MD5 sums checked Warning: cannot remove prior installation of package 'cluster' updating HTML package descriptions load(cluster) Error en load(cluster) : objeto 'cluster' no encontrado library(cluster) Error en library(cluster) : there is no package called 'cluster' library(clValid) Loading required package: cluster Error: package 'cluster' could not be loaded Además: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called 'cluster' update.packages() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.uk.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning message: In open.connection(con, r) : no fue posible conectarse a 'cran.r-project.org' en el pueto 80. Can you tell me for any suggestions... Thank you, David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Comparing COXPH models, one with age as a continuous variable
The anova process is only statistically valid for nested models, i.e., where one includes the other as a proper subset. A model with continuous age and one with discrete age are not nested; your p-value will be meaningless. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readBin: read from defined offset TO defined offset?
On 11/05/2009 7:05 AM, Johannes Graumann wrote: Hello, With the help of seek I can start readBin from any byte offset within my file that I deem appropriate. What I would like to do is to be able to define the endpoint of that read as well. Is there any solution to that already out there? Sure: just use the n parameter to readBin. This will work for any type except character, but it doesn't make sense to read those in a given range: what do you do if the last one is not zero terminated? If you want the end of block to count as a terminator, then read the block as raw, add a null to the end, and then re-read the raw vector. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Import Visual FoxPro (.dbf)
I have a large series of Visual FoxPro (.dbf) files that I want to convert to a plain text (.csv) file. I wrote a quick script to do all of this for me. With a little tweaking it seemed to work like a charm. But, when I looked at my newly created text files carefully, I discovered a problem. Every single file produced by my script had a few extra columns in it. To better understand this, I imported a single file. Here are my results: library(foreign) temp.df - read.dbf(Activity.dbf) ilp.dbc changed to: X.ilp.dbc Field name: changed to: X Field name: changed to: X.1 Field name: changed to: X.2 Field name: changed to: X.3 Field name: changed to: X.4 Field name: changed to: X.5 Field name: changed to: X.6 Based on the table definitions I received from the state, none of these tables have a column called ilp.dbc. When I open these same .dbf files in OpenOffice.org, individually, I do not see these columns. When I look at the temp.df in R, these mystery columns are all empty. Otherwise, the data appears to be fine. I looked at ?read.dbf and I did not see any options to play with that would seem to help. At the moment, I have a work-around in my script that prevents these extra columns from being written to the csv files, but I am curious to learn what I am doing wrong. The problem may be entirely of my own creation. Most of the info in these files is protected by HIPAA, which limits my ability to provide example files. If anyone really wants one, I can look to see if there are any files that I can release. Or I can try deleting all of the info and see if the problem persists. Version Information: r-project: 2.8.1 foreign: 0.8.30-1 Ubuntu:9.04 (32-bit) Thanks for any thoughts. --andy -- This is the price and the promise of citizenship. - Barack Obama __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems to run SVM regression with e1071
Hi R users, I'm trying to run a SVM - regression using e1071 package but the function svm() all the time apply a classification method rather than a regression. svm.m1 - svm(st ~ ., data = train, cost = 1000, gamma = 1e-03) Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1000 gamma: 0.001 Number of Support Vectors: 209 When I specify the method =eps-regression is the same svm.m1 - svm(st ~ ., data = train, method=eps-regression, cost = 1000, gamma = 1e-03) Call: svm(formula = st ~ ., data = train, method = eps-regression, cost = 1000, gamma = 0.001) Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1000 gamma: 0.001 Number of Support Vectors: 209 I know that it is wrong because when I do prediction appear levels. I'm working with normalized data [0,1] (249 points) . I don't have idea what it is wrong. Somebody can help me? h_aspire dados=read.table(svmdata.txt,header=TRUE) index=1:nrow(d) test=d[210:249,] train=d[1:209,] require(e1071) tuneobj = tune.svm(st ~ ., data = train, gamma = 10^(-6:-3), cost = 10^(1:3summary(tuneobj) svm.m1 - svm(st ~ ., data = train, cost = 1000, gamma = 1e-03) svm.pred - predict(svm.m1, test) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot bivariate joint pdf
beetle2 wrote: For a homework question. I was wondering if rcmdr has a function to plot a graph of a bivariate function of X and Y. I have a function with joint pdf fX,Y(x,y) = x+y for 0x1 , 0y1 I've tried x - seq(0,1,.001) y - seq(0,1,.001) r = x+y plot(r) but it seems to just add them together say .2+.2 .3+.3 not other possibilities like .9 + .1 We don't do homework questions here, but a few hints: (1) the question doesn't seem to be fully specified. Are x and y supposed to be uniform? (2) you could get a reasonable representation of the solution (although not necessarily one your prof would be happy with) by adding runif(1,0,1) and runif(1,0,1) (3) to do this analytically, think about convolutions and/or moment generating functions. Ben Bolker -- View this message in context: http://www.nabble.com/Plot-bivariate-joint-pdf-tp23481872p23483615.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Citing R/Packages Question
It would be nice if each package went through a peer-review and had a related publication (either in R-news or J Stat Soft). This publication can then be used as the official citation for the package. However, this still would not address updates and versions of the package. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of roger koenker Sent: Saturday, May 09, 2009 8:36 AM To: Derek Ogle Cc: r-help@r-project.org Subject: Re: [R] Citing R/Packages Question I've had an email exchange with the authors of a recent paper in Nature who also made a good faith effort to cite both R and the quantreg package, and were told that the Nature house style didn't allow such citations so they were dropped from the published paper and the supplementary material appearing on the Nature website. Since the CRAN website makes a special effort to make prior versions of packages available, it would seem to me to be much more useful to cite version numbers than access dates. There are serious questions about the ephemerality of url citations, not all of which are adequately resolved by the Wayback machine, and access dating, but it would be nice to have some better standards for such contingent citations rather than leave authors at the mercy of copy editors. I would also be interested in suggestions by other contributors. url:www.econ.uiuc.edu/~rogerRoger Koenker email rkoen...@uiuc.edu Department of Economics vox:217-333-4558University of Illinois fax:217-244-6678Champaign, IL 61820 On May 8, 2009, at 5:27 PM, Derek Ogle wrote: I used R and the quantreg package in a manuscript that is currently in the proofs stage. I cited both R and quantreg as suggested by citation() and noted the version of R and quantreg that I used in the main text as All tests were computed with the R v2.9.0 statistical programming language (R Development Core 2008). Quantile regressions were conducted with the quantreg v4.27 package (Koenker 2008) for R. The editor has asked me to also provide the date when the webpage was accessed for both R and quantreg. This does not seem like an appropriate request to me as both R and the quantreg package are versioned. This request seems to me to be the same as asking someone when they purchased commercial package X version Y (which I don't think would be asked). Am I thinking about this correctly or has the editor made a valid request? I would be interested in any comments or opinions. Dr. Derek H. Ogle Associate Professor of Mathematical Sciences and Natural Resources Northland College 1411 Ellis Avenue Box 112 Ashland, WI 715.682.1300 www.ncfaculty.net/dogle/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Ancestral Character Estimation
Hello, I was just wondering whether with the ace command in ape it was possible to incorporate polymorphic characters in ancestral character estimation. I am currently working with distibutions and often distributions are not restricted to a single geographic area. Thanks for any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dimnames do not match array extent
Dear adegenet users, I am trying to calculate geographical barriers using monmonier. However, I consistently get the error dimnames do not match array extent. - import of the distance matrix: read.table - conversion 1: as.dist(data, diag=TRUE, upper =TRUE) - conversion 2: as.matrix(data) - is.numeric(data) are answered for the geographic and the species distances are answered TRUE - is.matrix(data) is also answered TRUE for both The network is calculated but when setting the threshold I always get the above error. However, I checked the names and numbers of rows and columns now several times in Excel and I can find no differences... What would be the R way? Or is there a simple way to adopt the names from a master file? Trying to get around the problem I calculated everything without any row- or column names. I than get the error dimnames do not match array extent when using optimize.monmonier Any solution or suggestions are highly appreciated. Thanks in advance and best regards Johannes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Searching within a ch. string
Hi all, is there any function to find some words in a character-string? For example suppose the string is : gdfsa-sdhchc-88, now I want to find whether this string contains sdhch. Is there any R function to do that? Regards, -- View this message in context: http://www.nabble.com/Searching-within-a-ch.-string-tp23484010p23484010.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using ACE in the ape package
Andrew RODRIGUES wrote: Having a problem running the ace command in ape. After reading my table into R and then putting the names of the rows in the table in same order as the tree I can't get ace to run and get the message Erreur dans as.matrix(x) : dims [produit 25] ne correspond pas à la longueur de l'objet [0] This is the command I am using and each of the vectors used in the snalysis. ERreconstruction - ace(car, tr, type=discrete, model=SYM) car [1] 4 1 7 5 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1 2 1 tr Phylogenetic tree with 32 tips and 31 internal nodes. Tip labels: Batis_maritima, Pentadiplandra_brazzeana, Tovaria_pendula, Reseda_lutea, Tropaeolum_majus, Carica_sp, ... Rooted; no branch lengths. (1) you haven't actually given us a reproducible example here; try giving us the results of write.tree() on your tree. (2) you will have better luck with this question, and your related more recent one, on the r-sig-phylo (phylogenetics special interest group) mailing list rather than this list, where only a few people know about comparative methods, the ape package, etc. good luck Ben Bolker -- View this message in context: http://www.nabble.com/Using-ACE-in-the-ape-package-tp23480994p23484016.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Error, very odd....
At 12:37 AM -0700 5/11/09, Katie2009 wrote: hi dieter, the method i'm using is in excel, copying the data, then in r w-read.delim(clipboard) w-as.data.frame(w) i've been doing a bit more fiddling, and have identified the 'class' of the column that i'm having trouble with, is classified as 'factor' whilst the rest are numeric. if i just change that column to as.numeric of the column, this has appeared to have solved the problem. Has this changed that data at all though? Well, you can look at the data to find out. Either just print it, or perhaps use simple exploration techniques, such as unique( column) table(column) summary(column) compare before and after converting to numeric In general, changing a factor to numeric can change the data relative to what you might think the data actually is. Here is an example: tmp1 - c(-1,0,1) tmp2 - factor(tmp1) tmp3 - as.numeric(tmp2) tmp1 [1] -1 0 1 tmp2 [1] -1 0 1 Levels: -1 0 1 tmp3 [1] 1 2 3 tmp3 is clearly not the same as tmp1. tmp4 - as.numeric(format(tmp2)) tmp4 [1] -1 0 1 Evidently, R is creating a factor from a column that you think is numeric. Your job is to find out why. I would guess that you have, somewhere in the column, an entry that isn't a number. Perhaps a typographical error in the spreadsheet column. The effect of inputting as absolute values vs with negative numbers should give a clue to that. Try tmp - as.numeric(format( column )) any(is.na(tmp)) and if that is TRUE, then column[is.na(tmp)] -Don Thanks. Dieter Menne wrote: Katie2009 wrote: I'm trying to analyse some excel data in R. The problem is that when i input the data with the first column as absolute values, everything works fine, can analyse as normal. When I leave the first column unchanged to import negative numbers as well I get: Error in storage.mode(y) - double : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored You did not tell us anything how you got the data from Excel, so I have to guess. Try to re-arrange your Excel row so that the first (3 ? check the docs; which docs? your unknown function's) lines contain non-missing data. Dieter -- View this message in context: http:// www. nabble.com/R-Error%2C-very-odd-tp23477195p23478471.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:// stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http:// www. R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching within a ch. string
On 5/11/2009 10:07 AM, RON70 wrote: Hi all, is there any function to find some words in a character-string? For example suppose the string is : gdfsa-sdhchc-88, now I want to find whether this string contains sdhch. Is there any R function to do that? See ?grep. There are several functions described there, with different outputs. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching within a ch. string
The following is TRUE if the indicated string is found: regexpr(sdhch, gdfsa-sdhchc-88) 0 See ?regexpr Either of the next two will break up a string into words. The first needs to know the delimiters whereas the second needs to know the contents: strsplit(gdfsa-sdhchc-88, \\W+)[[1]] [1] gdfsa sdhchc 88 library(gsubfn) strapply(gdfsa-sdhchc-88, \\w+, c)[[1]] [1] gdfsa sdhchc 88 See ?strplit and ?regex and also the gsubfn home page at: http://gsubfn.googlecode.com where you can find info on strapply and also further resources on regular expressions. On Mon, May 11, 2009 at 10:07 AM, RON70 ron_michae...@yahoo.com wrote: Hi all, is there any function to find some words in a character-string? For example suppose the string is : gdfsa-sdhchc-88, now I want to find whether this string contains sdhch. Is there any R function to do that? Regards, -- View this message in context: http://www.nabble.com/Searching-within-a-ch.-string-tp23484010p23484010.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Searching within a ch. string
Hi Ron, Look up the grep() function. Cheers, -- *Luc Villandré* /Biostatistician McGill University Health Center - Montreal Children's Hospital Research Institute/ RON70 wrote: Hi all, is there any function to find some words in a character-string? For example suppose the string is : gdfsa-sdhchc-88, now I want to find whether this string contains sdhch. Is there any R function to do that? Regards, // __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Inconsistency in representation of variables
In stats::D, I was wondering why variables are represented as symbols in expressions, but as strings in lists of variables: D(quote(x^2),x) = 2*x D(quote(x^2),quote(x)) = error Variable must be a character string Strings are not allowed in the expression to denote variables: D(quote(x),quote(x)) == D(k,x) = NA (why not an error?) -s __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Rcompression on Omegahat
I tried to install Rcompression (for reading Matlab files) options(CRAN = c(getOption(CRAN), http://www.omegahat.org/R;)) install.packages(Rcompression) Warning: unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/2.9 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘Rcompression’ is not available Manual inspection of the site showed that 2.7 is the last version. Did I miss some change notes? Dieter R version 2.9.0 (2009-04-17) i386-pc-mingw32 locale: LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252; LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base loaded via a namespace (and not attached): [1] tools_2.9.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Citing R/Packages Question
I have have a package that I wrote called StreamMetabolism; which I use to calculate single station stream metabolism from diurnal oxygen curves. I would love to publish something about it (I am also an entering PhD student and need publications); however, I am not sure the applicability out side of a small subset of stream ecologists. Also, JSS or Rnews may not be the proper forum. We could publish a bulletin or something with all of the packages as an official document to site. Just a half fleshed idea. thanks Stephen Sefick On Mon, May 11, 2009 at 9:48 AM, Ravi Varadhan rvarad...@jhmi.edu wrote: It would be nice if each package went through a peer-review and had a related publication (either in R-news or J Stat Soft). This publication can then be used as the official citation for the package. However, this still would not address updates and versions of the package. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of roger koenker Sent: Saturday, May 09, 2009 8:36 AM To: Derek Ogle Cc: r-help@r-project.org Subject: Re: [R] Citing R/Packages Question I've had an email exchange with the authors of a recent paper in Nature who also made a good faith effort to cite both R and the quantreg package, and were told that the Nature house style didn't allow such citations so they were dropped from the published paper and the supplementary material appearing on the Nature website. Since the CRAN website makes a special effort to make prior versions of packages available, it would seem to me to be much more useful to cite version numbers than access dates. There are serious questions about the ephemerality of url citations, not all of which are adequately resolved by the Wayback machine, and access dating, but it would be nice to have some better standards for such contingent citations rather than leave authors at the mercy of copy editors. I would also be interested in suggestions by other contributors. url: www.econ.uiuc.edu/~roger Roger Koenker email rkoen...@uiuc.edu Department of Economics vox: 217-333-4558 University of Illinois fax: 217-244-6678 Champaign, IL 61820 On May 8, 2009, at 5:27 PM, Derek Ogle wrote: I used R and the quantreg package in a manuscript that is currently in the proofs stage. I cited both R and quantreg as suggested by citation() and noted the version of R and quantreg that I used in the main text as All tests were computed with the R v2.9.0 statistical programming language (R Development Core 2008). Quantile regressions were conducted with the quantreg v4.27 package (Koenker 2008) for R. The editor has asked me to also provide the date when the webpage was accessed for both R and quantreg. This does not seem like an appropriate request to me as both R and the quantreg package are versioned. This request seems to me to be the same as asking someone when they purchased commercial package X version Y (which I don't think would be asked). Am I thinking about this correctly or has the editor made a valid request? I would be interested in any comments or opinions. Dr. Derek H. Ogle Associate Professor of Mathematical Sciences and Natural Resources Northland College 1411 Ellis Avenue Box 112 Ashland, WI 715.682.1300 www.ncfaculty.net/dogle/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff
[R] predict function the other way around
Dear List, Consider the following example x=c(1,2,3,4,5) y=c(2,4,6,8,10) linearmodel=lm(y~x) To predict a y-value if you know the corresponding x value is very easy with the command predict. predict(linearmodel, newdata=(x=1.5)) The other way around, to predict an x-value with a corresponding y-value, doesn't work unfortunately. Is there another function that can do that, or do I need to solve that problem the classical way? Thanks in advance Gerrit Voigt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Do you use R for data manipulation?
2009/5/6 Emmanuel Charpentier charp...@bacbuc.dyndns.org: Le mercredi 06 mai 2009 à 00:22 -0400, Farrel Buchinsky a écrit : Is R an appropriate tool for data manipulation and data reshaping and data organizing? [ Large Snip ! ... ] Depends on what you have to do. I've done what can be more or less termed data management with almost uncountable tools (from Excel (sigh...) to R with SQL, APL, Pascal, C, Basic (in 1982 !), Fortran and even Lisp in passing...). SQL has strong points : join is, to my tastes, more easily expressed in SQL than in most languages, projection and aggregation are natural. However, in SQL, there is no natural ordering of row tables, which makes expressing algorithms using this order difficult. Try for example to express the differences of a time series ... (it can be done, but it is *not* a pretty sight). On the other hand, R has some unique expressive possibilities (reshape() comes to mind). So I tend to use a combination of tools : except for very small samples, I tend to manage my data in SQL and with associated tools (think data editing, for example ; a simple form in OpenOffice's Base is quite easy to create, can handle anything for which an ODBC driver exists, and won't crap out for more than a few hundreds line...). finer manipulation is usually done in R with native tools and sqldf. But, at least in my trade, the ability to handle Excel files is a must (this is considered as a standard for data entry. Sigh ...). So the first task is usually a) import data in an SQL database, and b) prepare some routines to dump SQL tables / R dataframes in Excel tor returning back to the original data author... I don't think Excel is a standard tool for data entry. Epidata entry is much more professional. HTH Emmanuel Charpentier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Legend in plots
Dear R users, I have what I think it is a very simple question concerning plots in R. If you could help me I would be very grateful. How can I include a legend in my plot? Below I give an example of my data and the code I am using. What I wish to accomplish is a legend saying that the black line refers to A, the red to B and the blue to C. Any suggestions? # data x-c(1,2,3,4,5) y1-c(2,4,6,8,10) y2-c(3,4,5,6,7) y3-c(2,3,5,7,9) # plot plot(x, y1, main=plot, type=l, xlab=x-axis, ylab=y-axis, col=black) lines(x, y2, col=red) lines(x, y3, col=blue) Thanking in advance. Best regards, Mafalda [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend in plots
Dear Mafalda, ?legend is what you are looking for. Take a look at the help page. Here is one way to do what you asked for: legend('topleft', c('A','B','C'),lty=1, col=c(1,2,4)) HTH, Jorge On Mon, May 11, 2009 at 11:26 AM, Mafalda Viana via...@tcd.ie wrote: Dear R users, I have what I think it is a very simple question concerning plots in R. If you could help me I would be very grateful. How can I include a legend in my plot? Below I give an example of my data and the code I am using. What I wish to accomplish is a legend saying that the black line refers to A, the red to B and the blue to C. Any suggestions? # data x-c(1,2,3,4,5) y1-c(2,4,6,8,10) y2-c(3,4,5,6,7) y3-c(2,3,5,7,9) # plot plot(x, y1, main=plot, type=l, xlab=x-axis, ylab=y-axis, col=black) lines(x, y2, col=red) lines(x, y3, col=blue) Thanking in advance. Best regards, Mafalda [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Removing any text beginning with...
Hi ! From an Ensembl annotation like ENSG /// ENSGy /// ENSG, I am trying to keep only the first part: ENSG. I wasn't able to find any helpful information about how to do it. Could you help me with that please ? Is the use of the equivalent to the Excel * (any text) a good way of doing it and how ? Your help will be very much appreciated. Amelie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R and McAfee 8.5
Hi, I have been working with R for the last year and using the UKFSST package to look at satellite tag track data and SST information. Fpr those not familiar, the package uses the positions estimated by the satellite tags themselves and the associated SST data from servers (in this case, from the University of Hawaii and the NOAA Coastwatch website) for the time preiod to estimate a reasonable track the animal took while it was at liberty. I'm currently having trouble downloading data from two different servers which I never had a problem before I recevied an upgraded computer with McAfee 8.5. When the package goes to the various servers for SST information to download, I continue to get a message in R: trying URL 'http://coastwatch.pfeg.noaa.gov/coastwatch/CWBrowserWW360.jsp?get=gridDatadataSet=TAGsstatimePeriod=3daycenteredTime=~2007-09-17T12%3A00%3A00maxLat=61.5minLon=295.06296maxLon=301.37891minLat=36filetype=.xyz' Error in download.file(link, dest, mode = wb) : cannot open URL 'http://coastwatch.pfeg.noaa.gov/coastwatch/CWBrowserWW360.jsp?get=gridDatadataSet=TAGsstatimePeriod=3daycenteredTime=~2007-09-17T12%3A00%3A00maxLat=61.5minLon=295.06296maxLon=301.37891minLat=36filetype=.xyz' In addition: Warning messages: 1: In dir.create(folder) : 'C:\DOCUME~1\Joycew\LOCALS~1\Temp\Rtmp0DilA3\sst_temp' already exists 2: In download.file(link, dest, mode = wb) : cannot open: HTTP status was '404 Not Found' I get a similar message when trying to access SST data from University of Hawaii trying URL 'http://atlas.nmfs.hawaii.edu/cgi-bin/reynolds_extract.py?lon1=295.06296lon2=301.37891lat1=37lat2=64.5year1=2007day1=259year2=2007day2=355' Error in download.file(link, dest, mode = wb) : cannot open URL 'http://atlas.nmfs.hawaii.edu/cgi-bin/reynolds_extract.py?lon1=295.06296lon2=301.37891lat1=37lat2=64.5year1=2007day1=259year2=2007day2=355' In addition: Warning message: In download.file(link, dest, mode = wb) : cannot open: HTTP status was '404 Not Found' If I copy and paste the above url's http://coastwatch.pfeg.noaa.gov/coastwatch/CWBrowserWW360.jsp?get=gridDatadataSet=TAGsstatimePeriod=3daycenteredTime=~2007-09-17T12%3A00%3A00maxLat=61.5minLon=295.06296maxLon=301.37891minLat=36filetype=.xyz Into my web browser, I get prompted with a file download window which quickly downloads an empty file. It looks like the data is available, I just can't seem to download it. I've deduced that it must be a problem with the new firewall features of McAfee 8.5 and was wondering if anyone else has run into a problem like this. I've tried using the exclusions options in 8.5 to exclude any R files but have come up empty handed. Still waiting on our informatics division to try and solve the problem as well but I thought I might try asking here as well. Thanks and I appreciate any assistance! Warren N. Joyce e-mail/courriel: warren.jo...@dfo-mpo.gc.ca (new address) Shark Technician/Technicien spécialiste du requin ph/tél: 902-426-6382 laboratory: 902-426-1846 fax/téléc: 902-426-1506 Bedford Institute of Oceanography 1 Challenger Drive P.O. Box 1006 Dartmouth, Nova Scotia Canada, B2Y 4A2 Institut Océanographique de Bedford 1, promenade Challenger C.P. 1006 Dartmouth, Nouvelle-Écosse Canada, B2Y 4A2 Shark Website http://marinebiodiversity.ca/shark/ Otolith Website http://marinebiodiversity.ca/otolith/ Skate Website http://www.marinebiodiversity.ca/skatesandrays/index.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotting colors on a world map
Hi useR's I have created a simple map of the world using the following code: m - map(xlim=c(-180,180), ylim=c(-90,90)) map.axes() I then create a grid of dimension 36x72 using the code: map.grid(m, nx=72, ny=36, labels=FALSE, col=black) This gives 2592 grid cells. In a separate data set of dimension 36x72, I have 2592 temperature values (some missing values are present) ranging from -20 degrees F to 90 degrees F. My question is, how can I create a reasonable color scheme (low temperatures in light blue to higher temperatures in dark red) and plot the temperature colors in their respective grid cells on the map? Take this data matrix as some example data: T - sample(-10:90, 2592, replace=TRUE) mat - matrix(T, nrow=36, ncol=72) Thanks in advance, dxc13 -- View this message in context: http://www.nabble.com/Plotting-colors-on-a-world-map-tp23484524p23484524.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Seewave options
Good afternoon, My name is Thiago. I'm a graduate student and affiliated to an Anuran Bioacustic and Systematics Laboratory at UFU (Federal University of Uberlândia) in Brazil. The professor in charge of the lab (Dr. Ariovaldo Antonio Giaretta) and I have recently been making use of R, specially the packages Sound and Seewave so as to analize anuran recordings. This software is just fantastic, but I am writing to ask for help about the graphics generated by Seewave. A graphic and the script I used are attached to the e-mail, so that you are able to verify if it is possible to reduce the graphic scale of the Y-axis (see we need only until 10 KHz, even less than it). The fact of recording at 44100 Hz/16 bits resolution may be a possible cause for such a long scale, but that is the only way to record with the best quality... If you think it is easier to change my script and send me back, I would reallly appreciate it too. I am looking forward to your reply. Thanks beforehand, __ Thiago Ribeiro de Carvalho Laboratório de Comportamento, Ecologia e Sistemática de Anuros Neotropicais Universidade Federal de Uberlândia http://lattes.cnpq.br/0618169962335506 Veja quais são os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.comsetWavPlayer(command=NULL) x-loadSample(1.wav) play(x) spectro(x, wl = 256, wn = hanning, zp = 0, ovlp = 0, plot = TRUE, grid = FALSE, osc = TRUE, scale = TRUE, cont = FALSE, collevels = seq(-30, 0, 1), palette = spectro.colors, contlevels = seq(-30, 0, 10), colcont = black, colbg = white, colgrid = black, colaxis = black, collab=black, plot.title = title(main = , xlab = Time (s), ylab = Frequency (kHz)), scalelab = Amplitude\n(dB), scalefontlab = 1, scalecexlab =0.75, axisX = TRUE, axisY = TRUE, tlim = NULL, trel = TRUE, flim = NULL, flimd = NULL, listen=TRUE) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot bivariate joint pdf
For a homework question. I was wondering if rcmdr has a function to plot a graph of a bivariate function of X and Y. I have a function with joint pdf fX,Y(x,y) = x+y for 0x1 , 0y1 I've tried x - seq(0,1,.001) y - seq(0,1,.001) r = x+y plot(r) but it seems to just add them together say .2+.2 .3+.3 not other possibilities like .9 + .1 Thanks -- View this message in context: http://www.nabble.com/Plot-bivariate-joint-pdf-tp23481872p23481872.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with groups of labels?
At 9:25 PM +1000 5/11/09, Jim Lemon wrote: Hi Phillip, I'm not exactly sure how you are positioning the labels. Is it possible to give us an example with some data that will produce a plot to show what you want? It shouldn't be too hard to do. Jim Data is something along the lines of: variablescore Real Bad Stuff 0 Real23 Bad 14 Stuff 17 Other Crazy Things 0 Other 18 Crazy 43 Things 13 The basic plot looks like this: barplot(score, horiz=TRUE, axes=FALSE, las=2, space=1, names.arg=c(Real Bad Stuff, Real,Bad,Stuff,Other Crazy Things,Other,Crazy,Things)) I've been trying make it look the way I want it by doing this: barplot(score, horiz=TRUE, axes=FALSE, las=1, space=1, names.arg=c(, Real,Bad,Stuff,,Other,Crazy,Things), cex.names=.5) mtext(c(Real Bad Stuff,Other Crazy Things),at=c(8,15.6),side=2, line=1.5,adj=1, las=1, cex=.5, font=2) The mtext is annoying to line up with the actual plot. If there was a way to get it to line up with the variables that would solve my problems, but I've tried at=variable and at=score (putting in for all of the variable names I don't want bolded and left justified) and neither way gets them to line up. Thanks, Phillip [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What does it mean by skip=2 and skip=7?
Can anyone tell me what is skip=2, skip =7 From ?read.csv: skip: integer: the number of lines of the data file to skip before beginning to read data. and %in% mean here? %in% matches values; see ?'%in%', and example('%in%') Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram frequencies with a normal pdf curve overlay
You may also want to look at the rootogram function in the vcd package. You could also use the updateusr function in the TeachingDemos package to reset the y-scale before plotting the curve (works well if you just want the shape of the curve, probably more work than the other suggestions if you want the areas to match). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Jacques Wagnor Sent: Saturday, May 09, 2009 11:04 AM To: ted.hard...@manchester.ac.uk Cc: r-help@r-project.org Subject: Re: [R] Histogram frequencies with a normal pdf curve overlay Thank you! On Sat, May 9, 2009 at 11:31 AM, Ted Harding ted.hard...@manchester.ac.uk wrote: On 09-May-09 16:10:42, Jacques Wagnor wrote: Dear List, When I plot a histogram with 'freq=FALSE' and overlay the histogram with a normal pdf curve, everything looks as expected, as follows: x - rnorm(1000) hist(x, freq=FALSE) curve(dnorm(x), add=TRUE, col=blue) What do I need to do if I want to show the frequencies (freq=TRUE) with the same normal pdf overlay, so that the plot would still look the same? Regards, Jacques Think first about how you would convert the histogram densities (heights of the bars on the density scale) into histogram frequencies. Density * (bin width) * N = frequency where N = total number in sample. Then all you need to is multiply the Normal density by the same factor. To find out the bin width, take the difference between succesive values of the breaks component of the histogram. One way to do all this is N - 1000 x - rnorm(N) H - hist(x, freq=TRUE) ## This will plot the histogram as well dx - min(diff(H$breaks)) curve(N*dx*dnorm(x), add=TRUE, col=blue) Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 09-May-09 Time: 17:31:03 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading large files quickly; resolved
Rob Steele wrote: I'm finding that readLines() and read.fwf() take nearly two hours to work through a 3.5 GB file, even when reading in large (100 MB) chunks. The unix command wc by contrast processes the same file in three minutes. Is there a faster way to read files in R? Thanks! readChar() is fast. I use strsplit(..., fixed = TRUE) to separate the input data into lines and then use substr() to separate the lines into fields. I do a little light processing and write the result back out with writeChar(). The whole thing takes thirty minutes where read.fwf() took nearly two hours just to read the data. Thanks for the help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R errors when trying to read a file
Colleagues, I have encountered a problem in version 2.9 of R, running in both Vista and OS X. My code is quite lengthy but the critical line is: if (file.exists(FILENAME)) readLines(FILENAME)) This triggers the error: Error in file(con, r) : cannot open the connection Calls: readLines - file Execution halted The file that it is reading is being created on the fly, then eventually deleted. The conditional was used to ensure that the readLines command would be executed only when the file existed. Is it possible that the file is deleted AFTER the conditional is evaluated but before the readLines command is executed? If so, is there any means to prevent an error condition? Any help will be greatly appreciated. Thanks. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help with chisq
Thank you Stephanie. This is perfect! On May 10, 12:34 pm, Stephanie Kovalchik sko...@ucla.edu wrote: JC, If each row are the counts for a 2 x 2 contingency table - so for the ith contingency table you have counts for row 1 c(Y08[i],Z08[i]) and row 2 (Y09[i],Z09[i]) then you could use apply: X - cbind(vdata$Y08,vdata$X08-vdata$Y08,vdata$Y09,vdata$X09-vdata$Y98) f.chisq - function(x){ m - matrix(x,2,2) chisq.test(m)$p.value } apply(X,1,f.chisq) Quoting JC jerome.co...@gmail.com: I am very new to R. I have some data from a CVS stored in vdata with 4 columns labeled: X08, Y08, X09, Y09. I have created two new columns like so: Z08 - (vdata$X08-vdata$Y08) Z09 - (vdata$X09-vdata$Y09) I would like to use chisq.test for each row and output the p-value for each in a stored variable. I don't know how to do it. Can you help? so far I have done it for one row (but I want it done automatically for all my data): chidata=rbind(c(vdata$Y08[1],Z08[1]),c(vdata$Y09[1],Z09[1])) results - chisq.test(chidata) results$p.value I tried removing the [1] and the c() but that didn't work... Any ideas? THANKS! __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Beyond double-precision?
A large chunk of the function below could be replaced with a call to the Reduce function. I don't know if it would be faster, slower, or depend on the situation, but it might make it a little more readable. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Berwin A Turlach Sent: Saturday, May 09, 2009 10:18 AM To: spencerg Cc: r-help@r-project.org; joaks1 Subject: Re: [R] Beyond double-precision? G'day all, On Sat, 09 May 2009 08:01:40 -0700 spencerg spencer.gra...@prodsyse.com wrote: The harmonic mean is exp(mean(logs)). Therefore, log(harmonic mean) = mean(logs). Does this make sense? I think you are talking here about the geometric mean and not the harmonic mean. :) The harmonic mean is a bit more complicated. If x_i are positive values, then the harmonic mean is H= n / (1/x_1 + 1/x_2 + ... + 1/x_n) so log(H) = log(n) - log( 1/x_1 + 1/x_2 + ... + 1/x_n) now log(1/x_i) = -log(x_i) so if log(x_i) is available, the logarithm of the individual terms are easily calculated. But we need to calculate the logarithm of a sum from the logarithms of the individual terms. At the C level R's API has the function logspace_add for such tasks, so it would be easy to do this at the C level. But one could also implement the equivalent of the C routine using R commands. The way to calculate log(x+y) from lx=log(x) and ly=log(y) according to logspace_add is: max(lx,ly) + log1p(exp(-abs(lx-ly))) So the following function may be helpful: logadd - function(x){ logspace_add - function(lx, ly) max(lx, ly) + log1p(exp(-abs(lx-ly))) len_x - length(x) if(len_x 1){ res - logspace_add(x[1], x[2]) if( len_x 2 ){ for(i in 3:len_x) res - logspace_add(res, x[i]) } }else{ res - x } res } R set.seed(1) R x - runif(50) R lx - log(x) R log(1/mean(1/x)) ## logarithm of harmonic mean [1] -1.600885 R log(length(x)) - logadd(-lx) [1] -1.600885 Cheers, Berwin === Full address = Berwin A TurlachTel.: +65 6515 4416 (secr) Dept of Statistics and Applied Probability+65 6515 6650 (self) Faculty of Science FAX : +65 6872 3919 National University of Singapore 6 Science Drive 2, Blk S16, Level 7 e-mail: sta...@nus.edu.sg Singapore 117546http://www.stat.nus.edu.sg/~statba __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Removing any text beginning with...
Is this what you want (using regular expressions): x - ENSG /// ENSGy /// ENSG sub(^([[:alpha:]]+).*, \\1 file://0.0.0.1/, x) [1] ENSG On Mon, May 11, 2009 at 9:01 AM, Amélie Baud ameli...@yahoo.fr wrote: Hi ! From an Ensembl annotation like ENSG /// ENSGy /// ENSG, I am trying to keep only the first part: ENSG. I wasn't able to find any helpful information about how to do it. Could you help me with that please ? Is the use of the equivalent to the Excel * (any text) a good way of doing it and how ? Your help will be very much appreciated. Amelie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] working with groups of labels?
It seems that the structure of your data is that you have two groups (Real Bad Stuff and Other Crazy Things) which are then subdivided into further categories. I'd be tempted to set your data up like this: dfr - data.frame( score=c(23, 14, 17, 8, 43, 13), group=rep(c(Real Bad Stuff, Other Crazy Things), each=3), variable=c(Real,Bad,Stuff,Other,Crazy,Things)) Then you can use a lattice plot to emphasise the different groups, and avoid your mtext worries. library(lattice) barchart( variable~score|group, data=dfr, horizontal=TRUE, layout=c(1,2), scales=list(y=list(relation=free)), prepanel=function(x,y,...) { y - y[,drop=TRUE] prepanel.default.bwplot(x,y,...) }, panel=function(x,y,...) { y - y[,drop=TRUE] panel.barchart(x,y,...) } ) (The scales, prepanel and panel arguments are just to get rid of the variables that appear in one group but not the other.) I realise it isn't exactly what you asked for, but I thought you might be interested in the alternate approach. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems to run SVM regression with e1071
Is the variable st character or a factor? What does str(train$st) show? -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R errors when trying to read a file
On Mon, 11 May 2009, Dennis Fisher wrote: Colleagues, I have encountered a problem in version 2.9 of R, running in both Vista and OS X. My code is quite lengthy but the critical line is: if (file.exists(FILENAME)) readLines(FILENAME)) This triggers the error: Error in file(con, r) : cannot open the connection Calls: readLines - file Execution halted The file that it is reading is being created on the fly, then eventually deleted. The conditional was used to ensure that the readLines command would be executed only when the file existed. Is it possible that the file is deleted AFTER the conditional is evaluated but before the readLines command is executed? If so, is there any means to prevent an error condition? It is possible. But so are a lot of other things, and your pretest is just not enough -- for example another process might have the file open for exclusive access (quite common in the Windows world) in which case it exists but you cannot open it for reading. There is only one sure way to find out if you can read a file, and that is to try to read it. So I'd simply use try() or tryCatch() on the readLines call. Any help will be greatly appreciated. Thanks. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] predict function the other way around
Why not use the x=T and y=T paramemters and see if : linearmodel=lm(y~x, x=T, y=T)linearmodel$model (linearmodel$model) y x 1 2 1 2 4 2 3 6 3 4 8 4 5 10 5 give you useful results. If you want to interpolate or extrapolate, then search for threads regarding those tasks. -- David Winsemius On May 11, 2009, at 11:20 AM, Gerrit Voigt wrote: Dear List, Consider the following example x=c(1,2,3,4,5) y=c(2,4,6,8,10) linearmodel=lm(y~x) To predict a y-value if you know the corresponding x value is very easy with the command predict. predict(linearmodel, newdata=(x=1.5)) The other way around, to predict an x-value with a corresponding y- value, doesn't work unfortunately. Is there another function that can do that, or do I need to solve that problem the classical way? Thanks in advance Gerrit Voigt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] anyone know how to calculate chi square value from P value?
Dear all, I have P value of a list of markers. Now I need the chi square value with degrees of freedom 2. I noticed there are several Chisquare functions (dchisq, pchisq, qchisq, and rchisq), but it seems all are not for my purpose. In microsoft excel, there is a function CHINV to do this, such as CHINV(0.184, 2) is 3.386, that means the chi square value for P value 0.184, degree 2 is 3.386. Does the R package has some function to do this? Thanks Anyuan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot bivariate joint pdf
On May 11, 2009, at 9:46 AM, Ben Bolker wrote: beetle2 wrote: For a homework question. I was wondering if rcmdr has a function to plot a graph of a bivariate function of X and Y. I have a function with joint pdf fX,Y(x,y) = x+y for 0x1 , 0y1 I've tried x - seq(0,1,.001) y - seq(0,1,.001) r = x+y plot(r) but it seems to just add them together say .2+.2 .3+.3 not other possibilities like .9 + .1 We don't do homework questions here, but a few hints: (1) the question doesn't seem to be fully specified. Are x and y supposed to be uniform? (2) you could get a reasonable representation of the solution (although not necessarily one your prof would be happy with) by adding runif(1,0,1) and runif(1,0,1) (3) to do this analytically, think about convolutions and/or moment generating functions. (4) ?integrate and search on double integration. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anyone know how to calculate chi square value from P value?
On 5/11/2009 3:36 PM, Anyuan Guo wrote: Dear all, I have P value of a list of markers. Now I need the chi square value with degrees of freedom 2. I noticed there are several Chisquare functions (dchisq, pchisq, qchisq, and rchisq), but it seems all are not for my purpose. In microsoft excel, there is a function CHINV to do this, such as CHINV(0.184, 2) is 3.386, that means the chi square value for P value 0.184, degree 2 is 3.386. Does the R package has some function to do this? qchisq(0.184, df=2, lower=FALSE) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Partial correlation function required
-- Forwarded message -- From: r-help-boun...@r-project.org Date: Mon, May 11, 2009 at 10:24 PM Subject: The results of your email commands To: das.moumita.onl...@gmail.com The results of your email command are provided below. Attached is your original message. - Results: Ignoring non-text/plain MIME parts - Unprocessed: What is the function for partial correlation.The function which i found here:-- http://www.yilab.gatech.edu/pcor.Rand used the recursive version, showed errors while computing partial correlation,where the third variable i.e controlled variable for a pair is more than that .That is when i had more than one third variable ,it always became an infinite loop,it else. # By using recursive formula pcor.rec - function(x,y,z,method=p,na.rm=T){ # x - c(x) y - c(y) z - as.data.frame(z) if(dim(z)[2] == 0){ stop(There should be given data\n) } data - data.frame(x,y,z) if(na.rm == T){ data = na.omit(data) } - Ignored: # recursive formula if(dim(z)[2] == 1){ tdata - na.omit(data.frame(data[,1],data[,2])) rxy - cor(tdata[,1],tdata[,2],m=method) tdata - na.omit(data.frame(data[,1],data[,-c(1,2)])) rxz - cor(tdata[,1],tdata[,2],m=method) tdata - na.omit(data.frame(data[,2],data[,-c(1,2)])) ryz - cor(tdata[,1],tdata[,2],m=method) rxy.z - (rxy - rxz*ryz)/( sqrt(1-rxz^2)*sqrt(1-ryz^2) ) return(rxy.z) }else{ x - c(data[,1]) y - c(data[,2]) z0 - c(data[,3]) zc - as.data.frame(data[,-c(1,2,3)]) rxy.zc - pcor.rec(x,y,zc,method=method,na.rm=na.rm) rxz0.zc - pcor.rec(x,z0,zc,method=method,na.rm=na.rm) ryz0.zc - pcor.rec(y,z0,zc,method=method,na.rm=na.rm) rxy.z - (rxy.zc - rxz0.zc*ryz0.zc)/( sqrt(1-rxz0.zc^2)*sqrt(1-ryz0.zc^2) ) return(rxy.z) } } and this piece of code also i tried to use. Rinv - solve http://wiki.r-project.org/rwiki/rhelp.php?id=solve(R) D - diag http://wiki.r-project.org/rwiki/rhelp.php?id=diag(1 / sqrt http://wiki.r-project.org/rwiki/rhelp.php?id=sqrt(diag http://wiki.r-project.org/rwiki/rhelp.php?id=diag(Rinv))) P - -D http://wiki.r-project.org/rwiki/rhelp.php?id=D %*% Rinv %*% D http://wiki.r-project.org/rwiki/rhelp.php?id=D where R is teh correlation matrix. but NaN error at for sqrt http://wiki.r-project.org/rwiki/rhelp.php?id=sqrt(diag http://wiki.r-project.org/rwiki/rhelp.php?id=diag(Rinv) were generated. http://wiki.r-project.org/rwiki/doku.php?id=tips:data-matrices:part_corrs=correlation Any convinient function for partial correlation for both one controlled variable or more. -- Thanks Moumita - Done. -- Forwarded message -- From: Moumita Das das.moumita.onl...@gmail.com To: r-help-requ...@r-project.org Date: Mon, 11 May 2009 22:23:33 +0530 Subject: partial correlation function Hi friends, What is the function for partial correlation.The function which i found here:-- http://www.yilab.gatech.edu/pcor.Rand used the recursive version, showed errors while computing partial correlation,where the third variable i.e controlled variable for a pair is more than that .That is when i had more than one third variable ,it always became an infinite loop,it else. # By using recursive formula pcor.rec - function(x,y,z,method=p,na.rm=T){ # x - c(x) y - c(y) z - as.data.frame(z) if(dim(z)[2] == 0){ stop(There should be given data\n) } data - data.frame(x,y,z) if(na.rm == T){ data = na.omit(data) } # recursive formula if(dim(z)[2] == 1){ tdata - na.omit(data.frame(data[,1],data[,2])) rxy - cor(tdata[,1],tdata[,2],m=method) tdata - na.omit(data.frame(data[,1],data[,-c(1,2)])) rxz - cor(tdata[,1],tdata[,2],m=method) tdata - na.omit(data.frame(data[,2],data[,-c(1,2)])) ryz - cor(tdata[,1],tdata[,2],m=method) rxy.z - (rxy - rxz*ryz)/( sqrt(1-rxz^2)*sqrt(1-ryz^2) ) return(rxy.z) }else{ x - c(data[,1]) y - c(data[,2]) z0 - c(data[,3]) zc - as.data.frame(data[,-c(1,2,3)]) rxy.zc - pcor.rec(x,y,zc,method=method,na.rm=na.rm) rxz0.zc - pcor.rec(x,z0,zc,method=method,na.rm=na.rm) ryz0.zc - pcor.rec(y,z0,zc,method=method,na.rm=na.rm) rxy.z - (rxy.zc - rxz0.zc*ryz0.zc)/( sqrt(1-rxz0.zc^2)*sqrt(1-ryz0.zc^2) ) return(rxy.z) } }
Re: [R] Plotting colors on a world map
On 5/11/2009 10:32 AM, dxc13 wrote: Hi useR's I have created a simple map of the world using the following code: m - map(xlim=c(-180,180), ylim=c(-90,90)) map.axes() I then create a grid of dimension 36x72 using the code: map.grid(m, nx=72, ny=36, labels=FALSE, col=black) This gives 2592 grid cells. In a separate data set of dimension 36x72, I have 2592 temperature values (some missing values are present) ranging from -20 degrees F to 90 degrees F. My question is, how can I create a reasonable color scheme (low temperatures in light blue to higher temperatures in dark red) and plot the temperature colors in their respective grid cells on the map? Take this data matrix as some example data: T - sample(-10:90, 2592, replace=TRUE) mat - matrix(T, nrow=36, ncol=72) The colorspace package can make nice color sequences for this sort of thing, and image() can add them to a plot. In colorspace, look at the examples for diverge_hcl. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anyone know how to calculate chi square value from P value?
On Mon, 2009-05-11 at 12:36 -0700, Anyuan Guo wrote: Dear all, I have P value of a list of markers. Now I need the chi square value with degrees of freedom 2. I noticed there are several Chisquare functions (dchisq, pchisq, qchisq, and rchisq), but it seems all are not for my purpose. In microsoft excel, there is a function CHINV to do this, such as CHINV(0.184, 2) is 3.386, that means the chi square value for P value 0.184, degree 2 is 3.386. Does the R package has some function to do this? Thanks Anyuan It never hurts to read the documentation: ?qchisq for example. Here q stands for quantile. You want the Chi-square value that has 0.184 area to the left. To compute this: qchisq(1-0.184,2) [1] 3.385639 You have to subtract 0.184 from 1, because qchisq finds the value with the given area below it. To double check the result: 1-pchisq(3.385639,2) [1] 0.184 Rick B. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hoe to get RESIDUAL VARIANCE in logistic regression using lmer
Thank you very much Mr Onkelinx, I appreciated your answer. I'm sorry about my lack of knowledge on this subject, but I don't understand why residual variance is fixed at 1 with the binomial family and I didn't manage to find any exhaustive explanation for that. May you kindly suggest me some reference I can consult in order to go into depth on this matter? Does anybody else can profide me furher information about this topic? Thank you very much. Best regards, Tommaso Alestra ONKELINX, Thierry wrote: Dear Tommaso, The residuals variance is fixed at 1 with the binomial family. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens tomal Verzonden: donderdag 30 april 2009 12:10 Aan: r-help@r-project.org Onderwerp: [R] Hoe to get RESIDUAL VARIANCE in logistic regression using lmer Hello everybody, using the lmer function, I have fitted the following logistic mixed regression model on an experimental data set containing one fixed factor (Cond) and three random variables (Sito, Area, Trans): model-lmer(Caul~Cond+(1|Sito)+(1|Area)+(1|Trans), data=dataset, family=binomial) this is the output: summary(model) Generalized linear mixed model fit by the Laplace approximation Formula: Caul ~ Cond + (1 | Sito) + (1 | Area) + (1 | Trans) Data: dataset AIC BIC logLik deviance 548.7 573.7 -268.3536.7 Random effects: Groups NameVariance Std.Dev. Trans (Intercept) 3.2313398 1.797593 Area (Intercept) 0.000 0.00 Sito (Intercept) 0.0047151 0.068667 Number of obs: 480, groups: Trans, 48; Area, 12; Sito, 2 As you can see the residual variance is missing. Can anybody tell me why? Does anybody know how can I get it? Thank you for your attention, I wish somebody can help me. Have a nice day, best regards, Tommaso Alestra -- View this message in context: http://www.nabble.com/Hoe-to-get-RESIDUAL-VARIANCE-in-logistic-regressio n-using-lmer-tp23313330p23313330.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-get-RESIDUAL-VARIANCE-in-logistic-regression-using-lmer-tp23313330p23487103.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hoe to get RESIDUAL VARIANCE in logistic regression using lmer
Thank you very much Mr Onkelinx, I appreciated your answer. I'm sorry about my lack of knowledge on this subject, but I don't understand why residual variance is fixed at 1 with the binomial family and I didn't manage to find any exhaustive explanation for that. May you kindly suggest me some reference I can consult in order to go into depth on this matter? Does anybody else can provide me furher information about this topic? Thank you very much. Best regards, Tommaso Alestra ONKELINX, Thierry wrote: Dear Tommaso, The residuals variance is fixed at 1 with the binomial family. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens tomal Verzonden: donderdag 30 april 2009 12:10 Aan: r-help@r-project.org Onderwerp: [R] Hoe to get RESIDUAL VARIANCE in logistic regression using lmer Hello everybody, using the lmer function, I have fitted the following logistic mixed regression model on an experimental data set containing one fixed factor (Cond) and three random variables (Sito, Area, Trans): model-lmer(Caul~Cond+(1|Sito)+(1|Area)+(1|Trans), data=dataset, family=binomial) this is the output: summary(model) Generalized linear mixed model fit by the Laplace approximation Formula: Caul ~ Cond + (1 | Sito) + (1 | Area) + (1 | Trans) Data: dataset AIC BIC logLik deviance 548.7 573.7 -268.3536.7 Random effects: Groups NameVariance Std.Dev. Trans (Intercept) 3.2313398 1.797593 Area (Intercept) 0.000 0.00 Sito (Intercept) 0.0047151 0.068667 Number of obs: 480, groups: Trans, 48; Area, 12; Sito, 2 As you can see the residual variance is missing. Can anybody tell me why? Does anybody know how can I get it? Thank you for your attention, I wish somebody can help me. Have a nice day, best regards, Tommaso Alestra -- View this message in context: http://www.nabble.com/Hoe-to-get-RESIDUAL-VARIANCE-in-logistic-regressio n-using-lmer-tp23313330p23313330.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-get-RESIDUAL-VARIANCE-in-logistic-regression-using-lmer-tp23313330p23487104.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] anyone know how to calculate chi square value from P val
On 11-May-09 19:36:00, Anyuan Guo wrote: Dear all, I have P value of a list of markers. Now I need the chi square value with degrees of freedom 2. I noticed there are several Chisquare functions (dchisq, pchisq, qchisq, and rchisq), but it seems all are not for my purpose. In microsoft excel, there is a function CHINV to do this, such as CHINV(0.184, 2) is 3.386, that means the chi square value for P value 0.184, degree 2 is 3.386. Does the R package has some function to do this? Thanks Anyuan Yes, and you already looked at it but apparently did not recognise it! Either: qchisq(1-0.184, 2) ## (note 1-0.184, since 0.184 is the upper tail) # [1] 3.385639 Or: qchisq(0.184, 2, lower.tail=FALSE) ## Default for lower.tail is TRUE # [1] 3.385639 Enter ?qchisq for more informatio0n on this and related function. Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-May-09 Time: 18:15:34 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in NLME (nonlinear mixed effects model)
Hi there, I have been trying to fit an NLME to my data. My dataset has two category levels - one is a fixed effect (level1) and one is a random effect (level2), though so far I have only experimented with the highest level grouping (fixed, level1), with the following code: mod1 - nlme(H ~ a*(1-exp(-b*D^c)), data=sizes, fixed=a+b+c~factor(Loc), start=c(a=75,b=0.05,c=0.7)) This returns the error: Error in getGroups.data.frame(dataMix, eval(parse(text = paste(~1, deparse(groups[[2]]), : Invalid formula for groups Other points that it may be useful to note in diagnosing the problem are that: 1) I have tried both specifying Loc=as.factor and not specifying this. 2) I have tried other configurations of writing fixed=list(...) or fixed=c(...) and that always generates an error 3) I have not specified groupedData 4) My groups do not have equal sample sizes (unbalanced?) Look forward to hearing back! Thanks in advance, Lindsay __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] robustbase: cannot install
This is really odd, I've installed the binary of robustbase through synaptic on an ubuntu 8.04 machine and get: library(robustbase) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib/R/site-library/robustbase/libs/robustbase.so': libRlapack.so: cannot open shared object file: No such file or directory Error: package/namespace load failed for 'robustbase' The package is where it is suposed to be: /usr/lib/R/site-library/robustbase is this not a problem at compiling? The problem is that if I try to install the source with install.packages(robustbase), I get: gcc -std=gnu99 -shared -o robustbase.so R-rng4ftn.o init.o lmrob.o mc.o qn_sn.o rf-common.o rffastmcd.o rfltsreg.o wgt_himed.o -L/usr/lib/R/lib -lRlapack -lblas -L/usr/lib/gcc/i486-linux-gnu/4.2 -lgfortran -lm -L/usr/lib/gcc/i486-linux-gnu/4.2 -lgfortran -lm -L/usr/lib/R/lib -lR /usr/bin/ld: cannot find -lRlapack collect2: ld returned 1 exit status Despite the fact that I do have Rlapack: ~$ R CMD config LAPACK_LIBS -L/usr/lib/R/lib -lRlapack Am I doing something wrong? Thanks Agus -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: agustin.l...@ija.csic.es http://www.ija.csic.es/gt/obster __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] maxLik package
Hi all. Recently i have been used maxlik package for optimizing a function with 5 parameters but i couldn't define gradient argument in function maxLik; How i can define a command to receive my goal? Whether I can change the core of this package? Thanks for your attention and reply A. kheradmandi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Do you use R for data manipulation?
I am not a statistician and not a computer scientist by education. I consider myself an R novice and came to R - thanks to my boss - from an SPSS background. I work for a market research company and the most typical data files we deal with are not huge - up to several thousand rows and up to a thousand variables. I would say, on certain projects, most of what we do in R (if you look at the number of lines in R we devote to a given task) is data manipulation. The actual statistical method is frequently just a line - all the rest is getting the data shaped right and then spitting out the results of the analysis in a way that is usable (i.e., presentable). I find R to be excellent in data manipulations that we perform. First of all, it's great that you can always grab variables/cases you need and ignore all the rest. In SPSS you just keep staring at all those data and variables that you don't need - trying to find the one you need. Second - I find R to be incredibly fast (as opposed to SPSS or Excel) with the amounts of data we are dealing with. And third - nothing is written in stone and your original data is always untouched - you can always read it in again and again. For example, if I create a new variable and make a mistake, I can always fix the code, rerun that piece of the code and that gives me the corrected object that containes that new variable. I never touch the original data and hence - never spoil it. Dimitri On Mon, May 11, 2009 at 11:20 AM, ronggui ronggui.hu...@gmail.com wrote: 2009/5/6 Emmanuel Charpentier charp...@bacbuc.dyndns.org: Le mercredi 06 mai 2009 à 00:22 -0400, Farrel Buchinsky a écrit : Is R an appropriate tool for data manipulation and data reshaping and data organizing? [ Large Snip ! ... ] Depends on what you have to do. I've done what can be more or less termed data management with almost uncountable tools (from Excel (sigh...) to R with SQL, APL, Pascal, C, Basic (in 1982 !), Fortran and even Lisp in passing...). SQL has strong points : join is, to my tastes, more easily expressed in SQL than in most languages, projection and aggregation are natural. However, in SQL, there is no natural ordering of row tables, which makes expressing algorithms using this order difficult. Try for example to express the differences of a time series ... (it can be done, but it is *not* a pretty sight). On the other hand, R has some unique expressive possibilities (reshape() comes to mind). So I tend to use a combination of tools : except for very small samples, I tend to manage my data in SQL and with associated tools (think data editing, for example ; a simple form in OpenOffice's Base is quite easy to create, can handle anything for which an ODBC driver exists, and won't crap out for more than a few hundreds line...). finer manipulation is usually done in R with native tools and sqldf. But, at least in my trade, the ability to handle Excel files is a must (this is considered as a standard for data entry. Sigh ...). So the first task is usually a) import data in an SQL database, and b) prepare some routines to dump SQL tables / R dataframes in Excel tor returning back to the original data author... I don't think Excel is a standard tool for data entry. Epidata entry is much more professional. HTH Emmanuel Charpentier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] consultation
*Dear R Users;* * * *I´m writing to ask you how can I do Survivals Curves using Time-dependent covariates? Which packages I need to Install?* *Thanks for your help, I look foward you reply.* ** *Sincerelly.* ** *Nancy Tejerina.* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building US maps in R
Hi DD, if you have a .shp file (which in principal should exist of the kind of map your describing) you can load into R using this packages: http://r-spatial.sourceforge.net/ In addition, there is also the R-Geo list which is much more suited for this kind of questions: r-sig-...@stat.math.ethz.ch And there is always the book when it comes to R and spatial modeling (Applied Spatial Data Analysis With R): http://www.asdar-book.org/ Best of luck, Stefan On Mon, May 11, 2009 at 3:55 AM, Dirty D dir...@overdetermined.net wrote: Hi, I'm trying to build some maps of the US by county that will have the following characteristics: Feature/Map Map 1 Map2 Both Broken out by county Yes Yes Yes Heatmaps of US Census Data for income by county Yes No Yes Heatmaps of US Census Data for race by county (recoded as white and non-white, with each county color coded based on the majority) No Yes No Polygon markers showing the coordinates of a list of restaurants that have geographical coordinates attached Yes Yes Yes I started learning R a year ago, but had to drop it for work reasons. Is there someone on the list who can help guide me through the process or refer me to /very, very/ detailed instructions and tutorials? Thanks, DD [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in NLME (nonlinear mixed effects model)
Lindsay Banin wrote: Hi there, I have been trying to fit an NLME to my data. My dataset has two category levels - one is a fixed effect (level1) and one is a random effect (level2), though so far I have only experimented with the highest level grouping (fixed, level1), with the following code: mod1 - nlme(H ~ a*(1-exp(-b*D^c)), data=sizes, fixed=a+b+c~factor(Loc), start=c(a=75,b=0.05,c=0.7)) This returns the error: Error in getGroups.data.frame(dataMix, eval(parse(text = paste(~1, deparse(groups[[2]]), : Invalid formula for groups Other points that it may be useful to note in diagnosing the problem are that: 1) I have tried both specifying Loc=as.factor and not specifying this. 2) I have tried other configurations of writing fixed=list(...) or fixed=c(...) and that always generates an error 3) I have not specified groupedData 4) My groups do not have equal sample sizes (unbalanced?) (1) You haven't given us a reproducible example ... (2) You might try asking this on the r-sig-mixed-models list instead (3) I suspect your problem might be that nlme can't fit models with no random effect. Have you tried the analogous model in gnls ? good luck Ben Bolker -- View this message in context: http://www.nabble.com/Error-in-NLME-%28nonlinear-mixed-effects-model%29-tp23488199p23489069.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Do you use R for data manipulation?
Le lundi 11 mai 2009 à 23:20 +0800, ronggui a écrit : [ Snip... ] But, at least in my trade, the ability to handle Excel files is a must (this is considered as a standard for data entry. Sigh ...). [ Re-snip... ] I don't think Excel is a standard tool for data entry. Epidata entry is much more professional. Irony squared ? This *must* go in the fortunes file ! Emmanuel Charpentier __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Warning trying to plot -log(log(survival))
windows xp R 2.8.1 I am trying to plot the -log(log(survival)) to visually test the proportional hazards assumption of a Cox regression. The plot, which should give two lines (one for each treatment) gives only one line and a warning message. I would appreciate help getting two lines, and an explanation of the warning message. My problem may the that I have very few events in one of my strata, but I don't know. Thanks, John fit0-coxph(Surv(Time30,Died)~strata(Rx)+Age,data=GVHDdata) plot(survfit(fit0),fun=cloglog) WARNING: Warning in xy.coords (x, y, xlabel, ylabel, log) : 2 x values =0 omitted from logarithmic plot print(survfit(fit0),fun=cloglog) Call: survfit.coxph(object = fit0) n events median 0.95LCL 0.95UCL Rx=0 31 5Inf Inf Inf Rx=1 32 15Inf1.17 Inf John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] explanation - what does R in the background?
for an undergraduate course in working with R I would like to explain the R-environment and the associated file system. But I am not sure if I have understand all of that correctly myself. Is there a document or a website out there which explains that in an understandable way? Things like; what files are loaded; what the .Rhistory does; what the different graphic devices are etc... (perhaps with a nice graphic or table) thanks für any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] explanation - what does R in the background?
?Startup should help. Bert Gunter Nonclinical Biostatistics 467-7374 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Batholdy Sent: Monday, May 11, 2009 12:53 PM To: r-help@r-project.org Subject: [R] explanation - what does R in the background? for an undergraduate course in working with R I would like to explain the R-environment and the associated file system. But I am not sure if I have understand all of that correctly myself. Is there a document or a website out there which explains that in an understandable way? Things like; what files are loaded; what the .Rhistory does; what the different graphic devices are etc... (perhaps with a nice graphic or table) thanks f|r any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Quantile Regression fixed effects model
Dear R-users, I am applying professor Koenker's code for fixed effect quantile regression. However, I need to bootstrap and cluster the standard errors in my fitted model. Assuming that I need to bootstrap then cluster the standard errors by s (the strata indicator in Prof. Koenker's code), what do I have to do? I tried to bootstrap and cluster using the bootcov command in Design package without any success. If you have used fixed effect quantile regression and were able to bootstrap and cluster, please let me know how the process should be done! With much appreciation, Thuy T. Nguyen see: http://www.econ.uiuc.edu/~roger/research/panel/rq.fit.panel.R url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 -- View this message in context: http://www.nabble.com/Quantile-Regression-fixed-effects-model-tp20506811p23490633.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read many .csv files into an R session automatically, without specifying filenames
Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. Thanks! Mark Na __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read many .csv files into an R session automatically, without specifying filenames
I really dont know hot to use it - but have a look at ?source On Mon, May 11, 2009 at 10:37 PM, Mark Na mtb...@gmail.com wrote: Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. Thanks! Mark Na __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Looking for a quick way to combine rows in a matrix
I'm working with genotype data in a frequency table: a=matrix(1:16, nrow=4) rownames(a)=c(AA,AT,TA,TT) a [,1] [,2] [,3] [,4] AA159 13 AT26 10 14 TA37 11 15 TT48 12 16 'AT' and 'TA' are essentially the same, and I'd like to combine (add) the rows to reflect this. The final matrix should be: [,1] [,2] [,3] [,4] AA159 13 AT513 21 29 TT48 12 16 Is there a fast way to do this? Thanks in advance! Jacy Crosby jacy.r.cro...@uth.tmc.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read many .csv files into an R session automatically, without specifying filenames
Hi, Something like this perhaps: files - dir( pattern = \\.csv$ ) for( x in files){ assign( sub( \\.csv$, , x ) , read.csv(x), envir = .GlobalEnv ) } Romain Mark Na wrote: Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. Thanks! Mark Na -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read many .csv files into an R session automatically, without specifying filenames
Woo, global jinx! On Mon, May 11, 2009 at 1:55 PM, Romain Francois romain.franc...@dbmail.com wrote: Hi, Something like this perhaps: files - dir( pattern = \\.csv$ ) for( x in files){ assign( sub( \\.csv$, , x ) , read.csv(x), envir = .GlobalEnv ) } Romain Mark Na wrote: Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. Thanks! Mark Na -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Beyond double-precision?
On Sat, May 9, 2009 at 12:17 PM, Berwin A Turlach ber...@maths.uwa.edu.au wrote: log(H) = log(n) - log( 1/x_1 + 1/x_2 + ... + 1/x_n) ...But we need to calculate the logarithm of a sum from the logarithms of the individual terms. ...The way to calculate log(x+y) from lx=log(x) and ly=log(y) ... max(lx,ly) + log1p(exp(-abs(lx-ly))) Agreed completely so far. But instead of calculating the logsum pairwise, you can do it all in one go, which is both more efficient and more accurate. Here are some timing and accuracy measurements of the one-shot logsum compared to the loop and the Reduce versions. (Full code at the bottom of this email.) The vector version is much faster and much more accurate in general. There must be cases where the log1p method increases accuracy, but I couldn't find them. -s Large examples to test accuracy and speed Test case: runif(1e+06) function. timeerror 1logsum 0.22 9.31e-16 2 logsum_s 0.15 9.31e-16 3 logsum_r 9.75 3.10e-13 Test case: rexp(1e+06) function. time error 1logsum 0.21 -1.40e-15 2 logsum_s 0.15 -1.40e-15 3 logsum_r 10.13 -1.38e-14 Test case: abs(rnorm(1e+06)) function. time error 1logsum 0.24 -4.38e-16 2 logsum_s 0.14 -4.38e-16 3 logsum_r 10.01 -8.74e-14 Test case: rep(1, 1e+05) function. timeerror 1logsum 0.01 1.46e-16 2 logsum_s 0.01 1.46e-16 3 logsum_r 0.96 6.24e-14 Test case: rep(10^-(1:10), each = 1) function. time error 1logsum 0.02 6.14e-16 2 logsum_s 0.01 6.14e-16 3 logsum_r 0.95 -6.96e-12 More accurate even for small cases Test case: 1:100 function. time error 1logsum0 -3.60e-16 2 logsum_s0 -3.60e-16 3 logsum_r0 3.24e-15 Test case: abs(rnorm(100)) function. time error 1logsum0 -3.48e-16 2 logsum_s0 -3.48e-16 3 logsum_r0 -2.09e-15 ## # Fast, accurate sum in log space # logsum - function(l) { maxi - which.max(l) maxl - l[maxi] maxl + log1p(sum(exp(l[-maxi]-maxl))) } ## ## # Simpler, perhaps less accurate sum in log space # logsum_s - function(l) { maxl - max(l) maxl + log(sum(exp(l-maxl))) } ## # Pairwise reduction logsum_r - function(x) Reduce( function(lx, ly) max(lx, ly) + log1p(exp(-abs(lx-ly))), x ) function_names - c(logsum,logsum_s,logsum_r) logsum_test - function(l) { cat(\nTest case:,deparse(substitute(l)),\n) realsum - sum(l) logl - log(l) results - times - list() lapply( function_names, function(f) times[[f]] - system.time( results[[f]] - getFunction(f)(logl))[1]) data.frame(`function`=function_names, time=as.numeric(times), error=(exp(as.numeric(results))-realsum)/realsum ) } set.seed(1) cat(\n\nLarge examples to test accuracy and speed\n\n) logsum_test(runif(100)) logsum_test(rexp(100)) logsum_test(abs(rnorm(100))) logsum_test(rep(1,10)) logsum_test(rep(10^-(1:10),each=1)) cat(\n\nMore accurate even for small cases\n\n) logsum_test(1:100) logsum_test(abs(rnorm(100))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stepAIC + cox.zph
Hi, I'm using stepAIC with a CoxPH model on some data. As we expect, there are a bunch of predictors, and stepAIC throws some out and then converges on others. Anyway, when I run cox.zph on the final model, I get some evidence of Beta(t) time dependence. Should I be concerned about the impact of this on the entire fit procedure, or is it just that I can't trust the final hazard ratio that the Cox model spits out? Thanks in advance, -Ekr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read many .csv files into an R session automatically, without specifying filenames
Hi, I once made this function (essentially the same as Romain), assignFiles - function (pattern = csv, strip = (_|.csv|-| ), ...) # strip is any pattern you want to remove from the filenames { listFiles - list.files(pattern = pattern, all.files = FALSE, full.names = FALSE, recursive = FALSE) variables - gsub(strip, , listFiles) for (ii in (1:length(listFiles))) { name - listFiles[ii] assign(variables[ii], read.csv(name, ...), env = .GlobalEnv) } } HTH, baptiste On 11 May 2009, at 22:55, Romain Francois wrote: Hi, Something like this perhaps: files - dir( pattern = \\.csv$ ) for( x in files){ assign( sub( \\.csv$, , x ) , read.csv(x), envir = .GlobalEnv ) } Romain Mark Na wrote: Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. Thanks! Mark Na -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Read many .csv files into an R session automatically, without specifying filenames
On 12/05/2009, at 8:41 AM, Andreas Christoffersen wrote: I really dont know hot to use it - but have a look at ?source No; ``source'' is irrelevant here. On Mon, May 11, 2009 at 10:37 PM, Mark Na mtb...@gmail.com wrote: Hi R-helpers, I would like to read into R all the .csv files that are in my working directory, without having to use a read.csv statement for each file. Each .csv would be read into a separate dataframe which would acquire the filename of the .csv. As an example: Mark-read.csv(Mark.csv) ...but the code (or command) would do this automatically for every .csv in the working directory without my specifying each file. I'd appreciate any help or ideas you might have. datalist - list() files - list.files(pattern=\\.csv$) for(file in files) { stem - gsub(\\.csv$,,file) datalist[[stem]] - read.csv(file) } The foregoing does things the *right* way, putting the resulting data sets together into a list whereby they can be accessed in an organized fashion. If you wrong-headedly *insist* on putting the data sets separately into your workspace then do: files - list.files(pattern=\\.csv$) for(file in files) { stem - gsub(\\.csv$,,file) assign(stem,read.csv(file)) } cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Add data count to plot?
Hi I'm a relative newbie to R and had a query concerning plotting. I have generated a par(mfrow = c(2, 2)) graphic with 10 rose diagrams using circular. What I wanted to add to each individual plot was n = x for the number of data observations in each dataset. How might I go about doing this?? Thanks Mike -- View this message in context: http://www.nabble.com/Add-data-count-to-plot--tp23491681p23491681.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] inconsistent results for axis.POSIXct
Some time ago, I posted a note about what I considered to be a bug in axis.POSIXt() for R 2.8.x, relating to whether timezones in the data are obeyed on the axes. A link to that note, and to a quick and helpful response, is at the following URL http://www.nabble.com/patch-for-axis.POSIXct-%28related-to-timezones%29-td22338700.html#a22338700 Note that R 2.9.0 has been adjusted to help with this. However, there are still problems. Test code is given below: # test code (top panel, OK; bottom panel, incorrect times on x axis) par(mar=c(2,2,2,1)) par(mfrow=c(2,1)) start - as.POSIXct(2008-05-01 00:00:00, tz=UTC) end - as.POSIXct(2008-05-01 00:10:00, tz=UTC) plot(c(start, end), c(0, 1), ylab=) mtext(paste(start, to, end), side=3) start - as.POSIXct(2008-05-01 00:00:00, tz=UTC) end - as.POSIXct(2008-05-01 01:10:00, tz=UTC) plot(c(start, end), c(0, 1), ylab=) mtext(paste(start, to, end), side=3) -- View this message in context: http://www.nabble.com/inconsistent-results-for-axis.POSIXct-tp23492108p23492108.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Set working directory by dragging text file onto R shortcut? [WinXP, unfortunately]
Hi R-helpers, I must use WinXP at work, and I'm missing a particular feature that's available in R on my Mac at home... In WinXP I would like to launch R by dragging and releasing a text file on top of the R shortcut on my desktop. Then, I would like the working directory to be automatically set to the location of that text file. That's what works in MacOS, but I can't figure out if it's possible in WinXP. Any ideas? I'd appreciate it... Thanks, Mark Na PS What I do now is make a new R shortcut for each project, store that shortcut in the directory containing that project's datafiles and R programs (which are in text files), and set the Start in value to that directory...but this has to be set up uniquely for each project... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and McAfee 8.5
On Mon, 2009-05-11 at 09:54 -0300, Joyce, Warren wrote: Hi, I have been working with R for the last year and using the UKFSST package to look at satellite tag track data and SST information. Fpr those not familiar, the package uses the positions estimated by the satellite tags themselves and the associated SST data from servers (in this case, from the University of Hawaii and the NOAA Coastwatch website) for the time preiod to estimate a reasonable track the animal took while it was at liberty. I'm currently having trouble downloading data from two different servers which I never had a problem before I recevied an upgraded computer with McAfee 8.5. When the package goes to the various servers for SST information to download, I continue to get a message in R: (...) Into my web browser, I get prompted with a file download window which quickly downloads an empty file. It looks like the data is available, I just can't seem to download it. I've deduced that it must be a problem with the new firewall features of McAfee 8.5 and was wondering if anyone else has run into a problem like this. I've tried using the exclusions options in 8.5 to exclude any R files but have come up empty handed. Still waiting on our informatics division to try and solve the problem as well but I thought I might try asking here as well. Thanks and I appreciate any assistance! Warren N. Joyce Hi Joice, In my opinion you need think about 2 things. 1- This is a problem of McAfee 8.5 not a R problem, so do you contact a McAfee support for fix this problem ? 2- I presume you use a windows but i do know your version (XP or Vista or win 95 etc) neither your R configuration (do you use R --internet2 or not?) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Set working directory by dragging text file onto R shortcut? [WinXP, unfortunately]
There are a several possibilities using batchfiles whose home page is at: http://batchfiles.googlecode.com When on that home page note that there are different versions of these utilities for XP and Vista. There are two utilities that could be used. Description is for Vista so for XP you may have to vary it slightly. 1. RguiStart.bat is a batch file that starts R interpreting its first argument as the folder in which to start R (or if its an .Rdata file then it interprets it as the .Rdata file to start R with). The main reason for its existence is so that you can place it in your SendTo folder. On Vista do this: copy RguiStart.bat %APPDATA%\Microsoft\Windows\SendTo Then, on Vista, when you are in Windows Explorer you can right click on any folder in your user area and choose SendTo. From the SendTo menu choose RGuiStart.bat to start up R in that folder. If you right click on an .Rdata file rather than a folder then R will start up with that file loaded (although in that case its probably easier to just double click the .Rdata file provided you have file type associations set up -- if you don't then the RguiStart.bat will provide an alternative). 2. Rgui.bat is a batch file that starts up R. Just shift right click a folder in Windows Explorer and choose Open Command Window Here and then when the command window opens enter Rgui assuming you have placed Rgui.bat somewhere on your path. Note that Rgui.bat and RguiStart.bat are actually the same file just renamed. When it runs it uses the name by which it was called to determine what to do. The files have no dependencies and find R by looking in the registry so when you install a new version of R they continue to work without any change (because installing a new version of R updates the registry). On Mon, May 11, 2009 at 6:30 PM, Mark Na mtb...@gmail.com wrote: Hi R-helpers, I must use WinXP at work, and I'm missing a particular feature that's available in R on my Mac at home... In WinXP I would like to launch R by dragging and releasing a text file on top of the R shortcut on my desktop. Then, I would like the working directory to be automatically set to the location of that text file. That's what works in MacOS, but I can't figure out if it's possible in WinXP. Any ideas? I'd appreciate it... Thanks, Mark Na PS What I do now is make a new R shortcut for each project, store that shortcut in the directory containing that project's datafiles and R programs (which are in text files), and set the Start in value to that directory...but this has to be set up uniquely for each project... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.