Re: [R] creating R packs for all
On Fri, 23-Mar-2007 at 06:00PM +, Prof Brian Ripley wrote: | On Fri, 23 Mar 2007, Erin Hodgess wrote: | | Dear R People: | | I am in the process of creating an R package via Windows. | | If I would decide to submit in to CRAN, what would I need to | do in order to make it run for the Linux or Mac People, please? | | If it passes R CMD check on Windows it should work anywhere. About | the only thing that is fussier on Unix than Windows is the use of | the correct line endings for C etc files. (OTOH, Windows adds | restrictions that 'R CMD check' checks for Unix users.) There are graphics functions that can be called in platform specific ways. Hard-wired coding that calls a default plotting device with unnamed arguments can make no sense on another platform. Using Linux, one gets: args(x11) function (display = , width = 7, height = 7, pointsize = 12, gamma = getOption(gamma), colortype = getOption(X11colortype), maxcubesize = 256, bg = transparent, canvas = white, fonts = getOption(X11fonts), xpos = NA, ypos = NA) Using Windows, the first argument is absent so code that assumes arguments are in the same order (say by not using names) irrespective of platform will fail even though R CMD check looks fine. Perhaps it could all be summed up by a general problem with hard-wired graphics calls (such as WMF files). From my limited experience they would not be that difficult to avoid. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] BRugs command modelGenInits() crashes R version 2.4.1 (windows)
Mark Fisher wrote: Is it appropriate to ask about this here? (I didn't see anything in the FAQ.) Can you please send me (the package maintainer) a reproducible example that crashes R in a private message? Thanks, Uwe Ligges --Mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using alpha transparency for lines in levelplot
Hello, I'm having trouble with using the alpha channel for transparency with lines with lattice levelplots. If I use transparency via the alpha argument to rgb to overplot lines on levelplot the transparent colour affects all of the region colours in the plot. Can anyone explain why the difference in region colours? Warning: this code attempts to create PDF files in working directory - they may be downloaded, see below library(lattice) ## prepare data data(volcano) xy - expand.grid(x = 1:nrow(volcano), y = 1:ncol(volcano)) xy$z - as.vector(volcano) ## panel function to add lines with grey(0.3) my.panel - function(...) { panel.contourplot(...); panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = grey(0.3)) } ## this works fine pdf(plot.pdf, version = 1.4) levelplot(z~x+y, xy, panel = my.panel) dev.off() ## panel function to add lines with grey transparency my.paneltransp - function(...) { panel.contourplot(...); panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = rgb(0.3, 0.3, 0.3, 0.5)) } ## this results in grey bleeding on the coloured regions of the plot pdf(alpha.pdf, version = 1.4) levelplot(z~x+y, xy, panel = my.paneltransp) dev.off() I've put the pdfs created here for reference: http://staff.acecrc.org.au/~mdsumner/R/ Cheers, Mike. I'm using Windows XP, SP2: sessionInfo() R version 2.4.1 (2006-12-18) i386-pc-mingw32 locale: LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MONETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: lattice 0.14-16 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing R on a machine with 64-bit Opteron processors
Stan, On Sun, 25 Mar 2007 13:36:47 -0400 Stan Horwitz [EMAIL PROTECTED] wrote: I have been tasked with installing statistical and other data analysis applications on a new Sun Fire X4600 M2 x64 server that came equipped with eight AMD dual core Opteronn 64-bit processors. It is running the 64-bit version of Suse Linux 9. the oldest version for which rpms are provided at the moment is 9.3 . If you have something older you need to recompile yourself. Normally you just do the usual configure and make stuff and everything falls in place. Nevertheless you need to install some libraries for that to work, too. If you can not use yast2 and use the installation source given in the ReadMe you can find out with rpm -q --whatprovides name_of_your_missing_dependency what to install. Hope that helps. Detlef I have read through the installation docs, and I guess I don't understand what to do, or even how to identify which version, if any, of this software is suitable for my computer environment. What I want to know is if R has been ported to that environment and if so, how do I install it? I tried downloading it from one of the mirror web sites, and when I install it, I get euler src/R-base-2.4.1# rpm -i R-base-2.4.1-2.1.i586.rpm warning: R-base-2.4.1-2.1.i586.rpm: V3 DSA signature: NOKEY, key ID 6b9d6523 error: Failed dependencies: xorg-x11-fonts-100dpi is needed by R-base-2.4.1-2.1 xorg-x11-fonts-75dpi is needed by R-base-2.4.1-2.1 xorg-x11-libs is needed by R-base-2.4.1-2.1 blas is needed by R-base-2.4.1-2.1 libreadline.so.5 is needed by R-base-2.4.1-2.1 euler src/R-base-2.4.1# I also tried the x386 version with the same results. The documentation lists some prerequisite items to install such as blas, but I have searched and I can't see to locate that software. Is it public domain or a commercial product? I also see that my server already has x11 fonts installed, so I don't know what those errors are about. Here's what rpm says about fonts ... fontconfig-2.2.92.20040221-28.13 fontconfig-32bit-9-200407011229 fontconfig-devel-32bit-9-200407011229 ghostscript-fonts-other-7.07.1rc1-195.8 XFree86-fonts-75dpi-4.3.99.902-43.71 fontforge-20060715-7.3 ghostscript-fonts-std-7.07.1rc1-195.8 fontconfig-devel-2.2.92.20040221-28.13 xorg-x11-fonts-scalable-6.9.0-48 efont-unicode-0.4.0-630.1 So isn't xorg-x11-fonts-scalable-6.9.0-48 what it wants? I guess not. Is there a list of what this software needs AND where to download or purchase each item for Suse 9? I am also wondering if this list has searchable archives? The list's web site shows archived postings, but I don't see a way to search them. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Die Dinge beim richtigen Namen nennen, ist der erste bedeutende revolutionäre Akt. Rosa Luxemburg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling from the uniform distribution over a convex hu
On 26-Mar-07 01:05:41, Adrian Baddeley wrote: Ranjan Maitra writes: Does anyone have a suggestion (or better still) code for sampling from the uniform distribution over the convex hull of a set of points? This is implemented in library 'spatstat'. If x and y are vectors of coordinates of your initial set of points, library(spatstat) W - convexhull.xy(x, y) P - runifpoint(42, W) will compute the convex hull and generate 42 independent uniformly-distributed points in the convex hull. Thanks, Adrian! I should have remembered about 'spatstat' after the Baddeley et al. paper to the RSS in June 2005, where the package was extensively used! (Though neither convexhull() nor runifpoint() are in the package I downloaded at the time; but of course things have moved on!). But this brings me to another issue -- It seems that the R Site Help and Archive Search at http://finzi.psych.upenn.edu has been belly-up since at least Saturday (when I tried to use it to search for relevant material for this query). My browser says connection refused, ping hangs, and traceroute returns !H (host unreachable); and that is still the situation this morning. I hope this is temporary, and not a withdrawal of the service. Anyone in the know? With thanks, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-07 Time: 10:23:57 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] matrix construction
Hallo, can anyone tell me how I can create a matrix in R? I have two arrays A = c(0:3), B=c(0:3). C should be the matrix. I just found the description that a matrix is just an array with two substricpts. Thanks, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix construction
Have a look at ?cbind, ?rbind and ?matrix C - cbind(A, B) C - rbind(A, B) C - matrix(c(0:3, 0:3), ncol = 2) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach 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 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Schmitt, Corinna Verzonden: maandag 26 maart 2007 11:34 Aan: r-help@stat.math.ethz.ch Onderwerp: [R] matrix construction Hallo, can anyone tell me how I can create a matrix in R? I have two arrays A = c(0:3), B=c(0:3). C should be the matrix. I just found the description that a matrix is just an array with two substricpts. Thanks, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem in loading all packages all at once
Hi All Please see the Rprofile file which i have modified as follows and after that when I start R then I see that R says to me TRUE for all the packages implying that all loaded at once. But when i try to use commands as simple as help(lm), it doesnt work nor any of the menu Packages is not working. Although the regression using lm ( Y ~ X ) is working even summary and rnorm is working fine. Please tell me why menu and help command is not working Rprofile is in between +++ lines R initialization is in between @@ lines Commands are in between $ lines Please also suggest me should i send this to r-devel list or not ### This is the system Rprofile file. It is always run on startup. options(scipen = 0) options(max.print = 1)# not yet exercised in 'core R' options(add.smooth = TRUE)# currently only used in 'plot.lm' ## ## #code added by gaurav yadav to install many other packages at startup# print (START OF CODE ADDED BY GAURAV YADAV) TEMP - Sys.getenv(R_DEFAULT_PACKAGES) print (R_DEFAULT_PACKAGES) print (TEMP) print (===) TEMP - c(TEMP,aplpack,approximator,apTreeshape,ArDec,arules,ash,aspace,assist,aster,asypow,aws,base,bayesm,bayesmix,bayesSurv,BayesTree,BayesValidate,betareg,Bhat,BHH2,bicreduc,biglm,bim,bindata,Biodem,biopara,bitops,bivpois,blighty,blockrand,BMA,boa,Bolstad,boolean,boost,boot,bootstrap,bqtl,BradleyTerry,brlr,BRugs,BSDA,BsMD,butler,calibrate,calibrator,caMassClass,car,cat,caTools,catspec,cba,cclust,CDNmoney,cfa,CGIwithR,changeLOS,chplot,chron,CircStats,circular,clac,class,classInt,classPP,clim.pact,climatol,clines,clue,cluster,clusterRepro,clustvarsel,cmprsk,cobs,CoCo,CoCoCg,CoCoCore,CoCoGraph,CoCoObjects,CoCoOldData,CoCoRaw,cocorresp,coda,coin,colorspace,combinat,compositions,concor,concord,cond,conf.design,connectedness,copula,corpcor,corpora,covRobust,coxrobust,cramer,crossdes,crq,c sampling,cslogistic,CTFS,ctv) TEMP - c(TEMP,CVThresh,cwhmath,cwhplot,cwhprint,cwhstat,cwhstring,cwhtool,cyclones,DAAG,datasets,date,Davies,DBI,dblcens,DCluster,DDHFm,deal,debug,deldir,delt,denpro,DEoptim,depmix,DescribeDisplay,Design,Devore5,Devore6,dglm,diamonds,dichromat,DICOM,digest,diptest,dispmod,distr,distrEx,distrSim,distrTEst,diveMove,doBy,DPpackage,dr,drc,drfit,dse1,dse2,dyn,dynamicGraph,dynlm,e1071,eba,EbayesThresh,Ecdat,eco,ecodist,edci,effects,eha,elasticnet,ElemStatLearn,ellipse,elliptic,emme2,emplik,emulator,EMV,energy,ensembleBMA,Epi,epitools,epsi,equivalence,evd,evdbayes,evir,exactLoglinTest,exactmaxsel,exactRankTests,extRemes,FactoMineR,Fahrmeir,far,faraway,fastICA,fBasics,fCalendar,fda,fdim,femmeR,fExtremes,fgac,fields,filehash,financial,FLCore,FLEDA,flexclust,flexmix,fMultivar,fOptions,foreign, FortranCallsR,fortunes,forward) TEMP - c(TEMP,fpc,fPortfolio,fracdiff,frailtypack,fSeries,ftnonpar,FunCluster,fuzzyRankTests,g.data,gafit,gam,gamair,gamlss,gamlss.tr,GammaTest,gap,gbm,gclus,gcmrec,gdata,gee,geepack,genalg,Geneland,GeneNT,genetics,GeneTS,GenKern,geometry,geoR,geoRglm,ggm,ggplot,giRaph,gld,gllm,glmmML,glmpath,glpk,gmodels,gmp,gmt,gnm,GPArotation,gpclib,gplots,gpls,graphics,grasper,GRASS,gRbase,grDevices,gregmisc,grid,gridBase,grnnR,grouped,GroupSeq,gss,gstat,gsubfn,gtools,hapassoc,haplo.ccs,haplo.stats,hapsim,hddplot,hdf5,hdrcde,hett,HI,hier.part,hierfstat,HighProbability,Hmisc,hmm.discnp,homals,hopach,howmany,HSAUR,HTMLapplets,httpRequest,hwde,hybridHclust,HyperbolicDist,ICE,Icens,IDPmisc,ifs,igraph,iid.test,impute,ineq,intcox,iplots,ipred,irr,ismev,ISwR,its,iWidgets,JavaGD,JGR,JLLprod,JointGL M,kappalab,Kendall,kernlab) TEMP - c(TEMP,KernSmooth,kinship,kknn,klaR,km.ci,KMsurv,knncat,knnFinder,knnTree,kohonen,ks,kza,kzft,labdsv,labstatR,lars,lasso2,latentnet,lattice,latticeExtra,lazy,ldbounds,ldDesign,LDheatmap,leaps,lgtdl,limma,linprog,lme4,lmeSplines,LMGene,lmm,lmomco,Lmoments,lmtest,locfdr,locfit,lodplot,LogicReg,logistf,logspline,lokern,longitudinal,longmemo,LoopAnalyst,LowRankQP,lpridge,lpSolve,lsa,lspls,ltm,maanova,magic,mapLD,mapproj,maps,maptools,maptree,mAr,marg,MarkedPointProcess,MASS,Matching,MatchIt,mathgraph,matlab,Matrix,maxstat,MBESS,mblm,mcgibbsit,mclust,mcmc,MCMCpack,mda,MEMSS,merror,meta,methods,mfp,mgcv,mice,micEcdat,micEcon,aaMI,abind,accuracy,acepack,actuar,adapt,ade4,adehabitat,adlift,agce,agsemisc,akima,AlgDesign,allelic,alr3,amap,AMORE,AnalyzeFMRI,aod,ape,mimR,minpack.l m,misc3d,mitools,mix,mixreg) TEMP -
Re: [R] DCOM graphics bug?
Assuming this is about the R (D)COM server from http://cran.r-project.org/contrib/extra/dcom/00ReadMe.html please note that it has its own mailing lists (accessed via the link on that page). You will need to tell people the versions of everything you used (as the R posting guide asked you to). On Sun, 25 Mar 2007, Martin Semmernegg wrote: Hi! I am trying to display a graphic using the dcom server and the dcom graphics object. Works fine without the embedded graphics object, in it's own windows, but if i use the embedded object (what I need to do) the colors are gone. Graphics are always only black and white. Even in the DCOM examples for VB the graphics are without color - is this a bug? Can I do anything about it? Thanks for your help! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] main title in multi-plot
Dear R-gurus, I need to print several plots into a graphic device and I would like to print out a main title. My code looks like x-1:100 y-x^2 z-y/x w-exp(z) par(mfrow=c(2,2)) plot(y~x) plot(z~x) plot(w~x) plot(z~w) Kind regards, miltinho Brazil __ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The Hurst Exponent in fBasic
Dear R users, The function lmacfPlot( ) in fBasics, returns a list including the Hurst Exponent. I get sometimes a value for Hurst Exponent using lmacfPlot bigger than 1 which is theoretically incorrect. What could be reason ? From the related documents, I could not find how the Hurst Exponent in lmacfPlot is estimated. Could you please say how it is estimated here? Thank you so much for help. Amir - always stay connected to friends. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] main title in multi-plot
Use par(oma) for outer margins and then title with outer=TRUE or mtext in the same way. x-1:100 y-x z-y/x w-exp(z) par(oma=c(0,0,2,0)) par(mfrow=c(2,2)) plot(y~x) plot(z~x) plot(w~x) plot(z~w) title(main=Main title,outer=T) - Henrik Milton Cezar Ribeiro wrote: Dear R-gurus, I need to print several plots into a graphic device and I would like to print out a main title. My code looks like x-1:100 y-x^2 z-y/x w-exp(z) par(mfrow=c(2,2)) plot(y~x) plot(z~x) plot(w~x) plot(z~w) Kind regards, miltinho Brazil __ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] a very small query
Hi All what is the command to give me the listing of the loaded packages. I mean which are active and not the listing of all the installed packages as given by library() thanks in advance -gaurav DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] one more small query
Hi All Thanks to you all for replying to my small query i got it. How can i load many packages other than the default packages automatically at the startup. Please tell me. I tried it by modifying the RProfile file, as given in the posted mail with the subject(Problem in loading all packages all at once), but it was not a total success, Please help me in this. Secondly is there any limits set that at a time maximum number of packages which can be loaded at a time. :-) -gaurav Sayonara With Smile With Warm Regards :-) G a u r a v Y a d a v Assistant Manager, Economic Research Surveillance Department, Clearing Corporation Of India Limited. Address: 5th, 6th, 7th Floor, Trade Wing 'C', Kamala City, S.B. Marg, Mumbai - 400 013 Telephone(Office): - +91 022 6663 9398 , Mobile(Personal) (0)9821286118 Email(Office) :- [EMAIL PROTECTED] , Email(Personal) :- [EMAIL PROTECTED] DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a very small query
On Mon, 26 Mar 2007, [EMAIL PROTECTED] wrote: what is the command to give me the listing of the loaded packages. ?search ?sessionInfo (sessionInfo massages the output of search() to show only packages). I mean which are active and not the listing of all the installed packages as given by library() -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Listing function
Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Listing function
Lst - list() Lst[[1]] - list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) Lst[[2]] - list(name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5)) I.e. a list of lists Regards Michael Schmitt, Corinna wrote: Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael T. Mader Institute of Stem Cell Research GSF - National Research Center for Environment and Health Ingolstaedter Landstrasse 1 D-85764 Neuherberg 0049-89-3187-3683 Program testing can be quite effective for showing the presence of bugs, but is hopelessly inadequate for showing their absence. E. W. Dijkstra __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] setting LD_LIBRARY_PATH
Dear R-help, I am trying to use a package (not from CRAN) which includes two shared library (.so) files. The maintainer suggests inserting two lines in /usr/bin/R, LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:path-to-package/lib export LD_LIBRARY_PATH This works, but I felt more comfortable putting the first line in .Renviron or $R_HOME/etc/Renviron.site. However this doesn't seem to work, and I cannot see why it doesn't. School of Biological Sciences, University of Edinburgh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in loading all packages all at once
I really don't know what is going on here, beyond that 'utils' has not been loaded. But 1) You are not supposed to edit system files like library/base/R/Rprofile. If you do, don't ask for help! 2) I don't see how the output shown came from the input shown: almost surely it did not. 3) It is extremely bad practice to load packages you do not need. This both slows R down unnecessarily and creates conflicts where packages override default behaviour. 4) I believe there is still a limit to the number of DLLs you can have loaded in a single R session, and I believe it to be 100. So you probably cannot load all 751 packages, and at some point package loading will fail. Now, loading library/base/R/Rprofile has no error-checking (as it is supposed to be unchanged, src/main/main.c:818) and so you may get no indication of this. So my guess is that there was an attempt to load a few hundred packages and only some of them got loaded, not as far down the list as 'utils'. If you want to load some packages in every session, do so from your .Rprofile file: that is run as user code and you should get full error-checking (and messages). As for Charilaos' points: a) .First.sys is defined in the system profile, library/base/R/Rprofile. It is run from the base environment. b) The environment variable R_DEFAULT_PACKAGES justs sets the default for the option 'defaultPackages', and the format is described in the surely obvious place, the documentation for the option. There are examples in the 'check' script. On Mon, 26 Mar 2007, Charilaos Skiadas wrote: A couple of things: 1) It would have been a lot easier to help you if you had created a much smaller example. perhaps trying to load 2-3 packages instead of 1000. Now we have to wade through a lot of stuff to get to the point. 2) Perhaps your call to Sys.putenv doesn't do quite what you expect it to do. Example: TEMP - c(a,b) Sys.getenv(TEST) TEST Sys.putenv(TEST=TEMP) Sys.getenv(TEST) TEST b 3) I couldn't really see where in your code all these packages are loaded. Reading the help for .First.sys tells me that that's the call that actually loads the default packages, unless I've misunderstood something. If that's the case, then the following line you have at the end would prevent this loading: .First.sys - function() I must say that from the ?Startup help there are two things that are not very clear: a) At what point in the load process is R_DEFAULT_PACKAGES checked? .First.sys doesn't seem to know about it. Ok, a bit of search provided an answer to this: Reading the help for options, I see there, in the section about defaultPackages, what is probably the most helpful bit (for me) in all this: defaultPackages: the packages that are attached by default when R starts up. Initially set from value of the environment variable R_DEFAULT_PACKAGES, or if that is unset to c(datasets, utils, grDevices, graphics, stats, methods). (Set R_DEFAULT_PACKAGES to NULL or a comma-separated list of package names.) A call to options should be in your ?.Rprofile? file to ensure that the change takes effect before the base package is initialized (see Startup). b) What is the format that the R_DEFAULT_PACKAGES variable must have (I guess now I know, since it is mentioned in ?options, though that's not really the place I would have expected it to be explained) ? The only examples I could find on the web were setting it to NULL. Hope all this helps in some way. Haris Skiadas Department of Mathematics and Computer Science Hanover College On Mar 26, 2007, at 6:01 AM, [EMAIL PROTECTED] wrote: Hi All Please see the Rprofile file which i have modified as follows and after that when I start R then I see that R says to me TRUE for all the packages implying that all loaded at once. But when i try to use commands as simple as help(lm), it doesnt work nor any of the menu Packages is not working. Although the regression using lm ( Y ~ X ) is working even summary and rnorm is working fine. Please tell me why menu and help command is not working Rprofile is in between +++ lines R initialization is in between @@ lines Commands are in between $ lines Please also suggest me should i send this to r-devel list or not ### This is the system Rprofile file. It is always run on startup. options(scipen = 0) options(max.print = 1)# not yet exercised in 'core R' options(add.smooth = TRUE)# currently only used in 'plot.lm' ##
Re: [R] sampling from the uniform distribution over a convex hu
Thanks, all, and thanks especially to Ted for your investigations in the other thread with the same title! Does spatstat handle higher dimensions than 2? Best wishes, Ranjan On Mon, 26 Mar 2007 10:31:15 - (BST) (Ted Harding) [EMAIL PROTECTED] wrote: I just wrote: Thanks, Adrian! I should have remembered about 'spatstat' after the Baddeley et al. paper to the RSS in June 2005, where the package was extensively used! (Though neither convexhull() nor runifpoint() are in the package I downloaded at the time; but of course things have moved on!). Apologies -- that last statement is false! Ted. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Listing function
maybe it'd be better to use a data.frame(), e.g., dat - data.frame(name = I(Fred), wife = I(Mary), no.children = 3, cild.ages1 = 4, cild.ages2 = 7, cild.ages3 = 9) ## new.info - c(name = Barney, wife = Liz, no.children=2, cild.ages1 = 3, cild.ages2 = 5, cild.ages3 = NA) rbind(dat, new.info) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Schmitt, Corinna [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, March 26, 2007 3:26 PM Subject: [R] Listing function Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a very small query
Try these: search() sessionInfo() loadedNamespaces() The first two show the attached packages (and some other info) and the last one shows the namespaces that are loaded. Note that detaching a package does not unload its namespace and unloading a namespace does not de-register its methods. This illustrates the behavior: search() [1] .GlobalEnvpackage:stats package:graphics [4] package:grDevices package:utils package:datasets [7] package:methods Autoloads package:base loadedNamespaces() [1] base graphics grDevices methods stats utils as.Date(1) # error as there is no numeric method for as.Date Error in as.Date.default(1) : do not know how to convert '1' to class Date library(zoo) search() [1] .GlobalEnvpackage:zoo package:stats [4] package:graphics package:grDevices package:utils [7] package:datasets package:methods Autoloads [10] package:base loadedNamespaces() [1] base graphics grDevices grid lattice methods [7] stats utils zoo as.Date(1) # zoo defines a numeric method for as.Date [1] 1970-01-02 detach() unloadNamespace(zoo) environment: namespace:zoo search() [1] .GlobalEnvpackage:stats package:graphics [4] package:grDevices package:utils package:datasets [7] package:methods Autoloads package:base loadedNamespaces() [1] base graphics grDevices grid lattice methods [7] stats utils # zoo is gone from attached package list and loadedNamespaces # but numeric method for as.Date from zoo is still registered as.Date(1) [1] 1970-01-02 On 3/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi All what is the command to give me the listing of the loaded packages. I mean which are active and not the listing of all the installed packages as given by library() thanks in advance -gaurav DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Listing function displayed as a table
Hallo, good idea it is working. A new question appears: How can I display the entries in a table like name wife no.children child.ages FredMary3 4,7,9 Barney Liz 2 3,5 Thanks, Corinna -Ursprüngliche Nachricht- Von: Michael T. Mader [mailto:[EMAIL PROTECTED] Gesendet: Montag, 26. März 2007 15:32 An: Schmitt, Corinna; r-help@stat.math.ethz.ch Betreff: Re: [R] Listing function Lst - list() Lst[[1]] - list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) Lst[[2]] - list(name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5)) I.e. a list of lists Regards Michael Schmitt, Corinna wrote: Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael T. Mader Institute of Stem Cell Research GSF - National Research Center for Environment and Health Ingolstaedter Landstrasse 1 D-85764 Neuherberg 0049-89-3187-3683 Program testing can be quite effective for showing the presence of bugs, but is hopelessly inadequate for showing their absence. E. W. Dijkstra __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Listing function
Use c() to extend your list creating a list of lists: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) Lst - c(list(Lst), list(list(name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5 You can give names to the components: Lst - c(Fred=list(Lst), Barney=list(list(name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5 See ?c for more information. You can also use a data.frame if this looks too messy. Petr Schmitt, Corinna napsal(a): Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gam parameter predictions
R-help, I'm applying a gam model (package mgcv) to predict relative abundances of a fish species. The covariates are year, month, vessel and statistical rectangle. The model looks like this: g1 - gam(log(cpue) ~ s(rekt1) + s(year) + s(mon) + s(reg1), data = dataTest) Once the model is fitted to the data I want to get the mean model estimates by year. I do the following: obsPred - data.frame(year = dataTest$year, pred = predict(g1, type = response)) gamFit - tapply(obsPred$pred, list(year = obsPred$ar), mean) Is this correct? Thanks in advance version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.1 year 2006 month 12 day18 svn rev40228 language R version.string R version 2.4.1 (2006-12-18) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Listing function - new possibility
I think your solution is more comfortable. But what do you do if an new entry consists of 4 children? How can you modify the old result of rbind()? Is ther a possibility to save the childrens ages in one table entry? Thanks, Corinna -Ursprüngliche Nachricht- Von: Dimitris Rizopoulos [mailto:[EMAIL PROTECTED] Gesendet: Montag, 26. März 2007 15:38 An: Schmitt, Corinna Cc: r-help@stat.math.ethz.ch Betreff: Re: [R] Listing function maybe it'd be better to use a data.frame(), e.g., dat - data.frame(name = I(Fred), wife = I(Mary), no.children = 3, cild.ages1 = 4, cild.ages2 = 7, cild.ages3 = 9) ## new.info - c(name = Barney, wife = Liz, no.children=2, cild.ages1 = 3, cild.ages2 = 5, cild.ages3 = NA) rbind(dat, new.info) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Schmitt, Corinna [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, March 26, 2007 3:26 PM Subject: [R] Listing function Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem in loading all packages all at once
Prof Brian Ripley [EMAIL PROTECTED] 26-03-07 07:06 PM To Charilaos Skiadas [EMAIL PROTECTED] cc [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject Re: [R] Problem in loading all packages all at once I really don't know what is going on here, beyond that 'utils' has not been loaded. @@@ Please :-), no sky is falling, just kidding But 1) You are not supposed to edit system files like library/base/R/Rprofile. If you do, don't ask for help! @@@ let me dare, and i will learn. I apologize if i have hurt your feelings. @@@ i used to modify the linux operating system code to see the effects, @@@ bad habits die hard. Please forgive me 2) I don't see how the output shown came from the input shown: almost surely it did not. @@@ but sincerely it came 3) It is extremely bad practice to load packages you do not need. This both slows R down unnecessarily and creates conflicts where packages override default behaviour. @@@ i know 4) I believe there is still a limit to the number of DLLs you can have loaded in a single R session, and I believe it to be 100. So you probably cannot load all 751 packages, and at some point package loading will fail. Now, loading library/base/R/Rprofile has no error-checking (as it is supposed to be unchanged, src/main/main.c:818) and so you may get no indication of this. @@@ Thanks this is really a great help, i will look into it @@@ are you one of the coders of R So my guess is that there was an attempt to load a few hundred packages and only some of them got loaded, not as far down the list as 'utils'. If you want to load some packages in every session, do so from your .Rprofile file: that is run as user code and you should get full error-checking (and messages). @@@ may you please send me a sample file, it would be really helpfull @@@ and where to put .Rprofile file As for Charilaos' points: a) .First.sys is defined in the system profile, library/base/R/Rprofile. It is run from the base environment. @@@ i ackowledge it b) The environment variable R_DEFAULT_PACKAGES justs sets the default for the option 'defaultPackages', and the format is described in the surely obvious place, the documentation for the option. There are examples in the 'check' script. @@@ This is really a good link to read again, Thanks Thank a lot Sir ! -gaurav On Mon, 26 Mar 2007, Charilaos Skiadas wrote: A couple of things: 1) It would have been a lot easier to help you if you had created a much smaller example. perhaps trying to load 2-3 packages instead of 1000. Now we have to wade through a lot of stuff to get to the point. 2) Perhaps your call to Sys.putenv doesn't do quite what you expect it to do. Example: TEMP - c(a,b) Sys.getenv(TEST) TEST Sys.putenv(TEST=TEMP) Sys.getenv(TEST) TEST b 3) I couldn't really see where in your code all these packages are loaded. Reading the help for .First.sys tells me that that's the call that actually loads the default packages, unless I've misunderstood something. If that's the case, then the following line you have at the end would prevent this loading: .First.sys - function() I must say that from the ?Startup help there are two things that are not very clear: a) At what point in the load process is R_DEFAULT_PACKAGES checked? .First.sys doesn't seem to know about it. Ok, a bit of search provided an answer to this: Reading the help for options, I see there, in the section about defaultPackages, what is probably the most helpful bit (for me) in all this: defaultPackages: the packages that are attached by default when R starts up. Initially set from value of the environment variable R_DEFAULT_PACKAGES, or if that is unset to c(datasets, utils, grDevices, graphics, stats, methods). (Set R_DEFAULT_PACKAGES to NULL or a comma-separated list of package names.) A call to options should be in your ?.Rprofile? file to ensure that the change takes effect before the base package is initialized (see Startup). b) What is the format that the R_DEFAULT_PACKAGES variable must have (I guess now I know, since it is mentioned in ?options, though that's not really the place I would have expected it to be explained) ? The only examples I could find on the web were setting it to NULL. Hope all this helps in some way. Haris Skiadas Department of Mathematics and Computer Science Hanover College On Mar 26, 2007, at 6:01 AM, [EMAIL PROTECTED] wrote: Hi All Please see the Rprofile file which i have modified as follows and after that when I start R then I see that R says to me TRUE for all the packages implying that all loaded at once. But when i try to use commands as simple as help(lm), it doesnt work nor any of the menu Packages is not working. Although the regression using lm ( Y ~ X ) is working even summary and rnorm is working fine. Please tell me why menu and help command is not working Rprofile is in between +++ lines R initialization
Re: [R] setting LD_LIBRARY_PATH
On Mon, 26 Mar 2007, ian white wrote: Dear R-help, I am trying to use a package (not from CRAN) which includes two shared library (.so) files. The maintainer suggests inserting two lines in /usr/bin/R, LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:path-to-package/lib export LD_LIBRARY_PATH (Not a very good idea, not least because there is another copy at R_HOME/bin/R. Better to modify R_HOME/etc/ldpaths, which deals with setting LD_LIBRARY_PATH.) This works, but I felt more comfortable putting the first line in .Renviron or $R_HOME/etc/Renviron.site. However this doesn't seem to work, and I cannot see why it doesn't. Those files are read by the process. You don't state your OS, but many OSes make sure that the paths for dlopen are cached before the process has a chance to change LD_LIBRARY_PATH, for security-related reasons. Most OSes are silent about this, but Solaris says If other objects were link-edited with pathname when path- name was built, that is, the pathname has dependencies on other objects, those objects will automatically be loaded by dlopen(). The directory search path used to find both path- name and the other needed objects may be affected by setting the environment variable LD_LIBRARY_PATH, which is analyzed once at process startup, and from a runpath setting within the object from which the call to dlopen() originated. As dlopen came from SunOS, it seems the behaviour has been copied by most implementations of dlopen. (AFAICS it is not touched on by POSIX.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Listing function displayed as a table
Something ugly like this? Lst - list() Lst[[1]] - list(name=Fred, wife=Mary, no.children=3, child.ages=c(4,7,9)) Lst[[2]] - list(name=Barney, wife=Liz, no.children=2, child.ages=c(3,5)) cbind( do.call(rbind, as.list(Lst))[ ,-4], child.ages=sapply( Lst, function(myli) paste(myli$child.ages, collapse=,) )) Why don't you just save the data in a dataframe instead of a list to begin with ? The only variable I can see that has multiple values is child.ages. Or create one row per record as in most databases. The choice depends on your input. df - rbind( c(Fred, Mary, 4), c(Fred, Mary, 7), c(Fred, Mary, 9), c(Barney, Liz, 3), c(Barney, Liz, 5) ) df - data.frame(df) colnames(df) - c(Father, Mother, Child.Age) df$Child.Age - as.numeric(as.character(df$Child.Age)) parents - paste( df$Father, df$Mother, sep=+ ) getstats - function(x) c( values=paste(x, collapse=,), mean=round(mean(x),2), youngest=min(x), oldest=max(x) ) do.call( rbind, tapply( df$Child.Age, parents, getstats ) ) values mean youngest oldest Barney+Liz 3,5 43 5 Fred+Mary 4,7,9 6.67 4 9 Regards, Adai Schmitt, Corinna wrote: Hallo, good idea it is working. A new question appears: How can I display the entries in a table like name wife no.children child.ages FredMary3 4,7,9 Barney Liz 2 3,5 Thanks, Corinna -Ursprüngliche Nachricht- Von: Michael T. Mader [mailto:[EMAIL PROTECTED] Gesendet: Montag, 26. März 2007 15:32 An: Schmitt, Corinna; r-help@stat.math.ethz.ch Betreff: Re: [R] Listing function Lst - list() Lst[[1]] - list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) Lst[[2]] - list(name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5)) I.e. a list of lists Regards Michael Schmitt, Corinna wrote: Hallo, I build a list by the following way: Lst = list(name=Fred, wife=Mary, no.children=3, cild.ages=c(4,7,9)) I know how I can extract the information one by one. But now I want to add a new entry which looks like name=Barney, wife=Liz, no.children=2, cild.ages=c(3,5) How can I add this information to Lst without overwriting the first entry? How can I then extract the corresponding information if I have both entries in Lst? Thanks for helping, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] subset
Dear R-Helpers, I want to make a subset from my data set. I'd like to perform different condition for subset. I.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2. How can i develop a subset under this condition? Thank you in advance. Sergio Della Franca. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset
On Mon, 2007-03-26 at 17:02 +0200, Sergio Della Franca wrote: Dear R-Helpers, I want to make a subset from my data set. I'd like to perform different condition for subset. I.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2. How can i develop a subset under this condition? Thank you in advance. Sergio Della Franca. See ?subset Something along the lines of the following should work: NewDF - subset(DF, (var1 == 0) (var2 == 0) (var 3 != 0)) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] substitute variable
Dear R-Helpers, I want to substitute the contents of a variable under some contitions. I.e., I have this data set: YEAR PRODUCTS 1 80 2 90 3 50 4 60 5 30 I want to perform this condition: if products 70 then products=NA else products=products. I'd like to achive the seguent result: YEAR PRODUCTS 1 NA 2 NA 3 50 4 60 5 30 How can i develop this? Thank you in advance. Sergio Della Franca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute variable
If you data frame is called 'df' df$PRODUCTS[df$PRODUCTS 70] - NA -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 Ohttp://maps.google.com/maps?f=qhl=enq=Curitiba,+Brazillayer=ie=UTF8z=18ll=-25.448315,-49.276916spn=0.002054,0.005407t=kom=1 On 26/03/07, Sergio Della Franca [EMAIL PROTECTED] wrote: Dear R-Helpers, I want to substitute the contents of a variable under some contitions. I.e., I have this data set: YEAR PRODUCTS 1 80 2 90 3 50 4 60 5 30 I want to perform this condition: if products 70 then products=NA else products=products. I'd like to achive the seguent result: YEAR PRODUCTS 1 NA 2 NA 3 50 4 60 5 30 How can i develop this? Thank you in advance. Sergio Della Franca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop help
Thanks Adai. You can tell by the clumsiness of my script that I am new to R and to programming. After wrestling with it this morning, I found that the following worked best: pre.outliers-subset(final.roi.df, gFDR4FWHM = 1.96) detach(final.roi.df) attach(pre.outliers) outliers - subset(pre.outliers, gtvalue4FWHM = 0.00) if(length(outliers$gtvalue4FWHM)==0) { print(NA) next } Thanks for the other suggestions. I have incorporated them. Anthony Adaikalavan Ramasamy wrote: Try changing outliers - subset(pre.outliers, gtvalue4FWHM = 0.00) to w - which( gtvalue4FWHM = 0.00 ) outliers( length(w) 0, pre.outliers[ w, ], NA ) Other comments: 1. Make sure you detach(data_gcs) at the end of the loops 2. scale() works on columns by default, so try current.roi.plus.z - data.frame(current.roi, scale(current.roi[, c(15,18,21,24)]) ) 3. For simple statements, you can use ifelse() syntax. Also see all(). Using these two functions, you can try testextrem - function(x) ifelse( all(abs(x[ 1:4 ]) c(2.5)), 1, 0) 4. Try to minimise the use of attach() in loops. 5. You might be interested in learning more about apply(), tapply(), split() etc. If this does not help, then please resend a simplified version of the codes, preferably with a simple toy example to illustrate. Regards, Adai Anthony Steven Dick wrote: Hello- I have a script which steps through a series of subjects, and for the subjects I remove outlying values. After removing these outliers, I specify a cutoff, keeping only values over a certain value (e.g., 1.96). I want to populate a matrix with a statistic of the values that make the cutoff (for example, the mean). However, in some subjects, after outliers and the cutoff are specified, there are no data that meet the criteria (I get 0 rows (or 0-length row.names)). Here the script dies. The solution I think is to specify a break so that the matrix will be populated with a value (such as NA) and it will move on to the next subject in the loop. However, I haven't been able to figure this out. If anyone has any suggestions I would very much appreciate them. I have paster part of the script below up to the point where it dies. Thanks. for (ss in levels(ss.list)) { print(ss) ss.count = ss.count + 1 query.string - paste(SELECT * FROM ,ss,;,sep=) #print(query.string) data_gcs - dbGetQuery(con, query.string) attach(data_gcs) names(data_gcs) mat_row = 0 for(i in levels(roi.list)){ print (i) current.roi - data_gcs[data_gcs$ROI==i,] current.roi.plus.z - data.frame(current.roi, scale(current.roi[,15]), scale(current.roi[,18]), scale(current.roi[,21]), scale(current.roi[,24])) testextrem - function(x) {if ((abs(x[1]) 2.5) (abs(x[2]) 2.5) (abs(x[3]) 2.5) (abs(x[4]) 2.5)) return(1) else return(0)} filtervector - apply(as.vector(current.roi.plus.z[,c(27, 28, 29, 30)]), 1, FUN=testextrem) current.roi.plus.z.filter - data.frame(current.roi.plus.z, filtervector) final.roi.df - current.roi.plus.z.filter[which(current.roi.plus.z.filter$filtervector==1),] #print (final.roi.df) kicked.out-(length(filtervector) - sum(filtervector))/length(filtervector) print(kicked.out) matrix.col = matrix.col + 1 attach(final.roi.df) names(final.roi.df) print(matrix.col) #set cutoff for FDR. per voxel p values (of Z dist) .05 = 1.96, .01 = 2.575, .001 = 3.277, .005 = 3.479 BE SURE TO CHANGE THE VARIABLE EACH TIME YOU CHANGE CONDITION pre.outliers-subset(final.roi.df, gFDR4FWHM = 1.96) detach(final.roi.df) attach(pre.outliers) outliers-subset(pre.outliers, gtvalue4FWHM = 0.00) ...and the script dies here because there are no data in outliers. -- Anthony Steven Dick, Ph.D. Post-Doctoral Scholar Human Neuroscience Laboratory Biological Sciences Division University of Chicago 5841 S. Maryland Ave. MC-2030 Chicago, IL 60637 Phone: (773)-834-7770 Email: [EMAIL PROTECTED] Alternate email: [EMAIL PROTECTED] Please visit my homepage at http://home.uchicago.edu/~adick/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute variable
say your data frame is called tmp tmp$PRODUCTS[tmp$PRODUCTS 70] - NA b On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote: Dear R-Helpers, I want to substitute the contents of a variable under some contitions. I.e., I have this data set: YEAR PRODUCTS 1 80 2 90 3 50 4 60 5 30 I want to perform this condition: if products 70 then products=NA else products=products. I'd like to achive the seguent result: YEAR PRODUCTS 1 NA 2 NA 3 50 4 60 5 30 How can i develop this? Thank you in advance. Sergio Della Franca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute variable
Ok, this run correctly. Now i want to perform much more conditions, i.e.: tmp$PRODUCTS[tmp$PRODUCTS 70] - NA and tmp$PRODUCTS[tmp$PRODUCTS 20] - NA. How can i perform this double condition in the same code? 2007/3/26, Benilton Carvalho [EMAIL PROTECTED]: say your data frame is called tmp tmp$PRODUCTS[tmp$PRODUCTS 70] - NA b On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote: Dear R-Helpers, I want to substitute the contents of a variable under some contitions. I.e., I have this data set: YEAR PRODUCTS 1 80 2 90 3 50 4 60 5 30 I want to perform this condition: if products 70 then products=NA else products=products. I'd like to achive the seguent result: YEAR PRODUCTS 1 NA 2 NA 3 50 4 60 5 30 How can i develop this? Thank you in advance. Sergio Della Franca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substitute variable
condition1 | condition2 (or) condition1 condition2 (and) tmp$PRODUCTS[tmp$PRODUCTS 70 | tmp$PRODUCTS 20] - NA b On Mar 26, 2007, at 12:47 PM, Sergio Della Franca wrote: Ok, this run correctly. Now i want to perform much more conditions, i.e.: tmp$PRODUCTS[tmp$PRODUCTS 70] - NA and tmp$PRODUCTS[tmp$PRODUCTS 20] - NA. How can i perform this double condition in the same code? 2007/3/26, Benilton Carvalho [EMAIL PROTECTED]: say your data frame is called tmp tmp$PRODUCTS[tmp$PRODUCTS 70] - NA b On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote: Dear R-Helpers, I want to substitute the contents of a variable under some contitions. I.e., I have this data set: YEAR PRODUCTS 1 80 2 90 3 50 4 60 5 30 I want to perform this condition: if products 70 then products=NA else products=products. I'd like to achive the seguent result: YEAR PRODUCTS 1 NA 2 NA 3 50 4 60 5 30 How can i develop this? Thank you in advance. Sergio Della Franca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with putting Hmisc labeled matrix into a data.frame.
# I seem to be having a bit of a problem with Hmisc. At least, I assume it is # coming from there. When I try to put a labeled matrix into a data.frame # I get a very strange result. If you would run the two examples I think # you will see my problem. # Example 1 no label library(Hmisc) mydata - matrix(1:12, 3, 4) myvec - matrix( c(a,b,c), 3) mf - data.frame(myvec, mydata) ; mf# works fine # with label ndata - matrix(1:12, 3, 4) label(ndata) - Great matrix nvec - matrix( c(a,b,c), 3) nf - data.frame(nvec, ndata) ; nf # Not so fine nf - data.frame(nvec, ndata) ; nf # nvec ndata.1 ndata.2 ndata.3 ndata.4 1 a 1 4 7 10 2 b 2 5 8 11 3 c 3 6 9 12 4 aNANANANA 5 bNANANANA 6 cNANANANA 7 aNANANANA 8 bNANANANA 9 cNANANANA 10aNANANANA 11bNANANANA 12cNANANANA Warning message: corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = digits, na.encode = FALSE) # Am I missing something obvious or should I bring this to the # attention of the package maintainer? I did not find anything in the archives. # Running Windows XP, R 2.4.1 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] data-frame adding/deleting column
This is a slightly different formulation of your problem, but you might find it easier to work with: Start by making a data frame): df=data.frame(Father=c (Fred,Fred,Fred,Barney,Barney),Mother=c (Mary,Mary,Mary,Liz,Liz),Child.Age=c(4,7,9,3,5)) If you want to add a wedding date column to this data frame, then df=data.frame(df,WeddingDate=c(December 12th, 1980,December 12th, 1980,December 12th, 1980,March 3rd, 2003,March 3rd, 2003)) If, for example, you wanted to delete row #4, this is what you could do: df=data.frame(df[-4,]) Similarly for column #4: df=data.frame(df[,-4]) Kyle H. Ambert Graduate Student, Dept. Behavioral Neuroscience Oregon Health Science University [EMAIL PROTECTED] On Mar 26, 2007, at 8:24 AM, Schmitt, Corinna wrote: Hallo, I have got an existing data frame and want to add a new column. The existing data frame was created like this: df - rbind( c(Fred, Mary, 4), c(Fred, Mary, 7), +c(Fred, Mary, 9), c(Barney, Liz, 3), +c(Barney, Liz, 5) ) df - data.frame(df) colnames(df) - c(Father, Mother, Child.Age) df Father Mother Child.Age 1 Fred Mary 4 2 Fred Mary 7 3 Fred Mary 9 4 BarneyLiz 3 5 BarneyLiz 5 I want to add a column named weddingdate. How does this work and how can I save the corresponding dates in the cells? (Fred-Mary: 12.12.1980, Barney-Liz: 3.3.2003) How can I delet a whole column or row if it is needed? Thanks, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Is the random number generator biased?
Hi all, in order to verify some results I did the following test in R (2.4.1., windows system): X - cumsum(rnorm(100)) for (i in 1:1000) { tmp - seq(1,length(X),by=i) X.coarse - X[tmp] X.return - diff(X.coarse) X.scale.mean[i] - mean(X.return) } plot(X.scale.mean,type=l) As X is a random walk with increments following a standard normal distribution, the mean of X should be 0. Further more, each piece of the random walk should also have zero mean - independent of its length. Why is it then, that the plot of X.scale.mean shows a clear linear trend? Is the generation of the random walk in some way biased or do I just miss some point? Thanks for any enlighting replies in advance Oliver __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to drop variables using a wildcard and logic...
Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter t I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to drop variables using a wildcard and logic...
if 'test' is your data frame... test[, grep([tT]$, names(test))] b On Mar 26, 2007, at 3:06 PM, [EMAIL PROTECTED] wrote: Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter t I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is the random number generator biased?
On 3/26/2007 2:48 PM, Oliver Faulhaber wrote: Hi all, in order to verify some results I did the following test in R (2.4.1., windows system): X - cumsum(rnorm(100)) for (i in 1:1000) { tmp - seq(1,length(X),by=i) X.coarse - X[tmp] X.return - diff(X.coarse) X.scale.mean[i] - mean(X.return) } plot(X.scale.mean,type=l) As X is a random walk with increments following a standard normal distribution, the mean of X should be 0. Further more, each piece of the random walk should also have zero mean - independent of its length. Why is it then, that the plot of X.scale.mean shows a clear linear trend? The points in your plot are all based on a single realization of a Brownian motion. What you are seeing is just that X[100] is non-zero. If you repeat the simulation you'll get a different linear trend. Is the generation of the random walk in some way biased or do I just miss some point? If it is biased, your plots don't show it. Try this plot instead (and wait a lot longer; it does a lot of memory allocations!): X.scale.mean - numeric(1000) for (i in 1:1000) { X - cumsum(rnorm(100)) tmp - seq(1,length(X),by=i) X.coarse - X[tmp] X.return - diff(X.coarse) X.scale.mean[i] - mean(X.return) } plot(X.scale.mean,type=l) Duncan Murdoch Thanks for any enlighting replies in advance Oliver __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset
On Mon, 26 Mar 2007, Marc Schwartz wrote: Sergio, Please be sure to cc: the list (ie. Reply to All) with follow up questions. In this case, you would use %in% with a negation: NewDF - subset(DF, (var1 == 0) (var2 == 0) (!var3 %in% 2:3)) Probably a typo: should be !(var3 %in% 2:3) rather than (!var %in% 2:3) -thomas See ?%in% for more information. HTH, Marc On Mon, 2007-03-26 at 17:30 +0200, Sergio Della Franca wrote: Ok, this run correctly. Another question for you: I want to put more than one condition for var3, i.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2 and from 3. Like you suggested, i perform this code: NewDF - subset(DF, (var1 == 0) (var2 == 0) (var 3 != 2)) (var 3 != 3)) There is a method to combine (var 3 != 2)) (var 3 != 3)) in one condition? Thank you. Sergio 2007/3/26, Marc Schwartz [EMAIL PROTECTED]: On Mon, 2007-03-26 at 17:02 +0200, Sergio Della Franca wrote: Dear R-Helpers, I want to make a subset from my data set. I'd like to perform different condition for subset. I.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2. How can i develop a subset under this condition? Thank you in advance. Sergio Della Franca. See ?subset Something along the lines of the following should work: NewDF - subset(DF, (var1 == 0) (var2 == 0) (var 3 != 0)) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is the random number generator biased?
[Sorry, I need to correct a vital typo!!] On 26-Mar-07 18:48:50, Oliver Faulhaber wrote: Hi all, in order to verify some results I did the following test in R (2.4.1., windows system): X - cumsum(rnorm(100)) for (i in 1:1000) { tmp - seq(1,length(X),by=i) X.coarse - X[tmp] X.return - diff(X.coarse) X.scale.mean[i] - mean(X.return) } plot(X.scale.mean,type=l) As X is a random walk with increments following a standard normal distribution, the mean of X should be 0. Further more, each piece of the random walk should also have zero mean - independent of its length. Why is it then, that the plot of X.scale.mean shows a clear linear trend? Is the generation of the random walk in some way biased or do I just miss some point? Thanks for any enlighting replies in advance Oliver Try plot(X,type=l) and you will see why you get that result from plot(X.scale.mean). But that does not help to understand why plot(X) looks as it does. However, this behaviour is standard for a random walk. [XXXIf you think about it, var(X[n]) = 1 (in your case), so atXXX] If you think about it, var(X[n]( = n (in your case), so at the nth step you are (for instance) likely (P1/2)to be at least 0.5*sqrt(n) on one side or other of the mean. So say n=1: then you are likely to be at least 50 away from the mean; and you have to get there somehow, starting from 0. So there will be an overall trend! Similarly, for n=100, you are likely to be at least 500 from the mean. The same explanation accounts for the shorter segments of trend you will also observe over the graph of X, since from any point along the graph the above holds true on a smaller scale. Hoping that helps! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-07 Time: 20:27:57 -- XFMail -- E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-07 Time: 20:32:42 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to drop variables using a wildcard and logic...
Alternatively, you can use ?glob2rx test[, grep(glob2rx(*[tT]), names(test))] which allows for wildcards. --sundar Benilton Carvalho said the following on 3/26/2007 12:19 PM: if 'test' is your data frame... test[, grep([tT]$, names(test))] b On Mar 26, 2007, at 3:06 PM, [EMAIL PROTECTED] wrote: Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter t I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to drop variables using a wildcard and logic...
Thanks Phil and Benilton! Mark On 3/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter t I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset [Broadcast]
From: Thomas Lumley On Mon, 26 Mar 2007, Marc Schwartz wrote: Sergio, Please be sure to cc: the list (ie. Reply to All) with follow up questions. In this case, you would use %in% with a negation: NewDF - subset(DF, (var1 == 0) (var2 == 0) (!var3 %in% 2:3)) Probably a typo: should be !(var3 %in% 2:3) rather than (!var %in% 2:3) I used to think so, but found I didn't need the parens: R a - 1:3; b - c(1, 3, 5) R ! a %in% b [1] FALSE TRUE FALSE R ! (a %in% b) [1] FALSE TRUE FALSE Andy -thomas See ?%in% for more information. HTH, Marc On Mon, 2007-03-26 at 17:30 +0200, Sergio Della Franca wrote: Ok, this run correctly. Another question for you: I want to put more than one condition for var3, i.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2 and from 3. Like you suggested, i perform this code: NewDF - subset(DF, (var1 == 0) (var2 == 0) (var 3 != 2)) (var 3 != 3)) There is a method to combine (var 3 != 2)) (var 3 != 3)) in one condition? Thank you. Sergio 2007/3/26, Marc Schwartz [EMAIL PROTECTED]: On Mon, 2007-03-26 at 17:02 +0200, Sergio Della Franca wrote: Dear R-Helpers, I want to make a subset from my data set. I'd like to perform different condition for subset. I.e.: I like to create a subset when: - var1=0 - var2=0 - var3 is different from 2. How can i develop a subset under this condition? Thank you in advance. Sergio Della Franca. See ?subset Something along the lines of the following should work: NewDF - subset(DF, (var1 == 0) (var2 == 0) (var 3 != 0)) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is the random number generator biased?
Oliver Faulhaber wrote: Hi all, in order to verify some results I did the following test in R (2.4.1., windows system): X - cumsum(rnorm(100)) for (i in 1:1000) { tmp - seq(1,length(X),by=i) X.coarse - X[tmp] X.return - diff(X.coarse) X.scale.mean[i] - mean(X.return) } plot(X.scale.mean,type=l) As X is a random walk with increments following a standard normal distribution, the mean of X should be 0. Further more, each piece of the random walk should also have zero mean - independent of its length. Why is it then, that the plot of X.scale.mean shows a clear linear trend? Is the generation of the random walk in some way biased or do I just miss some point? The latter. If you think a little closer, you'll realize that sum(X.return) is going to be pretty close to X[100], except for the sum of at most 999 terms (at most 961, actually). You then proceed to calculate the mean by dividing by the number of terms which is essentially 1/i. Thanks for any enlighting replies in advance Oliver __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fitted probabilities in multinomial logistic regression are identical for each level
Dear Bob, If I understand correctly what you've done, the newdata that you're using to get predicted values includes the three values of the response variable, which are irrelevant to the predictions and cause each prediction to be repeated three times. I hope that this helps, John On Tue, 27 Mar 2007 06:19:12 +1000 Bob Green [EMAIL PROTECTED] wrote: I was hoping for some advice regarding possible explanations for the fitted probability values I obtained for a multinomial logistic regression. The analysis aims to predict whether Capgras delusions (present/absent) are associated with group (ABH, SV, homicide; values = 1,2,3,), controlling for previous violence. What has me puzzled is that for each combination the fitted probabilities are identical. I haven't seen this in the worked examples I have come across and was interested to know if this is a problem or what might be the cause for this. I ran an analysis with another independent variable and obtained a similar pattern. Any assistance with this is appreciated Bob Green predictors - expand.grid(group=1:3, in.acute.danger = c(y,n), violent.convictions = c(y,n)) p.fit - predict(mod.multacute, predictors, type='probs') p.fit 1 2 3 1 0.4615070 0.3077061 0.2307869 2 0.4615070 0.3077061 0.2307869 3 0.4615070 0.3077061 0.2307869 4 0.7741997 0.1290310 0.0967693 5 0.7741997 0.1290310 0.0967693 6 0.7741997 0.1290310 0.0967693 7 0.4230927 0.3846055 0.1923017 8 0.4230927 0.3846055 0.1923017 9 0.4230927 0.3846055 0.1923017 10 0.7058783 0.1647063 0.1294153 11 0.7058783 0.1647063 0.1294153 12 0.7058783 0.1647063 0.1294153 mod.multacute - multinom(group ~ in.acute.danger * violent.convictions, data = kc, na.action = na.omit) # weights: 15 (8 variable) initial value 170.284905 iter 10 value 131.016050 final value 130.993722 converged summary(mod.multacute, cor=F, Wald=T) Call: multinom(formula = group ~ in.acute.danger * violent.convictions, data = kc, na.action = na.omit) Coefficients: (Intercept) in.acute.dangery violent.convictionsy in.acute.dangery:violent.convictionsy 2 -1.4552791.3599055 -0.3364982 0.02651913 3 -1.6964160.9078901 -0.3830842 0.47860722 Std. Errors: (Intercept) in.acute.dangery violent.convictionsy in.acute.dangery:violent.convictionsy 2 0.29680820.52820770.6162498 0.9936493 3 0.32798380.63125690.6946869 1.1284891 Value/SE (Wald statistics): (Intercept) in.acute.dangery violent.convictionsy in.acute.dangery:violent.convictionsy 2 -4.903094 2.574566 -0.5460419 0.02668862 3 -5.172256 1.438226 -0.5514486 0.42411327 Residual Deviance: 261.9874 AIC: 277.9874 Anova (mod.multacute) Anova Table (Type II tests) Response: group LR Chisq Df Pr(Chisq) in.acute.danger 10.9335 2 0.004225 ** violent.convictions 0.5957 2 0.742430 in.acute.danger:violent.convictions 0.1895 2 0.909600 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sphericity and post-hoc analysis in a repeated-measure ANOVA
Does anyone have any suggestions for how to test for violation of the sphericity assumption and apply the Huynh-Feldt correction to a repeated-measure model? My model follows the format below: Rep.anova=aov(Y~X1*X2+Error(Subject/(X1*X2),data=DataFile)) I've already looked at the explanations aov() and Error() in Baron's Notes on the use of R for psychology experiments and questionnaires, which seems like a logical place for this information, but I didn't see anything. Along a similar line, I'm also wondering if anyone has suggestions for how to implement post- hoc analyses on X1, after finding a significant main effect and no X1:X2 interaction, given that X1 has three levels and each subject in the analysis has data associated with each level. Thank-you in advance for your suggestions. Kyle H. Ambert Graduate Student, Dept. Behavioral Neuroscience Oregon Health Science University [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Updating a worksheet in Excel file using RODBC
Dear Hans-Peter, Thank you very much for your note! I tried your package and it works all right (i.e. it indeed writes data to Excel files), however it creates a new Excel file and this is not what I really need. I need to update/create one sheet in the existing file. I am using R do compute some data but then it must be put into an Excel file and an Excel chart must be created. So I intended to (manually) create one excel file and to write a VBA macro which makes a desirable chart of a certain sheet (let's say Sheet1). Then I intended to autoomatically make many copies of this file with appropriate file names, write the right data to Sheet1 of each such file so that when it is opened a desired chart is automatically created. So creting a totally new file does not help me. Best regards, Moshe. -Original Message- From: Hans-Peter [mailto:[EMAIL PROTECTED] Sent: Saturday, 24 March 2007 3:44 AM To: Moshe Olshansky Cc: R Help Subject: Re: [R] Updating a worksheet in Excel file using RODBC Hi, 2007/3/23, Moshe Olshansky [EMAIL PROTECTED]: Hello! I have no problem reading Excel files (each worksheet in the file is a table which can be read - at least in my case). What I would like to do is to read such a table, change it (just the contents, not the format) and write it back, and this I can not do. I am getting the following error messages (3 slightly different attempts): [snip] As another option (if you work with Windows) you can check my xlsReadWrite package (- CRAN). It should work very well in your case (it's not suited if you want to use SQL (join) statements, but for plain data reading/writing it is nice). For both versions (free/pro) updates are pending. They should be released by end of next week (but no guarantees). -- Regards, Hans-Peter Moshe Olshansky Chimaera Capital Limited Level 4 / 349 Collins Street Melbourne, Victoria 3000 Phone: +613 8614 8400 Fax: +613 8614 8410 Email: [EMAIL PROTECTED] Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Chimaera Capital Limited. E-mail transmissions cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Updating a worksheet in Excel file using RODBC
Dear Prof. Ripley, You seem not to have tried the simplest possible option. The following works for me (beware of wrapped lines from mailers) chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\bdr\\hills.xls; ReadOnly=False) sqlSave(chan, USArrests, tests, fast=TRUE) # or FALSE You are right - I have not. It does not work exactly as it should have but this solves my problem. I created a very small Excel file odbc1.xls containing 3 sheets (test, Sheet2 and Sheet3). Below is a short R session: chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\EFGraphs\\odbc1.xls; ReadOnly=False) x- c(1:6) x - matrix(x,nrow=3,ncol=2) x - data.frame(x) x X1 X2 1 1 4 2 2 5 3 3 6 sqlSave(chan, x, test, fast=FALSE) Error in sqlSave(chan, x, test, fast = FALSE) : table 'test' already exists sqlSave(chan, x, tests, fast=FALSE) As you see I was unable to overwrite an existing sheet (an attempt to drop this table also fails), but I was able to add a new sheet to an existing Excel file (after this action the file contains 4 sheets - the 3 it contained and the last sheet named tests). This allows me to do what I wanted, i.e. manually create an Excel file with a small VBA macro, make many copies of this file (under appropriate names), write an appropriate data to each file and then the macro will work on the right data (different for each file). Thanky you! Moshe. Moshe Olshansky Chimaera Capital Limited Level 4 / 349 Collins Street Melbourne, Victoria 3000 Phone: +613 8614 8400 Fax: +613 8614 8410 Email: [EMAIL PROTECTED] Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Chimaera Capital Limited. E-mail transmissions cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help for looping
Rusers: I have tried to minimize computing times by taking advanage of lapply(). My data is a 1000*30 matrix and the distance matrix was created with dist(). What I am trying to do is to compute the standard distances using the frequencies attached to the nearest negibors of n reference zones. So I will have 1000 standard distances, and would like to see the frequency distribution of the standard distances. # Convert decimal degrees into UTM miles x-(data[,1]-58277.194363)*0.000621 y-(data[,2]-4414486.03135)*0.000621 # Combine x y for computing distances coords-cbind(x,y) pts-length(data) # Subset housing data and employment data RES-data[,3:17] EMP-data[,378:392] # Combine all the subdata as D D-cbind(coords,RES,EMP) cases-ncol(D)-ncol(coords) # Create a threshold bandwidth for defining the nearest neighbors thrs-seq(0,35,by=1) SDTAZ-rep(list(matrix(,nrow(D),length(thrs))),cases) for (j in 1:nrow(D)) for (k in 1:length(thrs)) for (l in 1:cases) { { { SDTAZ[[l]][j,k]- sqrt( sum( (D[as.vector(which(dis[j,]=thrs[k])),l+2]-D[j,l+2]- min(D[as.vector(which(dis[j,]=thrs[k])),l+2]-D[j,l+2])+1)* ( (dis[j,as.vector(which(dis[j,]=thrs[k]))])^2 ) ) /sum(D[as.vector(which(dis[j,]=thrs[k])),l+2]-D[j,l+2]- min(D[as.vector(which(dis[j,]=thrs[k])),l+2]-D[j,l+2])+1) ) } } } I think that within this nested loop, I should use lapply() but I ended up getting different values I appreciate if someone could kindly help me. Thank you very much. Takatsugu Kobayashi PhD Candidate Indiana University, Dept. Geography __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using alpha transparency for lines in levelplot
On 3/26/07, Michael Sumner [EMAIL PROTECTED] wrote: Hello, I'm having trouble with using the alpha channel for transparency with lines with lattice levelplots. If I use transparency via the alpha argument to rgb to overplot lines on levelplot the transparent colour affects all of the region colours in the plot. I don't understand what you are trying to say. Here's a modified version of your code: -- ## panel function to add lines with grey(0.3) my.panel - function(...) { panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = grey(0.3)) panel.contourplot(...); panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = grey(0.3)) } ## panel function to add lines with grey transparency my.paneltransp - function(...) { panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = rgb(0.3, 0.3, 0.3, 0.5)) panel.contourplot(...) panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = rgb(0.3, 0.3, 0.3, 0.5)) } pdf(alpha.pdf, version = 1.4) ## this works fine levelplot(z~x+y, xy, panel = my.panel) ## this doesn't? levelplot(z~x+y, xy, panel = my.paneltransp) dev.off() -- and the resulting 2-page PDF file is at http://dsarkar.fhcrc.org/R/alpha.pdf I don't see any evidence of transparency in the 'region' colors (the lines behind the level plot never show up). Are you sure whatever you are seeing is not an artifact of your display application? Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using alpha transparency for lines in levelplot
Deepayan Sarkar wrote: I don't understand what you are trying to say. Here's a modified version of your code: Sorry, it's not that the transparency affects the plot regions but the colour of the lines darkens the region colours. I.e. with grey lines the regions are greyed. In your PDF the regions are greyed (darker) in both plots than the colours I see with the usual lattice colour scheme. Do you notice any difference between the region colours of the plots if you write them to separate files? If not it must be my viewer. Cheers, Mike. -- ## panel function to add lines with grey(0.3) my.panel - function(...) { panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = grey(0.3)) panel.contourplot(...); panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = grey(0.3)) } ## panel function to add lines with grey transparency my.paneltransp - function(...) { panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = rgb(0.3, 0.3, 0.3, 0.5)) panel.contourplot(...) panel.xyplot(1:60, runif(60, 1, 60), type = l, lwd = 3, col = rgb(0.3, 0.3, 0.3, 0.5)) } pdf(alpha.pdf, version = 1.4) ## this works fine levelplot(z~x+y, xy, panel = my.panel) ## this doesn't? levelplot(z~x+y, xy, panel = my.paneltransp) dev.off() -- and the resulting 2-page PDF file is at http://dsarkar.fhcrc.org/R/alpha.pdf I don't see any evidence of transparency in the 'region' colors (the lines behind the level plot never show up). Are you sure whatever you are seeing is not an artifact of your display application? Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using alpha transparency for lines in levelplot - SUMMARY
Hello, thanks to Deepayan Sarkar for sorting me out on this one. The problem with transparent lines affecting region colour in lattice plot appears when using Adobe Reader (v 8 in my case). I've only viewed the file on Windows XP. I've tried using Foxit Reader to view the file and there's no problem. Cheers, Mike. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Random divisions
I am working with microarray analysis and was using PAM with excel interface. Is there a way to do random divisions for the training set in excel? I also tried PAM in R with the pamr menu. How can I do the random divisions in R? Then I tried to reproduce classification with gene expression data, which is chapter 24 from the book bioinformatics and computational biology solutions using R and Bioconductor. There is also an explanation for random divisions using eset as an example. How do I have to load my data into R, to be able to reproduce, what they have done? what kind of file is eset? is it like an excel spreadsheet? I have my microarray data now in a .csv or .txt file with phenotype in the first row, class in the second row and then gene expression data starting from the third row. first column are the affy-IDs. I have two classes. I would appreciate it, if someone could help me out with that!!! Bettina __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Newbie: Combn and scripting
Hello All, I have just installed my R 2.4 (windows) as a test trying to load a data frame and run combn() for each line into another file. How do I do this? data.csv: a,b,c,d 1,2,3.4 g,3,6,t etc x=data.csv, m=3 Thank you Zam _ This email contains confidential information intended only for the person named above and may be subject to legal privilege. If you are not the intended recipient, any disclosure, copying or use of this information is prohibited. The Department provides no guarantee that this communication is free of virus or that it has not been intercepted or interfered with. If you have received this email in error or have any other concerns regarding its transmission, please notify [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problems with installation of packages
I am having a peculiar problem with installation of packages. I am trying to install the package maptools. This is what I get. install.packages(maptools,depend=T) Warning in install.packages(maptools, depend = T) : argument 'lib' is missing: using /usr/local/lib/R/site-library Warning: unable to access index for repository http://cran.wustl.edu/src/contribdependency ''maptools'' is not available This is a machine running debian sarge. The http_proxy is correctly set. I am able to download the package by using wget. I also tried starting R with (R http_proxy-http://my-proxy/). That does not help either. I have R 2.4.1 on my debian system. Will be grateful for any help. Vikas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Updating a worksheet in Excel file using RODBC
Yes, sqlDrop does not work correctly for Excel worksheet names (and there are other quirks). As I said in another message, it is on my TODO list to make this work better, but in the absence of good documentation of what the Excel ODBC driver should do and several with known bugs it is largely a matter of trial-and-error. On Tue, 27 Mar 2007, Moshe Olshansky wrote: Dear Prof. Ripley, You seem not to have tried the simplest possible option. The following works for me (beware of wrapped lines from mailers) chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\bdr\\hills.xls; ReadOnly=False) sqlSave(chan, USArrests, tests, fast=TRUE) # or FALSE You are right - I have not. It does not work exactly as it should have but this solves my problem. I created a very small Excel file odbc1.xls containing 3 sheets (test, Sheet2 and Sheet3). Below is a short R session: chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\EFGraphs\\odbc1.xls; ReadOnly=False) x- c(1:6) x - matrix(x,nrow=3,ncol=2) x - data.frame(x) x X1 X2 1 1 4 2 2 5 3 3 6 sqlSave(chan, x, test, fast=FALSE) Error in sqlSave(chan, x, test, fast = FALSE) : table 'test' already exists sqlSave(chan, x, tests, fast=FALSE) As you see I was unable to overwrite an existing sheet (an attempt to drop this table also fails), but I was able to add a new sheet to an existing Excel file (after this action the file contains 4 sheets - the 3 it contained and the last sheet named tests). This allows me to do what I wanted, i.e. manually create an Excel file with a small VBA macro, make many copies of this file (under appropriate names), write an appropriate data to each file and then the macro will work on the right data (different for each file). Thanky you! Moshe. Moshe Olshansky Chimaera Capital Limited Level 4 / 349 Collins Street Melbourne, Victoria 3000 Phone: +613 8614 8400 Fax: +613 8614 8410 Email: [EMAIL PROTECTED] Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Chimaera Capital Limited. E-mail transmissions cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Updating a worksheet in Excel file using RODBC
OK. By the way, I only thought that I could do what I wanted! It worked once but then it failed. When I was trying to update an existing sheet I got an error message saying that it existed and when I was trying to make a new sheet (something that worked once) I got a message saying that there was no such table! -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Tuesday, 27 March 2007 4:44 PM To: Moshe Olshansky Cc: [EMAIL PROTECTED] Subject: Re: Updating a worksheet in Excel file using RODBC Yes, sqlDrop does not work correctly for Excel worksheet names (and there are other quirks). As I said in another message, it is on my TODO list to make this work better, but in the absence of good documentation of what the Excel ODBC driver should do and several with known bugs it is largely a matter of trial-and-error. On Tue, 27 Mar 2007, Moshe Olshansky wrote: Dear Prof. Ripley, You seem not to have tried the simplest possible option. The following works for me (beware of wrapped lines from mailers) chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\bdr\\hills.xls; ReadOnly=False) sqlSave(chan, USArrests, tests, fast=TRUE) # or FALSE You are right - I have not. It does not work exactly as it should have but this solves my problem. I created a very small Excel file odbc1.xls containing 3 sheets (test, Sheet2 and Sheet3). Below is a short R session: chan - odbcDriverConnect(DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\\EFGraphs\\odbc1.xls; ReadOnly=False) x- c(1:6) x - matrix(x,nrow=3,ncol=2) x - data.frame(x) x X1 X2 1 1 4 2 2 5 3 3 6 sqlSave(chan, x, test, fast=FALSE) Error in sqlSave(chan, x, test, fast = FALSE) : table 'test' already exists sqlSave(chan, x, tests, fast=FALSE) As you see I was unable to overwrite an existing sheet (an attempt to drop this table also fails), but I was able to add a new sheet to an existing Excel file (after this action the file contains 4 sheets - the 3 it contained and the last sheet named tests). This allows me to do what I wanted, i.e. manually create an Excel file with a small VBA macro, make many copies of this file (under appropriate names), write an appropriate data to each file and then the macro will work on the right data (different for each file). Thanky you! Moshe. Moshe Olshansky Chimaera Capital Limited Level 4 / 349 Collins Street Melbourne, Victoria 3000 Phone: +613 8614 8400 Fax: +613 8614 8410 Email: [EMAIL PROTECTED] Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Chimaera Capital Limited. E-mail transmissions cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.