[R] RColorBrewer Package Color index
Hi everyone, Can anyone kindly help me with the interpretation of colors in the RColorBrewer Package (brewer.pal) ? For example, in brewer.pal command, when picking up the "RdBu" palette, does red means larger or smaller value? I am new to this fantastic program, and I have searched up and down, no clue :( I will really appreciate your time if you can kindly give me a hand. Thank you so much for your attention! Best, Katy _ 与世界各地的朋友进行交流,免费下载 Live Messenger; __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Zipcodes latitude and longitude
I see several mapping libraries but cannot find how to do a simple task. Starting with a vector of zip codes (in the United States and in Canada) I would like to automatically lookup the corresponding coordinates. Can you suggest a package and function that I should turn to? I would also like to automatically pull in the altitude, and some climate data. -- Farrel Buchinsky [[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] Possible ld.exe problem when building
Dear R People: I am trying to build R-2.5.0 from source on a Windows machinee. I downloaded the tools and such, and started things off. I received some odd errors messages, looked on the R Search and found a similar problem. The suggestion was to re-load "ld.exe". I downloaded and installed everything again. Same problem. I am including my output. c:\esr\R-2.5.0\src\gnuwin32>make all recommended make all recommended make[1]: `Rpwd.exe' is up to date. make[4]: Nothing to be done for `svnonly'. installing C headers make[2]: `all' is up to date. make[2]: `libRblas.dll.a' is up to date. make[5]: Nothing to be done for `svnonly'. installing C headers make --no-print-directory -C ../extra/intl OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' -f Makefile.win make --no-print-directory -C ../appl OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' FOPTFLAGS='-O3 -Wall' -f Makefile.win make --no-print-directory -C ../nmath OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' -f Makefile.win make --no-print-directory -C ../main OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' FFLAGS='-O3 -Wall' -f Makefile.win make --no-print-directory -C ./graphapp OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' make --no-print-directory -C ./getline OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' make[4]: `gl.a' is up to date. make -f Makefile.win chartables.h make[5]: `chartables.h' is up to date. make -f Makefile.win makeMakedeps make -f Makefile.win libpcre.a make[5]: `libpcre.a' is up to date. make[4]: Nothing to be done for `all'. make[4]: Nothing to be done for `all'. gcc -shared -s -mwindows -o R.dll R.def console.o dataentry.o dynload.o edit.o editor.o embeddedR.o extra.o opt.o pager.o preferences.o psignal.o rhome.o rt_complete.o rui.o run.o shext.o sys-win32.o system.o dos_glob.o e_pow.o ../main/libmain.a ../appl/libappl.a ../nmath/libnmath.a graphapp/ga.a getline/gl.a ../extra/xdr/libxdr.a ../extra/zlib/libz.a ../extra/pcre/libpcre.a ../extra/bzip2/libbz2.a ../extra/intl/libintl.a ../extra/trio/libtrio.a dllversion.o -L. -lg2c -lRblas -lcomctl32 -lversion console.o:console.c:(.text+0x44): undefined reference to `mbrtowc' console.o:console.c:(.text+0x9d): undefined reference to `mbrtowc' console.o:console.c:(.text+0x14f): undefined reference to `mbrtowc' console.o:console.c:(.text+0x6b1): undefined reference to `mbrtowc' console.o:console.c:(.text+0xc7c): undefined reference to `mbrtowc' console.o:console.c:(.text+0xcff): more undefined references to `mbrtowc' follow extra.o:extra.c:(.text+0x2240): undefined reference to `mallinfo' extra.o:extra.c:(.text+0x226f): undefined reference to `mallinfo' ../main/libmain.a(memory.o):memory.c:(.text+0x260): undefined reference to `Rm_free' ../main/libmain.a(memory.o):memory.c:(.text+0xa80): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0xbde): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0xc3d): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0xf4d): undefined reference to `Rm_calloc' ../main/libmain.a(memory.o):memory.c:(.text+0xfae): undefined reference to `Rm_realloc' ../main/libmain.a(memory.o):memory.c:(.text+0xfc8): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x2cbc): undefined reference to `Rm_free' ../main/libmain.a(memory.o):memory.c:(.text+0x35e0): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x38ef): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x3d3c): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x403f): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x462d): undefined reference to `Rm_malloc' ../main/libmain.a(memory.o):memory.c:(.text+0x4649): more undefined references to `Rm_malloc' follow ../main/libmain.a(memory.o):memory.c:(.text+0xffc): undefined reference to `Rm_free' ../main/libmain.a(printutils.o):printutils.c:(.text+0x6bd): undefined reference to `mbrtowc' ../main/libmain.a(printutils.o):printutils.c:(.text+0x9ce): undefined reference to `mbrtowc' ../main/libmain.a(engine.o):engine.c:(.text+0x7d6f): undefined reference to `mbrtowc' ../main/libmain.a(engine.o):engine.c:(.text+0x8016): undefined reference to `wcrtomb' ../main/libmain.a(plotmath.o):plotmath.c:(.text+0xfe7): undefined reference to `wcrtomb' ../main/libmain.a(plotmath.o):plotmath.c:(.text+0x1c11): undefined reference to `mbrtowc' ../main/libmain.a(plotmath.o):plotmath.c:(.text+0x24d0): undefined reference to `wcrtomb' ../main/libmain.a(arithmetic.o):arithmetic.c:(.text+0x2e7a): undefined reference to `expm1' ../main/libmain.a(gram.o):gram.c:(.text+0x7d): undefined reference to `mbrtowc' ../main/libmain.a(gram.o):gram.c:(.text+0x392): undefined reference to `mbrtowc' ../main/libmain.a(plot.o):plot.c:(.text+0x910): undefined reference to `mbrtowc' ../main/libmain.a(util.o):util.c:(.text+0x3806): undefined reference to `mbrtowc' ../main
Re: [R] Catenating factors.
On Wed, 2007-05-23 at 13:38 +1200, Rolf Turner wrote: > > I was recently asked by one of new colleagues how to combine, or catentate, > or concatentate two factors. If x and y are factors, doing c(x,y) appears > to coerce x and y to numeric mode before catenating them. So what does one > do if one wants the result to be a factor whose levels are the union of the > levels of x and y? I vaguely recall seeing this discussed in r-help, but I > can't find anything on it there, nor in the FAQ. > > Am I missing something obvious? Rolf, I think that this thread from last November on R-devel may be helpful: http://tolstoy.newcastle.edu.au/R/e2/devel/06/11/1130.html 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.
Re: [R] problem with read.table
On May 22, 2007, at 9:41 PM, Alex Tsoi wrote: > Dear all, > > I try to use read.table to get the data from a tab delimited file, > and some > of the data is shown below: [snip] > > and it means that whenever read.table reads ' , it skips the next > line, > until it reads ' again > > Could anyone show me how to solve this kind of problem ? > > I greatly appreciate for any suggestion. Thanks. You might want to have a look at ?read.table for more details, but the following should do it: test <- read.table("data.txt", colClasses = "character", sep="\t", quote="\"") Essentially by default read.table sees both " and ' as quote delimiters. In your data, you only want " as a quote delimiter. > Alex Tsoi- Haris Skiadas Department of Mathematics and Computer Science Hanover College __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with read.table
use quote="" to disable the effect of ' cheers Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 read.table
Dear all, I try to use read.table to get the data from a tab delimited file, and some of the data is shown below: 3185heterogeneous nuclear ribonucleoprotein F 3187heterogeneous nuclear ribonucleoprotein H1 (H) 3188heterogeneous nuclear ribonucleoprotein H2 (H') 3189heterogeneous nuclear ribonucleoprotein H3 (2H9) 3190heterogeneous nuclear ribonucleoprotein K /// heterogeneous nuclear ribonucleoprotein K 3190heterogeneous nuclear ribonucleoprotein K 3309"heat shock 70kDa protein 5 (glucose-regulated protein, 78kDa)" 3310heat shock 70kDa protein 6 (HSP70B') 3312heat shock 70kDa protein 8 3313heat shock 70kDa protein 9B (mortalin-2) 6302sarcoma amplified sequence 6303spermidine/spermine N1-acetyltransferase 6304special AT-rich sequence binding protein 1 (binds to nuclear matrix/scaffold-associating DNA's) 6305SET binding factor 1 6307sterol-C4-methyl oxidase-like 6625Small nuclear ribonucleoprotein 70kDa polypeptide (RNP antigen) 6626small nuclear ribonucleoprotein polypeptide A 6627small nuclear ribonucleoprotein polypeptide A' 6628small nuclear ribonucleoprotein polypeptides B and B1 6629Small nuclear ribonucleoprotein polypeptide B'' when I use > test <- read.table("data.txt", colClasses = "character", sep="\t") I found out that "test" only has certain records: 3185heterogeneous nuclear ribonucleoprotein F 3187heterogeneous nuclear ribonucleoprotein H1 (H) 3188heterogeneous nuclear ribonucleoprotein H2 (H') 3312heat shock 70kDa protein 8 3313heat shock 70kDa protein 9B (mortalin-2) 6302sarcoma amplified sequence 6303spermidine/spermine N1-acetyltransferase 6304special AT-rich sequence binding protein 1 (binds to nuclear matrix/scaffold-associating DNA's) 6628small nuclear ribonucleoprotein polypeptides B and B1 6629Small nuclear ribonucleoprotein polypeptide B'' and it means that whenever read.table reads ' , it skips the next line, until it reads ' again Could anyone show me how to solve this kind of problem ? I greatly appreciate for any suggestion. Thanks. Alex Tsoi- [[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] Catenating factors.
I was recently asked by one of new colleagues how to combine, or catentate, or concatentate two factors. If x and y are factors, doing c(x,y) appears to coerce x and y to numeric mode before catenating them. So what does one do if one wants the result to be a factor whose levels are the union of the levels of x and y? I vaguely recall seeing this discussed in r-help, but I can't find anything on it there, nor in the FAQ. Am I missing something obvious? cheers, Rolf [EMAIL PROTECTED] ## Attention:\ This e-mail message is privileged and confidenti...{{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] saving datafreame object problem
On 22/05/2007 8:25 PM, [EMAIL PROTECTED] wrote: > Do I miss here something? > > > dtaa = > read.table("http://www.ats.ucla.edu/stat/mplus/examples/ma_snijders/mlbook1.dat";, > > sep=",") > > head(dtaa) # shows the data as it should be > > save(dtaa,"dtaa",file="c:/dtaa") Besides what Thomas said: Just give the object once. You don't need its name separately from its value: save(dtaa, file="c:/dtaa") The way you did it you will save the object twice. > > d = load("c:/dtaa") > > head(d) # all data is lost, it only shows [1] "dtaa" "dtaa" That's why the name was listed twice here. Duncan Murdoch > > > Thanks for your hint on this. > > Toby > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] saving datafreame object problem
On Tue, 22 May 2007, [EMAIL PROTECTED] wrote: > Do I miss here something? > Yes. > > dtaa = > read.table("http://www.ats.ucla.edu/stat/mplus/examples/ma_snijders/mlbook1.dat";, > sep=",") > > head(dtaa) # shows the data as it should be > > save(dtaa,"dtaa",file="c:/dtaa") > > d = load("c:/dtaa") > >From ?load Value: A character vector of the names of objects created, invisibly. So d is correct. Try ls() to find the loaded data. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] saving datafreame object problem
Do I miss here something? dtaa = read.table("http://www.ats.ucla.edu/stat/mplus/examples/ma_snijders/mlbook1.dat";, sep=",") head(dtaa) # shows the data as it should be save(dtaa,"dtaa",file="c:/dtaa") d = load("c:/dtaa") head(d) # all data is lost, it only shows [1] "dtaa" "dtaa" Thanks for your hint on this. Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Please, remind a function name
Vladimir Eremeev wrote: > Sorry, I'm stuck. :) > > I am writing a function, which would fit either one linear model or another > one, depending on its argument model.type. > And I don't want to use several if's, because R allows doing it with much > more beauty. > > That is I am looking for prettier alternative to the following > > AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this > argument has any other value > [ do some stuff] > > if(model.type=="S") model<-lm( [s.model formula] ) > else if (model.type == "HK") model<-lm([hk.model formula]) > else model<-NULL > > return(model) > } > > I was looking at "switch", but didn't come to solution. Sorry <: Er, what's wrong with model <- switch(model.type, S = lm( [s.model formula] ), HK = lm([hk.model formula] )) ? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Please, remind a function name
Note that a significant difference between the two solutions is that the OO solution allows new methods corresponding to "method=" to be added without changing the function holding the statements. On 5/22/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: > > My solution (after a cup of coffee :) ): > > model.formula<-switch(model.type,S=[s-model formula],HK=[hk-model formula]) > model<-lm(model.formula) > > > Gabor Grothendieck wrote: > > > > You could use the class dispatching mechanism: > > > > > > mymodel <- function(a, b, method = "S") { > > .Class <- method > > NextMethod("mymodel") > > } > > > > mymodel.S <- function(a, b, method = "S") cat("S:", a, b, method, "\n") > > mymodel.HK <- function(a, b, method = "S") cat("HK:", a, b, method, "\n") > > > > mymodel(1:3, 1:4) > > mymodel(1:3, 1:4, "S") > > mymodel(1:3, 1:4, "HK") > > > > > > > > On 5/22/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: > >> > >> Sorry, I'm stuck. :) > >> > >> I am writing a function, which would fit either one linear model or > >> another > >> one, depending on its argument model.type. > >> And I don't want to use several if's, because R allows doing it with much > >> more beauty. > >> > >> That is I am looking for prettier alternative to the following > >> > >> AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this > >> argument has any other value > >> [ do some stuff] > >> > >> if(model.type=="S") model<-lm( [s.model formula] ) > >> else if (model.type == "HK") model<-lm([hk.model formula]) > >> else model<-NULL > >> > >> return(model) > >> } > >> > >> I was looking at "switch", but didn't come to solution. Sorry <:) > > > > > > -- > View this message in context: > http://www.nabble.com/Please%2C-remind-a-function-name-tf3797444.html#a10750855 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] Manipulating the sizes of multiple screens
Hi, I used split.screen command to creaye 5 screens, 4 screens contain a plot each, the fifth screen is designated to a legend. I am having difficulties setting the dimensions of the screens in a way that would allow me to have the screen dedicated to the legend smaller. I end up with a very awkward aspect at the end: 4 small plots with a big space for the legend. The gend needs to be at the top of the 4 graphs, it's common legend for the 4 graphs. I have tried manipulating the margins of each individual screen, but couldn't obtain the desired aspect. Thank you very much in advance for you help. Best Regards, J You snooze, you lose. Get messages ASAP with AutoCheck __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] German Map in package maps
On 22/05/2007 2:58 PM, Maja Schroeter wrote: > Hello everybody, > > I'm an absolute newbe in R, so please be gentle to me. > > I am looking for a german map in the package maps by Becker and Wilks. > > After that I want to draw the German cities from world.cities of this > package in the map and want to draw further a line from Berlin to Munich. > > Has anybody an idea? How about this: library(mapdata) map("worldHires", "Germany") map.cities(country="Germany") Berlin <- subset(world.cities, name=="Berlin" & country.etc=="Germany") Munich <- subset(world.cities, name=="Munich" & country.etc=="Germany") segments(Berlin$long, Berlin$lat, Munich$long, Munich$lat) Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parallel processes
You can find a decent tutorial on using RMPI here: http://ace.acadiau.ca/math/ACMMaC/Rmpi/index.html On 22-May-07, at 3:46 PM, Kuhn, Max wrote: > Erin, > > There is a "snow" package (note the case) and also a few others. > > Rlsf, is specific to grids/clusters that use the LSF queue system. > > More generally, the nws package is more sophisticated and should > work on > most systems. Also, there is Rmpi (which I haven't used). > > Max > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of hodgess > Sent: Tuesday, May 22, 2007 1:01 PM > To: [EMAIL PROTECTED] > Subject: [R] Parallel processes > > > Dear R People: > > I was wondering if there were any packages for parallel > programming in > R. > > According to the R-help, at one time there was a package called SNOW. > It doesn't seem > to exist anymore. > > Any help would be much appreciated! > > Sincerely, > Erin Hodgess > mailto: [EMAIL PROTECTED] > > > [[alternative(swapped) 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. > > -- > LEGAL NOTICE\ Unless expressly stated otherwise, this messag... > {{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. -- Mike Lawrence Graduate Student, Dalhousie University Department of Psychology http://myweb.dal.ca/mc973993 "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] German Map in package maps
On Wed, 23 May 2007, Maja Schröter wrote: > Hello everybody, > > I'm an absolute newbe in R, so please be gentle to me. > > I am looking for a german map in the package maps by Becker and Wilks. > > After that I want to draw the German cities from world.cities of this > package in the map and want to draw further a line from Berlin to Munich. > > Has anybody an idea? > There is no germany-only map in the maps databases, but the following might be close to what you want: > library(mapdata) # the world database in the maps package # probably isn't high enough resolution > map("worldHires", "Germany") > map.cities(country="Germany", minpop=1e6, capital=1) > lines(world.cities[world.cities$name %in% c("Berlin", "Munich") & world.cities$country=="Germany", c("long", "lat")]) > HTH Ray Brownrigg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 in packages... a list?
On 5/22/07, Adrian Dusa <[EMAIL PROTECTED]> wrote: > Dear all, > Is it possible to add a list in the data folder when creating a new package? Yes. > In other words, is data in packages restricted to data.frame only? Well section 1.1.3 of the manual "Writing R Extensions" say, in part, "Currently, data files can have one of three types as indicated by their extension ..." so the answer to your question is no. Perhaps reading that section of the manual will help. (Hint: you want to create an R expression that returns the list you want.) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Please, remind a function name
My solution (after a cup of coffee :) ): model.formula<-switch(model.type,S=[s-model formula],HK=[hk-model formula]) model<-lm(model.formula) Gabor Grothendieck wrote: > > You could use the class dispatching mechanism: > > > mymodel <- function(a, b, method = "S") { > .Class <- method > NextMethod("mymodel") > } > > mymodel.S <- function(a, b, method = "S") cat("S:", a, b, method, "\n") > mymodel.HK <- function(a, b, method = "S") cat("HK:", a, b, method, "\n") > > mymodel(1:3, 1:4) > mymodel(1:3, 1:4, "S") > mymodel(1:3, 1:4, "HK") > > > > On 5/22/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: >> >> Sorry, I'm stuck. :) >> >> I am writing a function, which would fit either one linear model or >> another >> one, depending on its argument model.type. >> And I don't want to use several if's, because R allows doing it with much >> more beauty. >> >> That is I am looking for prettier alternative to the following >> >> AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this >> argument has any other value >> [ do some stuff] >> >> if(model.type=="S") model<-lm( [s.model formula] ) >> else if (model.type == "HK") model<-lm([hk.model formula]) >> else model<-NULL >> >> return(model) >> } >> >> I was looking at "switch", but didn't come to solution. Sorry <:) > > -- View this message in context: http://www.nabble.com/Please%2C-remind-a-function-name-tf3797444.html#a10750855 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Parallel processes
There are R interfaces to MPI and PVM on CRAN, which are Rmpi and RPVM, respectively. hodgess wrote: > > I was wondering if there were any packages for parallel programming in R. > > According to the R-help, at one time there was a package called SNOW. It > doesn't seem > to exist anymore. > -- View this message in context: http://www.nabble.com/Parallel-processes-tf3798421.html#a10750815 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] basic problem but can't solve it
aggregate(Measure, list(Month=Month), mean) --- Benoit Chemineau <[EMAIL PROTECTED]> wrote: > Hello, >I have a basic problem but i can't figure it out > with the > table underneath. I would like to compute monthly > averages. >I would like to have the average measure for > month #5 for the first > three rows (the same number in the first three > lines) and the average > measure for month #6 for the last four rows ((the > same number in the first > three lines) in a separate vesctor (let's call it > 'result') >I tried to use a "while" statement inside a "for" > loop but it doesn't > seem to work. >Can someone please help me with this ? > >Measure Month >2.28 5 >14.04 5 >0.60 5 >0.21 6 >0.96 6 >0.75 6 >1.28 6 > >Thank you ! > > [[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] Reducing the size of pdf graphics files produced with R
On Tue, May 22, 2007 at 01:06:06PM -0400, Chabot Denis wrote: > Thank you Prof. Ripley. > > Believe me, I do not have the skills to contribute such a thing as a > stream compressor and I DO appreciate the work and usefulness of the > pdf device as it is. I do most of my plots with pdf device, the rest > with quartz (especially when I'm not sure I'll want to save a plot) > and (rarely) png when the pdf output is too large or for > compatibility with microsoft applications. > > I find the statement you took from the help page promising: I often > include these large plots into LaTeX, so I'll investigate what form > of compression pdftex can do. > > Sincerely, > > Denis > Le 07-05-22 à 12:47, Prof Brian Ripley a écrit : > > >> From the help page > > > > 'pdf' writes uncompressed PDF. It is primarily intended for > > producing PDF graphics for inclusion in other documents, and > > PDF-includers such as 'pdftex' are usually able to handle > > compression. > > > > If you are able to contribute a stream compressor, R will produce > > smaller plots. Otherwise it is unlikely to happen (and it any case > > would be a > > smaller contribution than that of the author of pdf(), who is quite > > happy with external compressors). > > > > Acrobat does other things (not all of which it tells you about), > > but compression is the main advantage. > > > > On Tue, 22 May 2007, Chabot Denis wrote: > > > >> Hi, > >> > >> Without trying to print 100 points (see >> finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often print > >> maps for which I do not want to loose too much of coastline detail, > >> and/or plots with 1000-5000 points (yes, some are on top of each > >> other, but using transparency (i.e. rgb colors with alpha > >> information) this actually comes through as useful information. > >> > >> But the files are large (not as large as in the thread above of > >> course, 800 KB to about 2 MB), especially when included in a LaTeX > >> document by the dozen. > >> > >> Acrobat (not the reader, the full program) has an option "reduce file > >> size". I don't know what it does, but it shrinks most of my plots to > >> about 30% or original size, and I cannot detect any loss of detail > >> even when zooming several times. But it is a pain to do this with > >> Acrobat when you generate many plots... And you need to buy Acrobat. > >> > >> Is this something the pdf device could do in a future version? I > >> tried the "million points" example from the thread above and the 55 > >> MB file was reduced to 6.9 MB, an even better shrinking I see on my > >> usual plots. > >> > >> > >> Denis Chabot > >> > >> __ > >> R-help@stat.math.ethz.ch mailing list > >> https://stat.ethz.ch/mailman/listinfo/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. as an attempt to suggest something more helpful than "do write the compressor yourself if you have a problem with pdf()": as you are using MacOS X, you'll have ghostscript installed anyway. so try in R `dev2bitmap' with `type =pdfwrite'. I believe `gs' _does_ include compression. a quick test showed at least a reduction by about a factor of 2 relative to `pdf()'. probably one can fiddle with the ghostscript settings (cf. e.g. `Ps2pdf.htm' in the ghostscipt docs: you can adjust the resolution for images in the pdf file) to improve this, so as a last resort you could indeed export the graphics as postscript and do the conversion to `pdf' by adjusting the `ps2pdf' switches. but even with the default settings the pdf produced via dev2bitmap/ghostscript is the better solution. apart from file size I by and then ran into problems when converting `pdf()' output to postscript later on, for instance. hth, joerg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] German Map in package maps
Hello everybody, I'm an absolute newbe in R, so please be gentle to me. I am looking for a german map in the package maps by Becker and Wilks. After that I want to draw the German cities from world.cities of this package in the map and want to draw further a line from Berlin to Munich. Has anybody an idea? Thank you so much and sorry for the question! Best regards from Berlin, Maja! -- View this message in context: http://www.nabble.com/German-Map-in-package-maps-tf3798578.html#a10745386 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Parallel processes
Erin, There is a "snow" package (note the case) and also a few others. Rlsf, is specific to grids/clusters that use the LSF queue system. More generally, the nws package is more sophisticated and should work on most systems. Also, there is Rmpi (which I haven't used). Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of hodgess Sent: Tuesday, May 22, 2007 1:01 PM To: [EMAIL PROTECTED] Subject: [R] Parallel processes Dear R People: I was wondering if there were any packages for parallel programming in R. According to the R-help, at one time there was a package called SNOW. It doesn't seem to exist anymore. Any help would be much appreciated! Sincerely, Erin Hodgess mailto: [EMAIL PROTECTED] [[alternative(swapped) 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. -- LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{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] Parallel processes
On Tue, 22 May 2007, hodgess wrote: > >Dear R People: > > I was wondering if there were any packages for parallel programming in R. > > According to the R-help, at one time there was a package called SNOW. It > doesn't seem > to exist anymore. ??? It's available on CRAN. Best, luke > > Any help would be much appreciated! > > Sincerely, > Erin Hodgess > mailto: [EMAIL PROTECTED] > > > [[alternative(swapped) 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. > -- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Parallel processes
snow still exists, and there is one more package snowFT on CRAN (FT stands for Fault Tolerant) Probably, you didn't find it because of typing its name in capitals. hodgess wrote: > > According to the R-help, at one time there was a package called SNOW. It > doesn't seem > to exist anymore. > -- View this message in context: http://www.nabble.com/Parallel-processes-tf3798421.html#a10750966 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] German Map in package maps
Hello everybody, I'm an absolute newbe in R, so please be gentle to me. I am looking for a german map in the package maps by Becker and Wilks. After that I want to draw the German cities from world.cities of this package in the map and want to draw further a line from Berlin to Munich. Has anybody an idea? Thank you so much and sorry for the question! Best regards from Berlin, Maja! -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error message
install.packages("RMySQL", dep=T) should fix it for you. b ps: The error says RMySQL is the problem... it is not complaining about R itself (although it would not be a bad idea, given that the latest R is v 2.5.0, so it would be a better idea to start by upgrading your R) On May 22, 2007, at 11:59 AM, karen power wrote: > Hi, > > I am trying to install the package exonmap and RMySQL however I keep > getting the following error: > > "Error in library(pkg, character.only = TRUE) : > 'RMySQL' is not a valid package -- installed < 2.0.0?" > > I have R version 2.4.1 so I know its not a version issue. I deleted > and > reinstalled the folders again and the same thing happened. Has anyone > any ideas? > > Thanks, > > Karen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reducing the size of pdf graphics files produced with R
Thank you Sundar, Do plots being so reduced remain object based (i.e. not bitmaps)? Denis Le 07-05-22 à 13:19, Sundar Dorai-Raj a écrit : > You need not buy Acrobat. There are two free software programs that > will compress pdf files: > > http://www.cutepdf.com > http://www.cs.wisc.edu/~ghost/ (and in particular GSView) > > They both allow several levels of compression. > > Thanks, > > --sundar > > Chabot Denis said the following on 5/22/2007 3:32 AM: >> Hi, >> Without trying to print 100 points (see > finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often >> print maps for which I do not want to loose too much of coastline >> detail, and/or plots with 1000-5000 points (yes, some are on top >> of each other, but using transparency (i.e. rgb colors with >> alpha information) this actually comes through as useful >> information. >> But the files are large (not as large as in the thread above of >> course, 800 KB to about 2 MB), especially when included in a >> LaTeX document by the dozen. >> Acrobat (not the reader, the full program) has an option "reduce >> file size". I don't know what it does, but it shrinks most of my >> plots to about 30% or original size, and I cannot detect any loss >> of detail even when zooming several times. But it is a pain to do >> this with Acrobat when you generate many plots... And you need to >> buy Acrobat. >> Is this something the pdf device could do in a future version? I >> tried the "million points" example from the thread above and the >> 55 MB file was reduced to 6.9 MB, an even better shrinking I see >> on my usual plots. >> Denis Chabot >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/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] basic problem but can't solve it
tapply(Measure,Month,mean)[as.character(Month)] -- Christophe Pallier (http://www.pallier.org) On 5/22/07, Benoit Chemineau <[EMAIL PROTECTED]> wrote: > > Hello, >I have a basic problem but i can't figure it out with the > table underneath. I would like to compute monthly averages. >I would like to have the average measure for month #5 for the first > three rows (the same number in the first three lines) and the average > measure for month #6 for the last four rows ((the same number in the first > three lines) in a separate vesctor (let's call it 'result') >I tried to use a "while" statement inside a "for" loop but it doesn't > seem to work. >Can someone please help me with this ? > >Measure Month >2.28 5 >14.04 5 >0.60 5 >0.21 6 >0.96 6 >0.75 6 >1.28 6 > >Thank you ! > > [[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] basic problem but can't solve it
On Tue, 2007-05-22 at 19:01 +0200, Benoit Chemineau wrote: > Hello, >I have a basic problem but i can't figure it out with the > table underneath. I would like to compute monthly averages. >I would like to have the average measure for month #5 for the first > three rows (the same number in the first three lines) and the average > measure for month #6 for the last four rows ((the same number in the first > three lines) in a separate vesctor (let's call it 'result') >I tried to use a "while" statement inside a "for" loop but it doesn't > seem to work. >Can someone please help me with this ? > >Measure Month >2.28 5 >14.04 5 >0.60 5 >0.21 6 >0.96 6 >0.75 6 >1.28 6 If dat is a data frame containing your data: > dat Measure Month 12.28 5 2 14.04 5 30.60 5 40.21 6 50.96 6 60.75 6 71.28 6 > aggregate(dat$Measure, by = list(Month = dat$Month), mean) Monthx 1 5 5.64 2 6 0.80 > tapply(dat$Measure, dat$Month, mean) 56 5.64 0.80 see ?aggregate and ?tapply for two solutions. The tapply one seems cleaner and easier to get the vector you need, the aggregate version needs an extra step: aggregate(dat$Measure, by = list(Month = dat$Month), mean)$x ^^ Note the $x at the end to subset the object returned by aggregate HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] part or semi-partial correlation
Only trivial if you can find it. Will the package corpcor do you any good? --- [EMAIL PROTECTED] wrote: > Is it possible to conduct part (also called > semi-partial correlation) > with R. The help.search produces no results and > there is also nothing > into the archive, well one post asking what is part > correlation. Just > quickly from Field [Discovering statistics using > spss]: > > "When we do a partial correlation between two > variables, we control > for the effect of a third variable. Specifically, > the effect that the > third variable has on BOTH variables in the > correlation is controlled. > In a semi-partial correlation we control for the > effect that the third > variable has on only one of the variables in the > correlation." > > Apologies if it is a trivial question. Thanks. > > -- > yianni > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] basic problem but can't solve it
Benoit, Try the aggregate() function. -Cody Cody Hamilton, PhD Edwards Lifesciences "Benoit Chemineau" r-help@stat.math.ethz.ch Sent by: cc [EMAIL PROTECTED] at.math.ethz.ch Subject [R] basic problem but can't solve it 05/22/2007 10:01 AM Hello, I have a basic problem but i can't figure it out with the table underneath. I would like to compute monthly averages. I would like to have the average measure for month #5 for the first three rows (the same number in the first three lines) and the average measure for month #6 for the last four rows ((the same number in the first three lines) in a separate vesctor (let's call it 'result') I tried to use a "while" statement inside a "for" loop but it doesn't seem to work. Can someone please help me with this ? Measure Month 2.28 5 14.04 5 0.60 5 0.21 6 0.96 6 0.75 6 1.28 6 Thank you ! [[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] Selecting complementary colours
Dear Thomas, This seems simpler than the solution that I used, so I'll give it a try. Thanks, John On Tue, 22 May 2007 09:01:01 -0700 (PDT) Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Mon, 21 May 2007, John Fox wrote: > > > > In retrospect, I didn't specify the problem clearly: What I want to > be able > > to do is to place text on a background of arbitrary (but known RGB) > colour > > so that the text is legible. I guess that this is better described > as a > > "contrasting" than a "complementary" colour. > > Since luminance contrasts are necessary and sufficient for readable > text, you could use white for dark colors and black for light colors. > > Luminance is roughly proportional to 0.2*(R^2.4)+0.6*(G^2.4), > suggesting something like > > lightdark<-function (color) > { > rgb <- col2rgb(color)/255 > L <- c(0.2, 0.6, 0) %*% rgb > ifelse(L >= 0.2, "#60", "#A0") > } > > This uses a pale yellow for dark backgrounds and a dark blue for > light backgrounds, and it seems to work reasonably well. > > -thomas 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.
Re: [R] Reducing the size of pdf graphics files produced with R
Thank you Prof. Ripley. Believe me, I do not have the skills to contribute such a thing as a stream compressor and I DO appreciate the work and usefulness of the pdf device as it is. I do most of my plots with pdf device, the rest with quartz (especially when I'm not sure I'll want to save a plot) and (rarely) png when the pdf output is too large or for compatibility with microsoft applications. I find the statement you took from the help page promising: I often include these large plots into LaTeX, so I'll investigate what form of compression pdftex can do. Sincerely, Denis Le 07-05-22 à 12:47, Prof Brian Ripley a écrit : >> From the help page > > 'pdf' writes uncompressed PDF. It is primarily intended for > producing PDF graphics for inclusion in other documents, and > PDF-includers such as 'pdftex' are usually able to handle > compression. > > If you are able to contribute a stream compressor, R will produce > smaller plots. Otherwise it is unlikely to happen (and it any case > would be a > smaller contribution than that of the author of pdf(), who is quite > happy with external compressors). > > Acrobat does other things (not all of which it tells you about), > but compression is the main advantage. > > On Tue, 22 May 2007, Chabot Denis wrote: > >> Hi, >> >> Without trying to print 100 points (see > finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often print >> maps for which I do not want to loose too much of coastline detail, >> and/or plots with 1000-5000 points (yes, some are on top of each >> other, but using transparency (i.e. rgb colors with alpha >> information) this actually comes through as useful information. >> >> But the files are large (not as large as in the thread above of >> course, 800 KB to about 2 MB), especially when included in a LaTeX >> document by the dozen. >> >> Acrobat (not the reader, the full program) has an option "reduce file >> size". I don't know what it does, but it shrinks most of my plots to >> about 30% or original size, and I cannot detect any loss of detail >> even when zooming several times. But it is a pain to do this with >> Acrobat when you generate many plots... And you need to buy Acrobat. >> >> Is this something the pdf device could do in a future version? I >> tried the "million points" example from the thread above and the 55 >> MB file was reduced to 6.9 MB, an even better shrinking I see on my >> usual plots. >> >> >> Denis Chabot >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/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] Parallel processes
Dear R People: I was wondering if there were any packages for parallel programming in R. According to the R-help, at one time there was a package called SNOW. It doesn't seem to exist anymore. Any help would be much appreciated! Sincerely, Erin Hodgess mailto: [EMAIL PROTECTED] [[alternative(swapped) 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] error message
Hi Karen -- This sounds like a Bioconductor question, and should be sent to the Bioconductor list. http://www.bioconductor.org/docs/mailList.html Likely the complaint is about RMySQL being too old, rather than R. The idea of 'reinstalling folders' doesn't sound like a good strategy for updating packages; for Bioconductor see http://www.bioconductor.org/docs/install-howto.html likely > source("http://www.bioconductor.org/biocLite.R";) > biocLite("exonmap") does the trick. If not and the problem seems to be RMySQL, then try > biocLite("RMySQL") or in a more robust way update all of your currently installed packages with > library("Biobase") > update.packages(repos=biocReposList()) Finally, please provide a more informative subject line and the output of > sessionInfo() so that the community can get a better understanding of the platform and packages you're using, and hence the source of your problems. Best, Martin karen power <[EMAIL PROTECTED]> writes: > Hi, > > I am trying to install the package exonmap and RMySQL however I keep > getting the following error: > > "Error in library(pkg, character.only = TRUE) : > 'RMySQL' is not a valid package -- installed < 2.0.0?" > > I have R version 2.4.1 so I know its not a version issue. I deleted and > reinstalled the folders again and the same thing happened. Has anyone > any ideas? > > Thanks, > > Karen > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Reducing the size of pdf graphics files produced with R
You need not buy Acrobat. There are two free software programs that will compress pdf files: http://www.cutepdf.com http://www.cs.wisc.edu/~ghost/ (and in particular GSView) They both allow several levels of compression. Thanks, --sundar Chabot Denis said the following on 5/22/2007 3:32 AM: > Hi, > > Without trying to print 100 points (see finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often print > maps for which I do not want to loose too much of coastline detail, > and/or plots with 1000-5000 points (yes, some are on top of each > other, but using transparency (i.e. rgb colors with alpha > information) this actually comes through as useful information. > > But the files are large (not as large as in the thread above of > course, 800 KB to about 2 MB), especially when included in a LaTeX > document by the dozen. > > Acrobat (not the reader, the full program) has an option "reduce file > size". I don't know what it does, but it shrinks most of my plots to > about 30% or original size, and I cannot detect any loss of detail > even when zooming several times. But it is a pain to do this with > Acrobat when you generate many plots... And you need to buy Acrobat. > > Is this something the pdf device could do in a future version? I > tried the "million points" example from the thread above and the 55 > MB file was reduced to 6.9 MB, an even better shrinking I see on my > usual plots. > > > Denis Chabot > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] Reducing the size of pdf graphics files produced with R
>From the help page 'pdf' writes uncompressed PDF. It is primarily intended for producing PDF graphics for inclusion in other documents, and PDF-includers such as 'pdftex' are usually able to handle compression. If you are able to contribute a stream compressor, R will produce smaller plots. Otherwise it is unlikely to happen (and it any case would be a smaller contribution than that of the author of pdf(), who is quite happy with external compressors). Acrobat does other things (not all of which it tells you about), but compression is the main advantage. On Tue, 22 May 2007, Chabot Denis wrote: > Hi, > > Without trying to print 100 points (see finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often print > maps for which I do not want to loose too much of coastline detail, > and/or plots with 1000-5000 points (yes, some are on top of each > other, but using transparency (i.e. rgb colors with alpha > information) this actually comes through as useful information. > > But the files are large (not as large as in the thread above of > course, 800 KB to about 2 MB), especially when included in a LaTeX > document by the dozen. > > Acrobat (not the reader, the full program) has an option "reduce file > size". I don't know what it does, but it shrinks most of my plots to > about 30% or original size, and I cannot detect any loss of detail > even when zooming several times. But it is a pain to do this with > Acrobat when you generate many plots... And you need to buy Acrobat. > > Is this something the pdf device could do in a future version? I > tried the "million points" example from the thread above and the 55 > MB file was reduced to 6.9 MB, an even better shrinking I see on my > usual plots. > > > Denis Chabot > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] basic problem but can't solve it
Hello, I have a basic problem but i can't figure it out with the table underneath. I would like to compute monthly averages. I would like to have the average measure for month #5 for the first three rows (the same number in the first three lines) and the average measure for month #6 for the last four rows ((the same number in the first three lines) in a separate vesctor (let's call it 'result') I tried to use a "while" statement inside a "for" loop but it doesn't seem to work. Can someone please help me with this ? Measure Month 2.28 5 14.04 5 0.60 5 0.21 6 0.96 6 0.75 6 1.28 6 Thank you ! [[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] Please, remind a function name
You could use the class dispatching mechanism: mymodel <- function(a, b, method = "S") { .Class <- method NextMethod("mymodel") } mymodel.S <- function(a, b, method = "S") cat("S:", a, b, method, "\n") mymodel.HK <- function(a, b, method = "S") cat("HK:", a, b, method, "\n") mymodel(1:3, 1:4) mymodel(1:3, 1:4, "S") mymodel(1:3, 1:4, "HK") On 5/22/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: > > Sorry, I'm stuck. :) > > I am writing a function, which would fit either one linear model or another > one, depending on its argument model.type. > And I don't want to use several if's, because R allows doing it with much > more beauty. > > That is I am looking for prettier alternative to the following > > AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this > argument has any other value > [ do some stuff] > > if(model.type=="S") model<-lm( [s.model formula] ) > else if (model.type == "HK") model<-lm([hk.model formula]) > else model<-NULL > > return(model) > } > > I was looking at "switch", but didn't come to solution. Sorry <:) > > -- > View this message in context: > http://www.nabble.com/Please%2C-remind-a-function-name-tf3797444.html#a10741597 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] R-help with apply and ccf
I understand you to want correlations of corresponding rows (** not ccf, which returns a vector ccf for each pair of rows). If that is so, 1) ... in theory, diag(cor(t(A), t(B)) would work without apply, except 196,000 rows is probably too large, and it is probably too inefficient to compute and then throw away all the off-diagonals anyway. 2. ##Use a 3d array. ar <- array(c(A,B),dim=c(dim(A),2)) ## this can also be done by abind() in the abind package apply(ar,1,function(x)cor(x[,1],x[,2])) ## Value is a vector 3. ## probably simplest and best sapply(seq_along(nrow(a)),function(i)cor(a[i,],b[i,])) ## Note: value is a vector, not an array Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Andric Sent: Tuesday, May 22, 2007 8:35 AM To: r-help@stat.math.ethz.ch Subject: [R] R-help with apply and ccf Dear R gurus, I would like to use the ccf function on two matrices that are each 196000 x 12. Ideally, I want to be able to go row by row for the two matrices using apply for the ccf function and get one 196000 X 1 array output. The apply function though wants only one array, no? Basically, is there a way to use apply when there are two arrays in order to do something like correlation on a row by row basis? Thanks for your help Michael [[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] data in lmtest
Porblem solved! Thanks for the fast response! Thought I updated my packages over the menu already. Greetings Achim Zeileis wrote: > > On Tue, 22 May 2007, Henning Schoelen wrote: > >> > Hi everyone! > > I am beginner in using R, so please excuse easy questions in advance. > > I want to reproduce results from the data available in the lmtest-package. > > Thatâs the failure code I get: > >> data(bondyield) > Warning message: > file 'bondyield.rda' has magic number 'RDX1' >Use of save versions prior to 2 is deprecated > > Looks like you have an old version of lmtest (although you didnt't tell us > so). Please upgrade. > Z > > Can anyone help me? > > Thanks in advance! > > Henning > -- > View this message in context: > http://www.nabble.com/data-in-lmtest-tf3797285.html#a10741036 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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. > > -- View this message in context: http://www.nabble.com/data-in-lmtest-tf3797285.html#a10741779 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Please, remind a function name
Sorry, I'm stuck. :) I am writing a function, which would fit either one linear model or another one, depending on its argument model.type. And I don't want to use several if's, because R allows doing it with much more beauty. That is I am looking for prettier alternative to the following AB2C<-function(a,b,model.type="S") { # or HK, and return NULL if this argument has any other value [ do some stuff] if(model.type=="S") model<-lm( [s.model formula] ) else if (model.type == "HK") model<-lm([hk.model formula]) else model<-NULL return(model) } I was looking at "switch", but didn't come to solution. Sorry <:) -- View this message in context: http://www.nabble.com/Please%2C-remind-a-function-name-tf3797444.html#a10741597 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] svychisq
On Fri, 18 May 2007, Moss, Angela (Dudley PCT) wrote: > Dear All > > I am trying to use svychisq with a two-dimensional table 4 x 5. The > command I am using is > summary(svytable(~dietperception+dietstatus,dudleyls1rake,na.rm=TRUE),"C > hisq") > > It is throwing up an error message as follows: > > Error in NCOL(y) : only 0's may be mixed with negative subscripts I can't reproduce this problem at all. I've tried tables with zero cells, with and without raking. The na.rm= argument to svytable() can't be helping, since svytable() doesn't have an na.rm argument. Does the same thing happen if you call svychisq() directly rather than via summary(svytable())? -thomas 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] Selecting complementary colours
"John Fox" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The object is to get contrasting colours, so that > when one is plotted over the other, the two will be readily > distinguishable. A simple approach to contrast is to compute a mean intensity by taking the mean of the three RGB components (should be 0..255) and then going with either "black" or "white" -- whichever one is "farthest" away. Look at the Color Chart with contrasting numbers http://research.stowers-institute.org/efg/R/Color/Chart/index.htm or http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf efg Earl F. Glynn Stowers Institute for Medical Research __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 in lmtest
On Tue, 22 May 2007, Henning Schoelen wrote: > Hi everyone! I am beginner in using R, so please excuse easy questions in advance. I want to reproduce results from the data available in the lmtest-package. Thatâs the failure code I get: > data(bondyield) Warning message: file 'bondyield.rda' has magic number 'RDX1' Use of save versions prior to 2 is deprecated Looks like you have an old version of lmtest (although you didnt't tell us so). Please upgrade. Z Can anyone help me? Thanks in advance! Henning -- View this message in context: http://www.nabble.com/data-in-lmtest-tf3797285.html#a10741036 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] "welcome" message upon loading data
Hi Simon -- ?data indicates that the first file looked for is mydata.R, and then mydata.RData and so on. So add a file mydata.R to your data directory that contains R code to print a message and then loads the data. This hack is used in Bioconductor, e.g., the Biobase package http://bioconductor.org/packages/2.0/bioc/html/Biobase.html to indicated that some data sets are deprecated. Martin simon bond <[EMAIL PROTECTED]> writes: > Dear R-help, > > I'm building a package which will contain a data set. I was wondering if it's > possible to make a message appear on the console whenever a user loads the > data. So the console would look like > >>data(mydata) > "Please do not use these data in any publication without permission of the > authors" >> > > Would this message be within the terms of GPL? > > Looking at the ?data page, it seems "packageIQR" might be the way forward, > but I couldn't find any further information on this. > > > Thanks > > > Simon Bond. > > > ___ > > > [[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. -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] convergence of coxfilter and coxph
On Mon, 21 May 2007, carol white wrote: > Hi, coxfilter function in genefilter package uses coxph to fit a model > to filter genes. how come that coxfilter could converge to find a > solution in cox model fitting using a data matrix of 8000 variables and > 600 samples but coxph doesn't converge with the same matrix? coxfilter() fits 8000 one-variable models, which works (for appropriate values of "works"). coxph() refuses to fit one 8000-variable model. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Selecting complementary colours
On Mon, 21 May 2007, John Fox wrote: > > In retrospect, I didn't specify the problem clearly: What I want to be able > to do is to place text on a background of arbitrary (but known RGB) colour > so that the text is legible. I guess that this is better described as a > "contrasting" than a "complementary" colour. Since luminance contrasts are necessary and sufficient for readable text, you could use white for dark colors and black for light colors. Luminance is roughly proportional to 0.2*(R^2.4)+0.6*(G^2.4), suggesting something like lightdark<-function (color) { rgb <- col2rgb(color)/255 L <- c(0.2, 0.6, 0) %*% rgb ifelse(L >= 0.2, "#60", "#A0") } This uses a pale yellow for dark backgrounds and a dark blue for light backgrounds, and it seems to work reasonably well. -thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error message
Hi, I am trying to install the package exonmap and RMySQL however I keep getting the following error: "Error in library(pkg, character.only = TRUE) : 'RMySQL' is not a valid package -- installed < 2.0.0?" I have R version 2.4.1 so I know its not a version issue. I deleted and reinstalled the folders again and the same thing happened. Has anyone any ideas? Thanks, Karen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help with apply and ccf
You could combine them with cbind, and then split the rows again inside the function you're calling with apply. Mat <- cbind(mat1, mat2) apply(Mat, 1, function(x){ row.mat1 <- x[seq_len(length(x)/2)] row.mat2 <- x[length(x)/2 + seq_len(length(x)/2)] cor(row.mat1, row.mat2) }) 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 Michael Andric > Verzonden: dinsdag 22 mei 2007 17:35 > Aan: r-help@stat.math.ethz.ch > Onderwerp: [R] R-help with apply and ccf > > Dear R gurus, > > I would like to use the ccf function on two matrices that are > each 196000 x 12. Ideally, I want to be able to go row by > row for the two matrices using apply for the ccf function and > get one 196000 X 1 array output. The apply function though > wants only one array, no? Basically, is there a way to use > apply when there are two arrays in order to do something like > correlation on a row by row basis? > Thanks for your help > > Michael > > [[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] data in lmtest
Hi everyone! I am beginner in using R, so please excuse easy questions in advance. I want to reproduce results from the data available in the lmtest-package. That’s the failure code I get: > data(bondyield) Warning message: file 'bondyield.rda' has magic number 'RDX1' Use of save versions prior to 2 is deprecated Can anyone help me? Thanks in advance! Henning -- View this message in context: http://www.nabble.com/data-in-lmtest-tf3797285.html#a10741036 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Time series\optimization question not R question
In my previous email, I meant to say: P1 <- A P2 <- atanh(A + beta) So that the model becomes: z_t = tanh(P2)*z_t-1 + epsilon_t - P1*epsilon_t-1 Although I am not sure, how readily the likelihood of the above model can be maximized. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Tuesday, May 22, 2007 11:27 AM To: 'Leeds, Mark (IED)'; r-help@stat.math.ethz.ch Subject: Re: [R] Time series\optimization question not R question Your approach obviously won't give you the same result as when the likelihood is optimized jointly with A and \beta. However, you can maximize the likelihood over \beta for different values of A, which would give you a "profiled" likelihood. Then you pick the \beta and A corresponding to maximum of the profiled likelihood. However, this set of A and \beta need not necessarily satisfy your constraints. If this does happen, you could make a simple parameter transformation from (A, beta) to (P1, P2) that might resolve the problem: P1 <- beta P2 <- atanh(A + beta) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Tuesday, May 22, 2007 10:29 AM To: r-help@stat.math.ethz.ch Subject: [R] Time series\optimization question not R question This is a time series\optimization rather than an R question : Suppose I have an ARMA(1,1) with restrictions such that the coefficient on the lagged epsilon_term is related to the coefficient on The lagged z term as below. z_t =[A + beta]*z_t-1 + epsilon_t - A*epsilon_t-1 So, if I don't have a facility for optimizing with this restriction, is it legal to set A to something and then Optimize just for the beta given the A ? Would this give me the same answer likelihood wise, of optimizing both jointly with the restriction ? This methodology doesn't sound right to me. Thanks. P.S : abs(A + beta) also has to be less than 1 but I was just going to hope for that and not worry about it right now. This is not an offer (or solicitation of an offer) to buy/se...{{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-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R-help with apply and ccf
Dear R gurus, I would like to use the ccf function on two matrices that are each 196000 x 12. Ideally, I want to be able to go row by row for the two matrices using apply for the ccf function and get one 196000 X 1 array output. The apply function though wants only one array, no? Basically, is there a way to use apply when there are two arrays in order to do something like correlation on a row by row basis? Thanks for your help Michael [[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] Time series\optimization question not R question
Your approach obviously won't give you the same result as when the likelihood is optimized jointly with A and \beta. However, you can maximize the likelihood over \beta for different values of A, which would give you a "profiled" likelihood. Then you pick the \beta and A corresponding to maximum of the profiled likelihood. However, this set of A and \beta need not necessarily satisfy your constraints. If this does happen, you could make a simple parameter transformation from (A, beta) to (P1, P2) that might resolve the problem: P1 <- beta P2 <- atanh(A + beta) Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Tuesday, May 22, 2007 10:29 AM To: r-help@stat.math.ethz.ch Subject: [R] Time series\optimization question not R question This is a time series\optimization rather than an R question : Suppose I have an ARMA(1,1) with restrictions such that the coefficient on the lagged epsilon_term is related to the coefficient on The lagged z term as below. z_t =[A + beta]*z_t-1 + epsilon_t - A*epsilon_t-1 So, if I don't have a facility for optimizing with this restriction, is it legal to set A to something and then Optimize just for the beta given the A ? Would this give me the same answer likelihood wise, of optimizing both jointly with the restriction ? This methodology doesn't sound right to me. Thanks. P.S : abs(A + beta) also has to be less than 1 but I was just going to hope for that and not worry about it right now. This is not an offer (or solicitation of an offer) to buy/se...{{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.
Re: [R] [R-SIG-Finance] readcsvIts
Thanks. This appears to do the trick. Best regards, Costas -Original Message- From: Armstrong, Whit [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 22, 2007 6:14 PM To: Vorlow Constantinos Cc: [EMAIL PROTECTED] Subject: RE: [R-SIG-Finance] readcsvIts I believe you need: its(readcsvIts("brenthf.csv",informat="%d/%m/%Y %H:%S")) > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Vorlow Constantinos > Sent: Tuesday, May 22, 2007 10:52 AM > To: r-help@stat.math.ethz.ch > Cc: [EMAIL PROTECTED] > Subject: [R-SIG-Finance] readcsvIts > > Hello, > > I am trying to read a .CSV file from Bloomberg of prices (for an "its" > series) of the following format: > > Date Price > 23/10/2006 09:59 57.291 > 23/10/2006 10:01 57.221 > 23/10/2006 10:02 57.201 > 23/10/2006 10:03 57.231 > 23/10/2006 10:04 57.191 > 23/10/2006 10:05 57.191 > 23/10/2006 10:06 57.141 > 23/10/2006 10:07 57.081 > > > I get the following: > > > its.format("%d/%m/%Y %X") > [1] "%d/%m/%Y %X" > > brent<-its(readcsvIts(filename="brenthf.csv")) > Error in validObject(.Object) : invalid class "its" object: > Missing values in dates > > > > What am I doing wrong? Used %H:%S as well but nothing improved... > > The csv file looks fine... > > Using the latest versions of R and its library on windows XP. > > Thanks in advance, > Costas > > --- > tel: +30-210-3337273 (ext 17273) > fax: +30-210-3337687 > > > > > Disclaimer: > This e-mail is confidential. If you are not the intended > recipient, you should not copy it, re-transmit it, use it or > disclose its contents, but should return it to the sender > immediately and delete the copy from your system. > EFG Eurobank Ergasias S.A. is not responsible for, nor > endorses, any opinion, recommendation, conclusion, > solicitation, offer or agreement or any information contained > in this communication. > EFG Eurobank Ergasias S.A. cannot accept any responsibility > for the accuracy or completeness of this message as it has > been transmitted over a public network. If you suspect that > the message may have been intercepted or amended, please call > the sender. > > > [[alternative HTML version deleted]] > > ___ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. > -- If you want to post, subscribe first. > This e-mail message is intended only for the named recipient(s) above. It may contain confidential information. If you are not the intended recipient you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and delete the message and any attachment(s) from your system. Thank you. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] readcsvIts
Hello, I am trying to read a .CSV file from Bloomberg of prices (for an "its" series) of the following format: Date Price 23/10/2006 09:59 57.291 23/10/2006 10:01 57.221 23/10/2006 10:02 57.201 23/10/2006 10:03 57.231 23/10/2006 10:04 57.191 23/10/2006 10:05 57.191 23/10/2006 10:06 57.141 23/10/2006 10:07 57.081 I get the following: > its.format("%d/%m/%Y %X") [1] "%d/%m/%Y %X" > brent<-its(readcsvIts(filename="brenthf.csv")) Error in validObject(.Object) : invalid class "its" object: Missing values in dates > What am I doing wrong? Used %H:%S as well but nothing improved... The csv file looks fine... Using the latest versions of R and its library on windows XP. Thanks in advance, Costas --- tel: +30-210-3337273 (ext 17273) fax: +30-210-3337687 Disclaimer: This e-mail is confidential. If you are not the intended recipient, you should not copy it, re-transmit it, use it or disclose its contents, but should return it to the sender immediately and delete the copy from your system. EFG Eurobank Ergasias S.A. is not responsible for, nor endorses, any opinion, recommendation, conclusion, solicitation, offer or agreement or any information contained in this communication. EFG Eurobank Ergasias S.A. cannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. If you suspect that the message may have been intercepted or amended, please call the sender. [[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] R2 always increases as variables are added?
On 5/21/07, Alberto Monteiro <[EMAIL PROTECTED]> wrote: > Paul Lynch wrote: > > > > I don't think it makes sense to compare models with > > and without an intercept term. (Also, I don't know what the point of > > using a model without an intercept term would be, but that is > > probably just my ignorance.) > > > Suppose that you are 100% sure that the intercept term is zero, or > so insignifantly small as not to matter. For example, if you are > measuring the density of some material, and you determine a lot > of pairs (mass, volume), you know that mass = density * volume, > with intercept zero. > In that case, you are 100% sure that the intercept *should* be zero, but you aren't 100% sure that the measurements have a best fit with intercept zero. There could have been some systematic error that is throwing things off. It seems safer to leave the intercept in and let the data show that the intercept is insignificantly small. However, I don't really know enough to know whether that is always the best approach. (And given that R provides a facility for excluding the intercept, I suspect there must be some good reason for doing so in some circumstances.) -- Paul Lynch Aquilent, Inc. National Library of Medicine (Contractor) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] rewrite a data file use write.table(), count.fields() show different pattern, any suggestion appreciated.
On Tue, 22 May 2007, Yong Wang wrote: > Thank you for the suggestion, Dr. Ripley I made no suggestion: I asked a question you have not answered. > However, I am a little bit confused. My understanding is that you > suspect the should-be-quoted fields (factor or character fields) > contains tabs. > > if this is the case, count.fields() should detect the tab, > read.table(sep="t\") should read with the same awareness, and if > write.table(sep"\t") write and seperate with tab those fields as > acknowldged by read.table(sep="t\"), the two field counts should be > the same. There are too many 'shoulds' in that sentence, and one of them is incorrect. Consider: > count.fields("test.dat", sep="\t") [1] 3 > A <- read.table("test.dat", sep="\t") > ncol(A) [1] 3 > write.table(A,"test2.dat", eol="\n",sep="\t",quote=F,row.names=F, col.names=F) > count.fields("test2.dat", sep="\t") [1] 4 > write.table(A,"test3.dat", eol="\n",sep="\t",row.names=F, col.names=F) > count.fields("test3.dat", sep="\t") [1] 3 and I'll leave you to reconstruct test.dat to ensure you understand. (BTW, you didn't show us even a sample of your dataset.) > anyway, I will try to redo it per your suggestion. > > Regards > yong > > > On 5/22/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: >> If you write out unquoted fields, how do you know they do not contain >> tabs? >> >> The default is quote=TRUE for a good reason. >> >> On Tue, 22 May 2007, Yong Wang wrote: >> >> > Dear all: >> > >> > I read in a tab delimited dataset, and then write it out as another >> > file as following: I did this simply to make sure I understand the >> > behavior of this command. >> > >> > data<-read.table(file,header=F,sep="\t",fill=T,colClasses="character"); >> > >> write.table(data,file="newdata.txt",eol="\n",sep="\t",quote=F,row.names=F); >> > >> > >> > cf1 <- count.fields(newdata.txt, sep="\t") >> > table(cf1) >> > 13 17 23 >> > 10 126 5445 >> > >> > # is different to >> > >> > cf2 <- count.fields(file,sep="\t") >> > 13 17 2333 >> > 10 106 5433 32 >> > >> > the worst problem is the maximal value of cf1 (33) is larger than the >> > maximal value of cf2 (23) which is the right number of fields for most >> > rows in the original file. >> > >> > I need to use write.table for some important data manipulation work, >> > your suggestion is >> > highly appreciated. >> > >> > Best Regards >> > >> > __ >> > R-help@stat.math.ethz.ch mailing list >> > https://stat.ethz.ch/mailman/listinfo/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 >> > -- 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] Peter Moser ist außer Haus.
Ich werde ab 22.05.2007 nicht im Büro sein. Ich kehre zurück am 28.05.2007. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] rewrite a data file use write.table(), count.fields() show different pattern, any suggestion appreciated.
Thank you for the suggestion, Dr. Ripley However, I am a little bit confused. My understanding is that you suspect the should-be-quoted fields (factor or character fields) contains tabs. if this is the case, count.fields() should detect the tab, read.table(sep="t\") should read with the same awareness, and if write.table(sep"\t") write and seperate with tab those fields as acknowldged by read.table(sep="t\"), the two field counts should be the same. anyway, I will try to redo it per your suggestion. Regards yong On 5/22/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > If you write out unquoted fields, how do you know they do not contain > tabs? > > The default is quote=TRUE for a good reason. > > On Tue, 22 May 2007, Yong Wang wrote: > > > Dear all: > > > > I read in a tab delimited dataset, and then write it out as another > > file as following: I did this simply to make sure I understand the > > behavior of this command. > > > > data<-read.table(file,header=F,sep="\t",fill=T,colClasses="character"); > > write.table(data,file="newdata.txt",eol="\n",sep="\t",quote=F,row.names=F); > > > > > > cf1 <- count.fields(newdata.txt, sep="\t") > > table(cf1) > > 13 17 23 > > 10 126 5445 > > > > # is different to > > > > cf2 <- count.fields(file,sep="\t") > > 13 17 2333 > > 10 106 5433 32 > > > > the worst problem is the maximal value of cf1 (33) is larger than the > > maximal value of cf2 (23) which is the right number of fields for most > > rows in the original file. > > > > I need to use write.table for some important data manipulation work, > > your suggestion is > > highly appreciated. > > > > Best Regards > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/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] Time series\optimization question not R question
This is a time series\optimization rather than an R question : Suppose I have an ARMA(1,1) with restrictions such that the coefficient on the lagged epsilon_term is related to the coefficient on The lagged z term as below. z_t =[A + beta]*z_t-1 + epsilon_t - A*epsilon_t-1 So, if I don't have a facility for optimizing with this restriction, is it legal to set A to something and then Optimize just for the beta given the A ? Would this give me the same answer likelihood wise, of optimizing both jointly with the restriction ? This methodology doesn't sound right to me. Thanks. P.S : abs(A + beta) also has to be less than 1 but I was just going to hope for that and not worry about it right now. This is not an offer (or solicitation of an offer) to buy/se...{{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] Reducing the size of pdf graphics files produced with R
Hi, Without trying to print 100 points (see ), I often print maps for which I do not want to loose too much of coastline detail, and/or plots with 1000-5000 points (yes, some are on top of each other, but using transparency (i.e. rgb colors with alpha information) this actually comes through as useful information. But the files are large (not as large as in the thread above of course, 800 KB to about 2 MB), especially when included in a LaTeX document by the dozen. Acrobat (not the reader, the full program) has an option "reduce file size". I don't know what it does, but it shrinks most of my plots to about 30% or original size, and I cannot detect any loss of detail even when zooming several times. But it is a pain to do this with Acrobat when you generate many plots... And you need to buy Acrobat. Is this something the pdf device could do in a future version? I tried the "million points" example from the thread above and the 55 MB file was reduced to 6.9 MB, an even better shrinking I see on my usual plots. Denis Chabot __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data in packages... a list?
Dear all, Is it possible to add a list in the data folder when creating a new package? In other words, is data in packages restricted to data.frame only? Thank you, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] part or semi-partial correlation
Is it possible to conduct part (also called semi-partial correlation) with R. The help.search produces no results and there is also nothing into the archive, well one post asking what is part correlation. Just quickly from Field [Discovering statistics using spss]: "When we do a partial correlation between two variables, we control for the effect of a third variable. Specifically, the effect that the third variable has on BOTH variables in the correlation is controlled. In a semi-partial correlation we control for the effect that the third variable has on only one of the variables in the correlation." Apologies if it is a trivial question. Thanks. -- yianni __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Stratified Cox proportional Hazard Model
You will have to be more clear about what exactly you are trying to do. I, at least, am quite unsure about what you want. fit <- coxph(Surv(time, status) ~ x1 + strata(x2)) The hazard ratio(s) wrt x1 have the same meaning for a stratified or an unstratified model. If you are asking about hazard ratios for x2 --- there are none. That is the point of a strata; you are declaring a variable to NOT be proportional hazards, and thus there is no single "hazard ratio" that describes it. Terry Therneau __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Boostrap p-value in regression [indirectly related to R]
Dear Wolfgang, I agree that it's preferable to compute the two-sided p-value without assuming symmetry. Another, equivalent, way of thinking about this is to use t^2 for the two-sided test in place of t. BTW, the formula used in my appendix (for the one-sided p-value) is from Davison and Hinkley, I believe, and differs trivially from the one in Efron and Tibshirani. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Viechtbauer Wolfgang (STAT) > Sent: Monday, May 21, 2007 10:41 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Boostrap p-value in regression [indirectly related to R] > > Hello All, > > Despite my preference for reporting confidence intervals, I > need to obtain a p-value for a hypothesis test in the context > of regression using bootstrapping. I have read John Fox's > chapter on bootstrapping regression models and have consulted > Efron & Tibshirani's "An Introduction to the Bootstrap" but I > just wanted to ask the experts here for some feedback to make > sure that I am not doing something wrong. > > Let's take a simplified example where the model includes one > independent variable and the idea is to test H0: beta1 = 0 > versus Ha: beta1 != 0. > > > > ### generate some sample data > > n <- 50 > xi <- runif(n, min=1, max=5) > yi <- 0 + 0.2 * xi + rnorm(n, mean=0, sd=1) > > ### fit simple regression model > > mod <- lm(yi ~ xi) > summary(mod) > b1 <- coef(mod)[2] > t1 <- coef(mod)[2] / coef(summary(mod))[2,2] > > ### 1000 bootstrap replications using (X,Y)-pair resampling > > t1.star <- rep(NA,1000) > > for (i in 1:1000) { > > ids<- sample(1:n, replace=TRUE) > newyi <- yi[ids] > newxi <- xi[ids] > mod<- lm(newyi ~ newxi) > t1.star[i] <- ( coef(mod)[2] - b1) / coef(summary(mod))[2,2] > > } > > ### get bootstrap p-value > > hist(t1.star, nclass=40) > abline(v=t1, lwd=3) > abline(v=-1*t1, lwd=3) > 2 * mean( t1.star > abs(t1) ) > > > > As suggested in the chapter on bootstrapping regression > models by John Fox, the bootstrap p-value is 2 times the > proportion of bootstrap t-values (with b1 subtracted so that > we get the distribution under H0) larger than the absolute > value of the actual t-value observed in the data. > > Doesn't this assume that the bootstrap sampling distribution > is symmetric? And if yes, would it then not be more reasonable to > calculate: > > mean( abs(t1.star) > abs(t1) ) > > or in words: the number of bootstrap t-values that are more > extreme on either side of the bootstrap distribution than the > actual t-value observed? > > Any suggestions or comments would be appreciated! > > -- > Wolfgang Viechtbauer > Department of Methodology and Statistics University of > Maastricht, The Netherlands http://www.wvbauer.com > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] partial correlation function
Hi, after reading the archives I found some methods... adopted and modified one of them to the following. I think it is correct after checking and comparing the results with other software... but if possible someone could have a look and spot any mistakes I would be grateful. Thanks pcor3 <- function (x, test = T, p = 0.05, alternative="two.sided") { nvar <- ncol(x) ndata <- nrow(x) conc <- solve(cor(x)) resid.sd <- 1/sqrt(diag(conc)) pcc <- -sweep(sweep(conc, 1, resid.sd, "*"), 2, resid.sd, "*") #colnames(pcc) <- rownames(pcc) <- colnames(x) if (test) { t.df <- ndata - nvar t <- pcc/sqrt((1 - pcc^2)/t.df) #pcc <- list(coefs = pcc, sig = t > qt(1 - (p/2), df = t.df)); # original statement if (alternative == "two.sided") { pcc <- list(coefs = pcc, sig = t > qt(1 - (p/2), df = t.df), p.value = 2 * pmin(pt(t, t.df), 1-pt(t, t.df))) # two.sided } else if (alternative == "greater") { pcc <- list(coefs = pcc, sig = t > qt(1 - p, df = t.df), p.value = 1-pt(t, t.df)) # greater } else if (alternative == "less") { pcc <- list(coefs = pcc, sig = t > qt(1 - p, df = t.df), p.value = 2*(1-pt(t, t.df))) } } str <- sprintf("Partial correlation for:"); print(str, quote=FALSE); str <- sprintf("%s", colnames(x)); print(str, quote=FALSE); str <- sprintf("p: %.2f, alternative: %s", p, alternative); print(str, quote=FALSE); if (test) { str <- sprintf("df: %d", t.df); print(str, quote=FALSE); } return(pcc) } The function was adopted from the following email: http://tolstoy.newcastle.edu.au/R/help/00a/0518.html -- yianni __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] rewrite a data file use write.table(), count.fields() show different pattern, any suggestion appreciated.
If you write out unquoted fields, how do you know they do not contain tabs? The default is quote=TRUE for a good reason. On Tue, 22 May 2007, Yong Wang wrote: > Dear all: > > I read in a tab delimited dataset, and then write it out as another > file as following: I did this simply to make sure I understand the > behavior of this command. > > data<-read.table(file,header=F,sep="\t",fill=T,colClasses="character"); > write.table(data,file="newdata.txt",eol="\n",sep="\t",quote=F,row.names=F); > > > cf1 <- count.fields(newdata.txt, sep="\t") > table(cf1) > 13 17 23 > 10 126 5445 > > # is different to > > cf2 <- count.fields(file,sep="\t") > 13 17 2333 > 10 106 5433 32 > > the worst problem is the maximal value of cf1 (33) is larger than the > maximal value of cf2 (23) which is the right number of fields for most > rows in the original file. > > I need to use write.table for some important data manipulation work, > your suggestion is > highly appreciated. > > Best Regards > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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.
Re: [R] plot(......,new=T) vs. par(new=T)
On 2007-May-22 , at 13:51 , John Kane wrote: > ?par > There are several parameters can only be set by a call > to par(): "new" > > You just were lucky enough to find one. Yes sorry about that, I saw this afterwards. I read the help pages a while ago and it seems it's time to take a re-read tour. Thank you. JiHO --- http://jo.irisson.free.fr/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] rewrite a data file use write.table(), count.fields() show different pattern, any suggestion appreciated.
Dear all: I read in a tab delimited dataset, and then write it out as another file as following: I did this simply to make sure I understand the behavior of this command. data<-read.table(file,header=F,sep="\t",fill=T,colClasses="character"); write.table(data,file="newdata.txt",eol="\n",sep="\t",quote=F,row.names=F); cf1 <- count.fields(newdata.txt, sep="\t") table(cf1) 13 17 23 10 126 5445 # is different to cf2 <- count.fields(file,sep="\t") 13 17 2333 10 106 5433 32 the worst problem is the maximal value of cf1 (33) is larger than the maximal value of cf2 (23) which is the right number of fields for most rows in the original file. I need to use write.table for some important data manipulation work, your suggestion is highly appreciated. Best Regards __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot(......,new=T) vs. par(new=T)
?par There are several parameters can only be set by a call to par(): "new" You just were lucky enough to find one. --- jiho <[EMAIL PROTECTED]> wrote: > Hello everybody, > > This is probably a classic but I cannot find an > answer to this on the > mailing list (i.e. with a google search restricted > to the mailing > list archive). Setting: > par(new=T) > plot(x,y) > works but > plot(x,y,new=T) > doesn't while it is said in plot's help that ... > arguments are passed > to par. What am I missing? > > JiHO > --- > http://jo.irisson.free.fr/ > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] Legend outside plotting area
Judith, you might try split.screen() and related functions, see ?screen. Example: split.screen(c(1,2)) # 1 row, 2 columns split.screen(c(2,2), screen = 1) # split left column into 2x2 for(i in 3:6) { screen(i); plot(1:10) } screen(2) plot(1, type="n", axes=F, ann=F) # empty plot legend("center", pch=1, legend="Data") Regards, Carsten > Hi, > > I have been trying many of the suggested options > to place a legend outside plotting area, including > something like this: > > par(xpd=T, > oma=par()$oma+c(4.5,0,1.5,0),mar=par()$mar+c(1,0,1,0) > > > But the aspect of the four plots gets compromised > when I change the margin settings. I cannot use mtext > because I need to use colors for the text. I tried > layout, but wouldn't let me include the legend, only > plots. > >I would appreciate very much some more help. > > Regards, > > J __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Legend outside plotting area
RSiteSearch("legend outside plot") will bring you many links to the discussions of this question. layout perfectly allows everything. typical sequence looks like this This divides the device region by two parts one below another: layout(matrix(c(1,2),byrow=TRUE), heights=[blah-blah-blah], [some other arguments]) Then we plot on the first part: plot( ... ) lines ( ... ) points ( ... ) grid( ... ) [ whatever you want on the plotting area] Then we finish plotting on the first part of the layout matrix and come to the next, legend part. The only thing to do is placing the legend in the top left corner. plot.new(); plot.window(c(0,1), c(0,1)); legend(0,1, [ legend text ] ) Judith Flores wrote: > > Hi, > > I have been trying many of the suggested options > to place a legend outside plotting area, including > something like this: > > par(xpd=T, > oma=par()$oma+c(4.5,0,1.5,0),mar=par()$mar+c(1,0,1,0) > > But the aspect of the four plots gets compromised > when I change the margin settings. I cannot use mtext > because I need to use colors for the text. I tried > layout, but wouldn't let me include the legend, only > plots. > >I would appreciate very much some more help. > > Regards, > > J > -- View this message in context: http://www.nabble.com/Legend-outside-plotting-area-tf3794564.html#a10735956 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] my e-mail
here is my address [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] Segfault?
[EMAIL PROTECTED] wrote: > Hello everyone, > > I get (reproducible) segfaults when I try to update my packages, and > was wondering whether anyone knows why this might be happening. > > I am trying to update my packages: > 1. I start R via sudo in a terminal > 2. I type update.packages() - a Tcl/Tk list pops up, I select a mirror > 3. R segfaults. > > Maybe I need to update to a newer version of R or something? Yes. Uwe Ligges > Slightly OT, but does anyone know where coredumps end up on Mac OS X? > > Thanks. > > > > Some details are below. > output: > -8<--- > $ sudo R > > R : Copyright 2006, The R Foundation for Statistical Computing > Version 2.3.1 (2006-06-01) > ISBN 3-900051-07-0 > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type 'license()' or 'licence()' for distribution details. > > Natural language support but running in an English locale > > R is a collaborative project with many contributors. > Type 'contributors()' for more information and > 'citation()' on how to cite R or R packages in publications. > > Type 'demo()' for some demos, 'help()' for on-line help, or > 'help.start()' for an HTML browser interface to help. > Type 'q()' to quit R. > >> update.packages() > --- Please select a CRAN mirror for use in this session --- > Loading Tcl/Tk interface ... done > > *** caught segfault *** > address 0x5f4d4550, cause 'memory not mapped' > > Traceback: > 1: download.file(url = paste(repos, "PACKAGES.gz", sep = "/"), destfile = > tmpf, method = method, cacheOK = FALSE, quiet = TRUE, mode = "wb") > 2: try(download.file(url = paste(repos, "PACKAGES.gz", sep = "/"), > destfile = tmpf, method = method, cacheOK = FALSE, quiet = TRUE, mode = > "wb"), silent = TRUE) > 3: available.packages(contriburl = contriburl, method = method) > 4: update.packages() > > Possible actions: > 1: abort (with core dump) > 2: normal R exit > 3: exit R without saving workspace > 4: exit R saving workspace > Selection: 1 > aborting ... > Segmentation fault > -8<--- > > I am running Mac OS X 10.4.9 on Dual PowerPC G5, R 2.3.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. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Selecting complementary colours
Dear Chuck, This solution works reasonably well for me. Although it occasionally produces an error, I'm able to trap that. Thank you -- and to everyone else who responded. John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: Charles C. Berry [mailto:[EMAIL PROTECTED] > Sent: Monday, May 21, 2007 8:49 PM > To: John Fox > Cc: 'Deepayan Sarkar'; r-help@stat.math.ethz.ch > Subject: Re: [R] Selecting complementary colours > > On Mon, 21 May 2007, John Fox wrote: > > > Dear Deepayan, > > > > I actually thought of the equivalent of this approach, but > it doesn't > > do quite what I want. > > > > In retrospect, I didn't specify the problem clearly: What I > want to be > > able to do is to place text on a background of arbitrary (but known > > RGB) colour so that the text is legible. I guess that this > is better > > described as a "contrasting" than a "complementary" colour. > > John, > > There may be no unique solution. (For gray, for example.) > > I am not sure (in terms of color theory) that maximizing in > rgb space really is the right thing to do, but perhaps this > will help you: > > > cval <- function(x,y) -sum((x-y)^2) > > contrasting <- function(x) > > > optim(runif(3,0,255),cval,lower=0,upper=255,method="L-BFGS-B",y=x)$par > > do.call(rgb,as.list(contrasting(col2rgb("gray"))/255)) > [1] "#00" > > do.call(rgb,as.list(contrasting(col2rgb("gray"))/255)) > [1] "#FF" > > do.call(rgb,as.list(contrasting(col2rgb("pink"))/255)) > [1] "#00FF00" > > Regards, > > Chuck > > > > > > > > Your solution, for example breaks down for grays: > > > >> mycol <- "#88" > >> do.call(rgb, as.list(1 - col2rgb(mycol) / 255)) > > [1] "#77" > > > > Thank you for the suggestion. > > > > John > > > > > > John Fox, Professor > > Department of Sociology > > McMaster University > > Hamilton, Ontario > > Canada L8S 4M4 > > 905-525-9140x23604 > > http://socserv.mcmaster.ca/jfox > > > > > >> -Original Message- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] On Behalf Of Deepayan > >> Sarkar > >> Sent: Monday, May 21, 2007 6:45 PM > >> To: John Fox > >> Cc: r-help@stat.math.ethz.ch > >> Subject: Re: [R] Selecting complementary colours > >> > >> On 5/21/07, John Fox <[EMAIL PROTECTED]> wrote: > >>> Dear r-helpers, > >>> > >>> I wonder whether, given the "#rrggbb" representation of a colour, > >>> there is a simple way to select the complementary colour, > >> also expressed as a "#rrggbb" > >>> string. > >>> > >>> Any suggestions would be appreciated. > >> > >> You want rgb2col. The following should work for any standard color > >> specification: > >> > >>> mycol = "royalblue" > >>> do.call(rgb, as.list(1 - col2rgb(mycol) / 255)) > >> [1] "#BE961E" > >> > >> -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. > >> > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > Charles C. Berry(858) 534-2098 > Dept of > Family/Preventive Medicine > E mailto:[EMAIL PROTECTED] UC San Diego > http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego > 92093-0901 > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] "welcome" message upon loading data
Dear R-help, I'm building a package which will contain a data set. I was wondering if it's possible to make a message appear on the console whenever a user loads the data. So the console would look like >data(mydata) "Please do not use these data in any publication without permission of the authors" > Would this message be within the terms of GPL? Looking at the ?data page, it seems "packageIQR" might be the way forward, but I couldn't find any further information on this. Thanks Simon Bond. ___ [[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] R2 always increases as variables are added?
Hi,Oksanen, Thanks for your reply. I agree with you at the point that if we misjudge none-zero intercept to be zero, there will be loss still or even great loss as you and Venables emphasized in your practical research work. If there won't be any loss when we misjudge zero intercept to be none-zero, and we don't care the possible improvement on predictive ability, the strategy that always including intercept will be OK. Otherwise, even though the cases that true intercept is none-zero are very rare, I think in some special cases, my strategy is worthy to be concerned. In fact, to your example, my strategy gives correct result at a very high possibility, shown by the following code: > library(leaps) > n.sim=1000 > result=matrix(rep(NA,2*n.sim),ncol=2) > > for(i.sim in 1:n.sim){ + mass <- runif(100, 10, 500) # typical range for plant biomass/m^2 + spno <- rpois(100, 12) # Moderate number of species independent of mass + + var.selection=leaps(cbind(rep(1,length(mass)),mass),spno,int=F,method="adjr2") + temp=var.selection$which[var.selection$adjr2==max(var.selection$adjr2),] + names(temp)=c("intercept","mass") + result[i.sim,]=temp ## This is the result given by my strategy + } > > apply(result,2,sum)/n.sim ## This is the frequencies that intercept and mass are selected respectively [1] 1.000 0.314 2007/5/22, Jari Oksanen <[EMAIL PROTECTED]>: > > Àî¿¡½Ü gmail.com> writes: > > > > > Hi, Lynch, > > > > Thank you for attention first. > > > > I am also not a statistician and have just taken several statistics > classes. > > So it is natral for us to ask some question seeming naive to > statisticans. > > > > I am sorry that I cannot agree with your point that we must always > include > > intercept in our model. becaus if true intercept is zero, the strategy > of > > you or your textbook will be have 2 losses. First, there will be > > explaination problem. If true intercept is zero and your estimate of it > is > > not zero, the result of regression is misleading. However, it might be > not > > so serious as we judge those coefficients which are actually zeros to be > > none-zeros, but the misjudge here is still a loss in some > > extent. Secondly, if true intercept is zero, your strategy's predictive > > ability is often lower than other strategies which do not always include > > intercept. > > > I'm not a statistician, but I've seen much damage done with regression > forced > through zero in my field (ecology). This technique is tought in many > statistical > textbooks popular among ecologists. The key problem here is: how do you > *know* > that the intercept is zero? Even in logically compelling cases it is very > easy > to reach false certainty of zero intercept. A typical case in ecology is > where > people study the number of species against biomass, and argue that there > *must* > be zero species when biomass = 0 (if there is nothing, then there is > nothing). > The conclusion is that you must fit a model with no intercept. Let's see a > typical example (and I'm so confident that I won't put any random number > seed > for this): > > mass <- runif(100, 10, 500) # typical range for plant biomass/m^2 > spno <- rpois(100, 12) # Moderate number of species independent of mass > summary(lm(spno ~ mass - 1)) # WRONG! > summary(lm(spno ~ mass)) # More or less correct > > It is not sufficient to know that the value must be zero in a certain > point, you > also should know how that point is scaled: it may make sense to say that > spno = > 0 at log(mass) = -Inf, but then it does not make sense to force regression > through that point. In particular, when the zero-point is extrapolated > from the > data, it is dangerous to force regression through the origin. Further, if > your x > does not have a really natural scale, but you can replace x with x - > constant > (like x - mean(x)), then it hardly makes sense to play with zero > intercepts. > > There may be cases where forcing regression through zero makes sense, but > they > seem to be very rare. I've seen them very rarely. > > There is an exegetic text on the issue at > http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf which also touches this > issue > (page 3) and makes a nice reading anyhow. > > Cheers, Jari Oksanen > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Junjie Li, [EMAIL PROTECTED] Undergranduate in DEP of Tsinghua University, [[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] Segfault?
Hello everyone, I get (reproducible) segfaults when I try to update my packages, and was wondering whether anyone knows why this might be happening. I am trying to update my packages: 1. I start R via sudo in a terminal 2. I type update.packages() - a Tcl/Tk list pops up, I select a mirror 3. R segfaults. Maybe I need to update to a newer version of R or something? Slightly OT, but does anyone know where coredumps end up on Mac OS X? Thanks. Some details are below. output: -8<--- $ sudo R R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.1 (2006-06-01) ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > update.packages() --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done *** caught segfault *** address 0x5f4d4550, cause 'memory not mapped' Traceback: 1: download.file(url = paste(repos, "PACKAGES.gz", sep = "/"), destfile = tmpf, method = method, cacheOK = FALSE, quiet = TRUE, mode = "wb") 2: try(download.file(url = paste(repos, "PACKAGES.gz", sep = "/"), destfile = tmpf, method = method, cacheOK = FALSE, quiet = TRUE, mode = "wb"), silent = TRUE) 3: available.packages(contriburl = contriburl, method = method) 4: update.packages() Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: 1 aborting ... Segmentation fault -8<--- I am running Mac OS X 10.4.9 on Dual PowerPC G5, R 2.3.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] translate SAS code
I am not sure if R can read formulas and if it does, it probably as characters. I would suggest you Copy and Paste Special (as values) onto a new sheet and save it a tab delimited files. elyakhlifi mustapha wrote: > good morning, > I have some SAS code to translate in R code and when I export data from Excel > to R I have to read formula writed as follow > > C604=(C181/S181)*(100-C182)*(100/85) > > or > > if C325=. then C740=(C346/C103)*100| else C740=(C346/C325)*100 > > I find some difficulties to write a good program to read and calculate these > formulas > there are several kinds of formulas there are with conditional and without > conditional > can you help me please? > thanks. > > > > _ > > [[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] Installing packages from command line on Linux RHEL4
Assuming the R packages have been downloaded locally and end with tar.gz, then how about simply changing to where the files are located and typing the following command? ls *.tar.gz | while read x; do echo "R CMD INSTALL $x"; done | bash Alternatively, you can use the install.packages() function in R. Regards, Adai Kermit Short wrote: > Dirk- > Many thanks for your reply. As I mentioned, I know very little > about programming in 'R' and what I've got is a BASH script. If needs be, > I'll look up how to read in a text file through R and add that into your > script in lieu of the (argv) stuff, but you wouldn't happen to know how to > accomplish the same thing using the > > R CMD INSTALL > > Shell command? > > Thanks! > > -Kermit > > -Original Message- > From: Dirk Eddelbuettel [mailto:[EMAIL PROTECTED] > Sent: Monday, May 21, 2007 12:00 PM > To: [EMAIL PROTECTED] > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Installing packages from command line on Linux RHEL4 > > > Hi Kernit, > > On 21 May 2007 at 11:37, Kermit Short wrote: > | Greetings. > | > |I am a System Administrator, and thus have very little knowledge of R > | itself. I have been asked to install a list of some 200 packages (from > | CRAM) to R. Rather than installing each package manually, I was hoping I > | could script this. I've written a BASH script that hopefully will do > this, > | but I'm wondering about the Mirror Selection portion of the installation > | process. I've looked and can't find anywhere a parameter to supply that > | specifies a mirror to use so that I don't have to manually select it for > | each package I want to install. In this case, with nearly 200 packages to > | install, this could become quite tedious. Does anyone have any > | suggestions? > > The narrow answer is try adding > > repos="http://cran.us.r-project.org"; > > Also, and if I may, the littler front-end (essentially "#!" shebang support > for R) > helps there: > > basebud:~> cat bin/installPackages.r > #!/usr/bin/env r > # > # a simple example to install all the listed arguments as packages > > if (is.null(argv)) { > cat("Usage: installPackages.r pkg1 [pkg2 [pkg3 [...]]]\n") > q() > } > > for (pkg in argv) { > install.packages(pkg, lib="/usr/local/lib/R/site-library", depend=TRUE) > } > > You would still need to add repos="..." there. I tend to do that in my > ~/.Rprofile. > > Hth, Dirk > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Chosing a subset of a non-sorted vector
You want to select two subplots for each DL value. Try: df <- data.frame( DL=gl(3,4), subplot=rep(1:4,3) ) df$index <- 1:nrow(df) ind <- tapply( df$index, df$DL, function(x) sample(x,2) ) df[ unlist(ind), ] You could also have used rownames(df) instead of creating df$index. OR tmp <- lapply( split(df, df$DL), function(m) m[sample(1:nrow(m),2),] ) do.call("rbind", tmp) Regards, Adai Christoph Scherber wrote: > Dear all, > > I have a tricky problem here: > > I have a dataframe with biodiversity data in which suplots are a > repeated sequence from 1 to 4 (1234,1234,...) > > Now, I want to randomly pick two subplots each from each diversity level > (DL). > > The problem is that it works up to that point - but if I try to subset > the whole dataframe, I get stuck: > > DL=gl(3,4) > subplot=rep(1:4,3) > diversity.data=data.frame(DL,subplot) > > > subplot.sampled=NULL > for(i in 1:3) > subplot.sampled=c(subplot.sampled,sort(sample(4,2,replace=F))) > > subplot.sampled > [1] 3 4 1 3 1 3 > subplot[subplot.sampled] > [1] 3 4 1 3 1 3 > > ## here comes the tricky bit: > > diversity.data[subplot.sampled,] > DL subplot > 31 3 > 41 4 > 11 1 > 3.1 1 3 > 1.1 1 1 > 3.2 1 3 > > How can I select those rows of diversity.data that match the exact > subplots in "subplot.sampled"? > > > Thank you very much for your help! > > Best wishes, > Christoph > > (I am using R 2.4.1 on Windows XP) > > > ## > Christoph Scherber > DNPW, Agroecology > University of Goettingen > Waldweg 26 > D-37073 Goettingen > > +49-(0)551-39-8807 > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] translate SAS code
good morning, I have some SAS code to translate in R code and when I export data from Excel to R I have to read formula writed as follow C604=(C181/S181)*(100-C182)*(100/85) or if C325=. then C740=(C346/C103)*100| else C740=(C346/C325)*100 I find some difficulties to write a good program to read and calculate these formulas there are several kinds of formulas there are with conditional and without conditional can you help me please? thanks. _ [[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] kernel density
I'm in need of information with regard to Stochastic Kernel. I would like to know if I can use R to compute stochastic Kernels according to Quah methodology. Best wishes, Oriana - - [[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] Running an R script without running R
This gives you a GUI that runs R without you having to run it yourself on your machine: http://rss.acs.unt.edu/cgi-bin/R/Rprog You could upload your data to a webspace if you have one, and catch it from there in that service they provide. You could provide to whomever you like such a service yourself I guess. T Alberto Monteiro wrote: > Thomas Adams wrote: > >>Below I have two scripts: >> >>(1) cpc2fgroup >>(2) R.cpc.6_10day.outlook.batch >> >>Bash shell script (1) calls the R script (2). >> > > It works with R CMD BATH r-script > > I know how to do this (I do it inside make...) > > I guess I did not make myself clear. > > I want to write some GUI applications that will not be used by > me (think of the target user as people with the knowledge of > a 7-year-old kid). I want this application to have one icon in > the Desktop, and it will be launched just by clicking in the icon. > > In some other message, I read that Rscript might be what I need - but > I have to test it. > > Alberto Monteiro (who does not have any special affinity with > the letter "I", despite this message) > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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] Goodness of fit for hclust?
On Tue, 2007-05-22 at 00:35 +, [EMAIL PROTECTED] wrote: > I'd like to get a measure of goodness of fit for a heirarchical > clustering result from hclust. Something that would indicate the > extent to which the dendrogram accurately represents the original > dissimilarity matrix. Is there an easy way to do this? > > Or, does anyone have code for computing distances between nodes given > an hclust structure? So far, my searches have come up dry. > > -- David Hinds Try ?cophenetic which calculates the cophenetic distances of a hierarchical cluster analysis. The example on that help page shows how to use the function to get the correlation between the original distances and cophenetic distances. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/ WC1E 6BT [w] http://www.freshwaters.org.uk/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] R2 always increases as variables are added?
李俊杰 gmail.com> writes: > > Hi, Lynch, > > Thank you for attention first. > > I am also not a statistician and have just taken several statistics classes. > So it is natral for us to ask some question seeming naive to statisticans. > > I am sorry that I cannot agree with your point that we must always include > intercept in our model. becaus if true intercept is zero, the strategy of > you or your textbook will be have 2 losses. First, there will be > explaination problem. If true intercept is zero and your estimate of it is > not zero, the result of regression is misleading. However, it might be not > so serious as we judge those coefficients which are actually zeros to be > none-zeros, but the misjudge here is still a loss in some > extent. Secondly, if true intercept is zero, your strategy's predictive > ability is often lower than other strategies which do not always include > intercept. > I'm not a statistician, but I've seen much damage done with regression forced through zero in my field (ecology). This technique is tought in many statistical textbooks popular among ecologists. The key problem here is: how do you *know* that the intercept is zero? Even in logically compelling cases it is very easy to reach false certainty of zero intercept. A typical case in ecology is where people study the number of species against biomass, and argue that there *must* be zero species when biomass = 0 (if there is nothing, then there is nothing). The conclusion is that you must fit a model with no intercept. Let's see a typical example (and I'm so confident that I won't put any random number seed for this): mass <- runif(100, 10, 500) # typical range for plant biomass/m^2 spno <- rpois(100, 12) # Moderate number of species independent of mass summary(lm(spno ~ mass - 1)) # WRONG! summary(lm(spno ~ mass)) # More or less correct It is not sufficient to know that the value must be zero in a certain point, you also should know how that point is scaled: it may make sense to say that spno = 0 at log(mass) = -Inf, but then it does not make sense to force regression through that point. In particular, when the zero-point is extrapolated from the data, it is dangerous to force regression through the origin. Further, if your x does not have a really natural scale, but you can replace x with x - constant (like x - mean(x)), then it hardly makes sense to play with zero intercepts. There may be cases where forcing regression through zero makes sense, but they seem to be very rare. I've seen them very rarely. There is an exegetic text on the issue at http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf which also touches this issue (page 3) and makes a nice reading anyhow. Cheers, Jari Oksanen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.