Re: [R] How to create a directoy with R
?dir.create On Mon, 2006-03-27 at 13:07 +0200, pau carre wrote: Hello, I am trying to create directories with R. I would like R to create directories because it is platform independent. I tried using file() and searching in R Data Import/Export but I did not succeed. I think it must be some function since exists the unlink to remove directories (and files). Pau __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] [OT] colors in a LaTex doc
Hi Erin, On Fri, 2006-03-24 at 17:36 -0600, Erin Hodgess wrote: Dear R People: I know that this is COMPLETELY off topic. Does anyone know how to put colors into a LaTex document, please? This is LaTex via WinEdt. I can get colors via PcTex but not in WinEdt. I'm not a user of WinEdt but I guess it should be the same regardless of the editor you use. Just use the color package. \documentclass{article} \usepackage{color} \begin{document} Some colourful examples. \color{green} Now everything is green. \color{black} And now everything is black again. This is \textcolor{blue}{some blue text}. \end{document} Take a look at this page for an overview: http://tex.loria.fr/graph-pack/grf/grf.htm#Q1-1-21 Note that this uses named colours for dvi output. Many of these will not necessarily work if you want PDF output. I often define my own colours. Dave Thanks in advance! Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Newbie question about SQL and data sources
Hi Rex, Take a look at the Data Import/Export manual that ships with R to get a feel for some of your options. I use a variety of techniques depending on what I am doing. Quite often I use MySQL, accessing my tables via RODBC. Other times text files are most appropriate. Then on other occasions I am given datasets in DBF, stata, spss, or some other format and use the foreign package to import them. When I have tables of data that I know are not going to change I often save them as Rdata files, document them and make a simple package of them so that I can load them quickly and I have the information I need about the dataset and variables to hand (very useful months later when I've forgotten what half the variables represent). Dave On Fri, 2006-03-24 at 23:13 -0500, Rex Eastbourne wrote: Hi, I just downloaded R, and am wondering about data sources. Where do people typically get their data for analysis? It seems to me most people would have their data somehow automatically gathered and stored in an SQL database (e.g. MySQL), but this seems not to be the case. Does everyone just use the plain-text tab-separated values format? If so, how are these tables typically created in the first place? I store a lot of data automatically in MySQL databases--is there another good way of aggregating data for statistical analysis that I might be unaware of? Thank you, Rex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] appending objects to a file created by save()
On Fri, 2006-03-10 at 03:46 -0500, Rajarshi Guha wrote: Hi, I've been slowly transitioning to saving sets of objects for a project using save() rather than cluttering my workspace and then doing save.image() However, sometimes after I have done say: save(x,y,z, file='work.Rda') and I reload it a little later and I see that I also want to save object p. Currently I need to do: save(x,y,z,p, file='work.Rda') Is there any way to instruct save to append an object to a previously created binary data file? I use this approach. One potential problem with this approach is that if you have large saved objects you could get into problems because you need to load them before saving them. ## Function to append an object to an R data file. append.Rda - function(x, file) { old.objects - load(file, new.env()) save(list = c(old.objects, deparse(substitute(x))), file = file) } ## Example: x - 1:10 y - letters[1:10] save(list = c(x, y), file = temp.Rda) z - fred append.Rda(z, temp.Rda) Dave Thanks, --- Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- CChheecckk yyoouurr dduupplleexx sswwiittcchh.. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hmisc latex cell background color
Hi Dieter, The nearest I got to was to be able to colour row. Take a look at Table 10 here: http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf I used the latex package colotbl (see the definition of \shadeRow in section 1). I didn't play any further with this. It might be possible that colortbl has further commands ora mechanism for colouring individual cells. Dave Dieter Menne wrote: Dear latex/R-Sweavers, Using the codel below, I can color text in individual cells for latex output. Is there a similar way to get a background shading? My attempts failed because I did not get the closing brace at the right place with Hmisc/latex. library(Hmisc) x - as.data.frame(diag(rnorm(3),nrow=3)) cellTex - matrix(rep(, NROW(x) * NCOL(x)), nrow=NROW(x)) cellTex[2,2] - \color{red} ct - latex(x, cellTexCmds = cellTex,numeric.dollar=FALSE) ct$style - color dvi(ct) Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. In God we trust, all others must bring data W. Edwards Deming __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hmisc latex function
Charles Dupont wrote: [...] H, It works for me. Interesting. It almost looks like the temp dir is not being created, but thats not possible because R does that. It might be a Unicode issue with you system shell. Can you run this statement in R sys(paste('cd',dQuote(tempdir()),;, echo Hello BOB test.test, ;,cat test.test)) What version of Hmisc are you using? What local are you using? Charles I've had similar problems latex() which I tracked down to dQuote() that I think are related to unicode and locales on Ubuntu 5.04. I think the problem is with Ubuntu (because I get funny little boxes now and then with various applications), but have not managed to get my head around unicode sufficiently well to be able to write a sensible post about this or work out how to fix it. My current way of getting around this in R is to change the locale: Sys.getlocale() [1] LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C tempdir() [1] /tmp/RtmpWL64Z2 dQuote(tempdir()) [1] â/tmp/RtmpWL64Z2â [I get funny little boxes here] Sys.setlocale(LC_CTYPE, C) [1] C Sys.getlocale() [1] LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C dQuote(tempdir()) [1] \/tmp/RtmpWL64Z2\ [No funny boxes this time] version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major2 minor1.1 year 2005 month06 day 20 language R [Hmmm, I need to update my R installation] -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, 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
Re: [R] Convert ftable to latex?
)*27.6954 (-1;0.0396)*NA (NA;NA)\\ \hline \\ 7.5719 (1;0.4391)***9.7039 (1;-0.2938)***8.5525 (1;-0.4063)***\\ 8.3466 (1;-0.3122)***9.8524 (0;-0.887)***11.4154 (0;-1.2267)***\\ 9.4509 (1;-0.0795)***9.0177 (1;-0.2654)***9.441 (0;-0.7625)\\ 9.4921 (1;-0.1835)***10.107 (0;-0.72)**10.912 (0;-1.3619)\\ 7.8254 (1;1.016)**9.5687 (0;-0.9019)10.6842 (-1;0.0719)*\\ 7.7332 (1;1.2834)**9.4626 (1;0.3173)***10.0508 (0;-1.4876)\\ \hline \\ 16.7312 (0;-1.7286)21.4786 (2;2.4726)**41.6646 (1;-0.6796)***\\ 29.5637 (1;-0.0951)**37.4517 (1;0.1032)***38.2729 (1;-0.3249)***\\ 23.0214 (0;-1.3023)35.0403 (1;0.9176)***36.0989 (1;-0.2141)***\\ 10.579 (1;0.3292)31.4878 (0;-1.2475)38.0472 (1;-0.3049)**\\ 17.9077 (1;-1.2857)26.8651 (1;0.0221)***30.5705 (1;-0.5866)***\\ 18.832 (0;-2.)40.375 (1;-1.417)*26.2463 (1;0.4025)***\\ \hline \end{tabular} \end{center} \end{table} As you can see, I do not get any row names, and I want two layers of them (votcat and age in the formula). Column names work ok. Please, help me recreate the table above in latex form (if it is indeed possible). /Fredrik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. I love deadlines. I love the whooshing noise they make as they go by (Douglas Adams) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convert ftable to latex?
Hi again Fredrik, Here's a slightly better version (sex is no longer the first column, it is used by the rowname option in latex instead). library(Hmisc) x - ftable(Titanic, row.vars = 1:2) x Age Child Adult SurvivedNo YesNo Yes Class Sex 1st Male0 5 118 57 Female 0 1 4 140 2nd Male0 11 154 14 Female 0 1313 80 3rd Male 35 13 387 75 Female 17 1489 76 Crew Male0 0 670 192 Female 0 0 3 20 x.row.vars - attr(x, row.vars) col1 - x.row.vars[[1]] col2 - rep(x.row.vars[[2]], 4) x2 - data.frame(x[ ,]) colnames(x2) - c(No, Yes, No, Yes) x2 No Yes No Yes 1 0 5 118 57 2 0 1 4 140 3 0 11 154 14 4 0 13 13 80 5 35 13 387 75 6 17 14 89 76 7 0 0 670 192 8 0 0 3 20 latex(x2, + title=, + rowname=col2, + rgroup=col1, + cgroup=c(Child, Adult), + n.cgroup=c(2, 2), + n.rgroup=rep(2, 4) + ) Dave David Whiting wrote: Hi Fredrik, What you need to do is to massage your table a little to get it into the appropriate structure and then use the rgroup and n.rgroup options. Here's an example using the Titanic data that come with R. Note that this is not necessarily (or even remotely likely?) the best way to get your data into the shape required, but hopefully it shows you what, in general, you need to do. You might find that you don't need to use ftable at all, you might find other ways of creating the table you need. In the example below, note in particular what x and x2 look like. library(Hmisc) x - ftable(Titanic, row.vars = 1:2) x Age Child Adult SurvivedNo YesNo Yes Class Sex 1st Male0 5 118 57 Female 0 1 4 140 2nd Male0 11 154 14 Female 0 1313 80 3rd Male 35 13 387 75 Female 17 1489 76 Crew Male0 0 670 192 Female 0 0 3 20 x.row.vars - attr(x, row.vars) col1 - x.row.vars[[1]] col2 - rep(x.row.vars[[2]], 4) x2 - data.frame(sex=col2, x[ ,]) colnames(x2) - c(Sex, No, Yes, No, Yes) x2 Sex No Yes No Yes 1 Male 0 5 118 57 2 Female 0 1 4 140 3 Male 0 11 154 14 4 Female 0 13 13 80 5 Male 35 13 387 75 6 Female 17 14 89 76 7 Male 0 0 670 192 8 Female 0 0 3 20 latex(x2, + title=, + rowname=, + rgroup=col1, + cgroup=c(, Child, Adult), + n.cgroup=c(1, 2, 2), + n.rgroup=rep(2, 4) + ) HTH. Dave Fredrik Karlsson wrote: Dear list, I cannot make the latex command to output a ftable objet the way I want it. Is it posible? I found a post in the archives saying that one should use the rgroup and n.rgroup arguments to supply the row names, but so far I have been unsuccessful. This is what I have: (ftable(tapply(worksub$vot,list(votcat=worksub$votcat,age=worksub$agemF,voicetype=worksub$Type),FUN=distribution.table.fun,digits=4)) - ftab) voicetype Voiced Voiceless unaspirated Voiceless aspirated votcatage Prevoiced 18 - 24 46.6158 (0;-1.6652) 40.7417 (0;-0.6489) 48.4164 (0;-1.0483) 24 - 30 50.5716 (0;-1.4244)** 43.4056 (-1;-0.4537)*** 24.204 (0;-2.1416) 30 - 36 44.4439 (0;-1.182)* 51.0996 (0;-1.5241)*** 32.1219 (0;-1.5007) 36 - 42 40.8604 (-1;-0.3423)40.6045 (-1;-0.408)** 32.7949 (0;-2.75) 42 - 48 46.301 (0;-1.1878) 21.6894 (0;-1.7041) NA (NA;NA) 48 - 54 38.0151 (-1;-0.7878)* 27.6954 (-1;0.0396)*NA (NA;NA) Short lag 18 - 24 7.5719 (1;0.4391)***9.7039 (1;-0.2938)*** 8.5525 (1;-0.4063)*** 24 - 30 8.3466 (1;-0.3122)*** 9.8524 (0;-0.887)***11.4154 (0;-1.2267)*** 30 - 36 9.4509 (1;-0.0795)*** 9.0177 (1;-0.2654)*** 9.441 (0;-0.7625) 36 - 42 9.4921 (1;-0.1835)*** 10.107 (0;-0.72)** 10.912 (0;-1.3619) 42 - 48 7.8254 (1;1.016)** 9.5687 (0;-0.9019) 10.6842 (-1;0.0719)* 48 - 54 7.7332 (1;1.2834)** 9.4626 (1;0.3173)***10.0508 (0;-1.4876) Long lag 18 - 24 16.7312 (0;-1.7286) 21.4786 (2;2.4726)**41.6646 (1;-0.6796)*** 24 - 30 29.5637 (1;-0.0951)** 37.4517 (1;0.1032)*** 38.2729 (1;-0.3249)*** 30 - 36 23.0214 (0;-1.3023) 35.0403 (1;0.9176)*** 36.0989 (1;-0.2141)*** 36 - 42 10.579 (1;0.3292) 31.4878 (0;-1.2475) 38.0472 (1;-0.3049)** 42 - 48 17.9077 (1;-1.2857) 26.8651 (1;0.0221)*** 30.5705 (1;-0.5866
[R] 'splice' two data frames
Hi, I often need to take columns from two data.frames and 'splice' them together (alternately taking a column from the first data frame, then from the second). For example: x - table(sample(letters[1:9], 100, replace=TRUE), sample(letters[1:4], 100, replace=TRUE)) y - prop.table(x) splice - function (x, y) { z - matrix(rep(NA, (ncol(x) * 2) * nrow(x)), nrow = nrow(x)) j - 1 for (i in seq(1, ncol(z), by = 2)) { z[, i] - x[, j] z[, (i + 1)] - y[, j] j - j + 1 } z - data.frame(z) rownames(z) - rownames(x) z } splice(x, y) Manually using indexing I can do this: zz - data.frame(x[, 1], y[, 1], x[, 2], y[, 2], x[, 3], y[, 3], x[, 4], y[, 4]) I *feel* that it should be possible in R to generate the sequence of column indexes automatically. I can get close with this: i - paste(x[,, 1:ncol(x), ], , y[,, 1:ncol(y), ], collapse=, ) which creates a string version of what I want, but I am not sure how to use that with data.frame. FAQ 7.21 (How can I turn a string into a variable?) looked promising but I have not been able to apply any of the suggestions to this problem. I also tried using do.call: i - paste(x[,, 1:4, ],, y[,, 1:4, ], collapse=,) i - gsub(],, ]@, i) # Create a marker for i - strsplit(i, @) # strsplit to create a list do.call(data.frame, i) and with lapply: lappy(i, data.frame) These did not work (i.e. they worked as they were designed to and did not give me the results I am after). I think I need a nudge or two in the right direction. Thanks. Dave -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, 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
Re: [R] 'splice' two data frames
Thank you! I think I can simplify the first line further to: z-data.frame(matrix(rbind(x,y),nrow(x))) i.e. remove 2 * ncol(x) Thanks. Dave Peter Wolf wrote: what about: @ *= z-data.frame(matrix(rbind(x,y),nrow(x),2*ncol(x))) rownames(z)-rownames(x) z @ output-start Thu Aug 25 11:24:29 2005 X1 X2 X3 X4 X5 X6 X7 X8 a 2 0.02 1 0.01 2 0.02 2 0.02 b 3 0.03 0 0.00 4 0.04 3 0.03 c 3 0.03 2 0.02 1 0.01 6 0.06 d 3 0.03 4 0.04 2 0.02 3 0.03 e 4 0.04 1 0.01 4 0.04 2 0.02 f 2 0.02 5 0.05 2 0.02 2 0.02 g 4 0.04 5 0.05 3 0.03 3 0.03 h 3 0.03 3 0.03 5 0.05 4 0.04 i 1 0.01 0 0.00 3 0.03 3 0.03 output-end Peter Wolf [...] -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, 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
Re: [R] How do I make a Sweave + latex table out of this ?
Hi Fredrik, You can do this nicely with latex() if you massage this a little so that you end up with a data frame that includes a column for agemF (to indicate which agemF each row belongs to) and then use the rgroup and n.rgroup options of latex(). Dave Fredrik Karlsson wrote: Dear list, I have a table that I would like to convert to latex for inclusion into a Sweave file. round(ftable(prop.table(xtabs(~agemF + votcat + Type , data=work),margin=2))*100,1) Type Voiced Voiceless unaspirated Voiceless aspirated agemF votcat 18 - 24 Prevoiced 2.6 8.7 2.3 Short lag 5.8 6.7 5.1 Long lag 1.0 1.9 2.9 24 - 30 Prevoiced15.1 10.5 1.7 Short lag 9.2 15.3 5.8 Long lag 3.5 8.115.8 30 - 36 Prevoiced12.8 14.0 2.6 Short lag10.2 14.2 3.0 Long lag 2.3 5.522.2 36 - 42 Prevoiced 4.4 6.4 0.6 Short lag 4.0 5.9 1.5 Long lag 1.3 2.9 9.4 42 - 48 Prevoiced 6.4 2.3 0.3 Short lag 3.0 2.8 1.4 Long lag 0.6 7.7 8.8 48 - 54 Prevoiced 4.9 4.1 0.3 Short lag 2.0 2.7 1.3 Long lag 0.3 0.9 4.7 However, I have not been able to use this as a table. The Hmisc latex command only accepts the input if I first convert it to a data.frame format, and that makes the output much more difficult to read as it duplicates the category levels of agemF. Is there a way to do this? /Fredrik Karlsson __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. I love deadlines. I love the whooshing noise they make as they go by (Douglas Adams) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Digest reading is tedious
Hi Adrian, Here's what I used to use for a list I used to subscribe to (it is the first example in the man page for formail, it worked for me and I never went further playing with formail): :0: * ! * [EMAIL PROTECTED] | formail +1 -ds new/expert Here is a rough summary of what it does: :0:(is something to do with file locking (I think)) * !(I can't remember what this does) * [EMAIL PROTECTED] ^TO_ means the email address is in the To: *or* the CC: header. Note that you have to escape the dot in the .com bit. | formail +1 -ds new/expert This pipes the digest to formail, splits the messages and puts them all into a mailbox called new/expert (in this case). For you, the recipe might be something like: :0: * ! * [EMAIL PROTECTED] | formail +1 -ds R-undigested HTH, Dave Adrian Dusa wrote: On Tuesday 09 August 2005 23:47, Martin Maechler wrote: Trevor == Trevor Hastie [EMAIL PROTECTED] on Tue, 9 Aug 2005 10:27:32 -0700 writes: Trevor [...snip...] But that has been an option in mailman, the software behind our mailing lists --- for ages --- [...snip...] I hope this helps, Martin I use MIME for digest reading, with KMail under SuSE 9.2. The way I get the digest is a list of encapsulated messages. There is, however, a tedious things: the encapsulated messages are not numbered... (so I still have to scroll down to find a particular message, guessing the right place where it might be; odd enough, there is no Find text inside a message in KMail). If there's any option in KMail to split the digest into threaded messages, I couldn't find it. I tried to figure out how to use procmail and formail but is too complex for a regular user. Is it possible to get numbered encapsulated messages? TIA, Adrian -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. I love deadlines. I love the whooshing noise they make as they go by (Douglas Adams) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Dating Objects
Hi Jason, Perhaps you get do what you want to do using attributes? Does this get close to what you need? ## Create some objects xx - adsfasdf zz - 3027 yy - abdsf ## Assign a time attribute to them. attr(zz, time) - Sys.time() attr(yy, time) - Sys.time() ## To see the time attribute of, for example, zz: attributes(zz)$time [1] 2005-08-12 16:46:47 BST ## A crude function to show the time attributes ## of objects: time.attr - function (x) { + x.attr - attributes(get(x)) + attr.names - names(attributes(get(x))) + if (!is.null(attr.names) attr.names %in% time) { + x.time - x.attr$time + names(x.time) - x + x.time + } + } ## Apply the time.attr function to all objects listed by ls(): lapply(ls(), time.attr) [[1]] NULL [[2]] NULL [[3]] yy 2005-08-12 16:46:47 BST [[4]] zz 2005-08-12 16:46:47 BST Dave Jason Skelton wrote: Hi I know this subject has been mentioned before but from the mail archives I'm under the impression that this is not possible ? I'm trying to carryout the equivalent of ls -l in R to give some date/time label to each of my objects If the case is that there is no equivalent, is it possible to list all objects in an environment that share a common component ? So that the common component is also displayed ? I'm attempting to do the following object$time - Sys.time() for every object i've created which although tedious appears to work However I've no idea how if it is possible to list all the objects by $time or extract the object name $ time from all objects simultaneously so I can compare them. Or am I just wasting my time ? Apologies but my knowledge of R is limited at best ;-( Any help would be fantastic and greatfully received Cheers Jason -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. I love deadlines. I love the whooshing noise they make as they go by (Douglas Adams) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Digest reading is tedious
A.J. Rossini wrote: Trevor - There's a wonderful feature in gnus (the emacs information (including mail) reader), that bursts digests into subparts for reading (and hence, easy access). I think there are other similar tools as well for other mail readers. If you are using linux you can use procmail with formail. I used to do this a long time ago. See, for example: http://polydistortion.net/doc/procmail-monash.html#digests It's been a while since I used it so I'm not sure how much tweaking you would need to do to get the recipe right for you. But once you have it done you can then use any email client. -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, UK. I love deadlines. I love the whooshing noise they make as they go by (Douglas Adams) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] chocolate [was Re: calling R from C or C++]
Dirk Eddelbuettel wrote: On 23 July 2005 at 20:18, Bahoo wrote: [...] Dirk, who still wants chocolate to grow on trees, preferably in his backyard Well, it does, sort of. To have it in your backyard you are going to have to move nearer the equator though :) You can get the source, Theobroma Cacao, but you would have to compile it yourself to make it edible. Check the Chocolate Ingestion and Administration Manual. You will need a number of tools before you can do so. Under debian this is easy with: apt-get install chocolate-factory Windows users seem to have more trouble getting the tools together and some seem to believe that a clearer explanation of how to create packaged chocolate in windows is required. I think I should stop now and take my medication. David -- David Whiting School of Clinical Medical Sciences, The Medical School University of Newcastle upon Tyne, NE2 4HH, 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
Re: [R] more and tab functionalities in R under linux
Here's a very simple function that more literally emulates 'more'. It would probably become irritating on dataframes with many columns or rows. (Note that this is quick code thrown together and could probably be simplified and/or improved.) more - function(x, num.rows=20) { ## Purpose:display a dataframe in a 'more'-like manner ## --- ## Arguments: ## x: a data frame ## num.rows: number of rows to show at a time. ## --- show.more - TRUE start.row - 1 while (show.more) { print(x[start.row:(start.row + num.rows), ]) pc.shown - round(((start.row + num.rows) / nrow(x)) * 100, 1) ans - readline(paste(--More--(, pc.shown, %)\n, sep=)) if (ans == q) { show.more - FALSE } else { start.row - start.row + num.rows + 1 } } } David Gabor Grothendieck wrote: Here are some possibilities: - head(iris) will show the first few rows of the data frame - edit(iris) will put up a spreadsheet with the data frame in it that you can scroll - In JGR (a GUI front end for R) you can use the object browser (ctrl-B) - If the object is a file rather than a data frame use file.show On 7/8/05, Weiwei Shi [EMAIL PROTECTED] wrote: Hi, forgive me if it is due to my laziness :) I am wondering if there are functionalities in R, which can do like more and tab in linux: more(one.data.frame) so I can browse through it. Sometimes I can use one.data.frame[1:100,], but still not as good as more in linux. tab: can I use tab to auto complete an defined object name in R so I don't have to type the full name? I knew ESS can do it but it is a little bit funny when I use ESS and it can delete something that you cannot delete from R, like pressing del key all the time and you see what i mean. thanks, weiwei -- Weiwei Shi, Ph.D Did you always know? No, I did not. But I believed... ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] write.dta limits
Thomas Lumley [EMAIL PROTECTED] writes: On Mon, 6 Jun 2005, Jean Eid wrote: Hope everyone id doing great .. Just need some clarification over the limit of write.dta. I have some coauthors that use stata and I need to send them my data in .dta format. the data.frame is 41706x229 and I get the following Error in write.dta(Panel, file = STATADATA/Panel.dta, version = 7) : a binary write error occured Once I subset the data everything works out fine. my question is what are the limits of write.dta. I tried to find out but no luck.. There aren't supposed to be any built-in limits. The error message that you report means that the low-level operating system calls to write data gave an error, so if a limit was hit it was in the operating system (?disk full) -thomas When I have encountered this error message in the past seems to have resulted from a blank/empty level in a factor or an empty character. For example: library(foreign) x - data.frame(x=c(A, B, C), y=c(1,2,3)) write.dta(x, file=temp.dta) levels(x$x)[2] [1] B levels(x$x)[2] - write.dta(x, file=temp.dta) Error in write.dta(x, file = temp.dta) : a binary write error occurred My work-around at the time was to go through the data replacing with something else that I could then deal with later. -- David Whiting University of Newcastle upon Tyne, 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
Re: [R] how to modify and compile R sourse codes
Zhongming Yang [EMAIL PROTECTED] writes: You can get the source code from the source package and modify it. You'll have to read the relevant documentation about the tools you need to compile it---see the archives, there was a discussion recently about this, and see the documenation that comes with R. I don't use Windows so I can't give any more advice. Depending on what you need to do you might find that what you need is already in the CVS version of Hmisc. The code was added recently and is mentioned here: http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport A PDF with a few simple examples (created while developing and testing the code) are shown here: http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf The new options allow you to use any latex command (declaration) to format row and column names, row and column group labels, and each cell of a table individually. Defining new commands in the preamble of your LaTeX document you can great all sorts of splendid (and awful!) combinations of formats. The current version (3.0-5) has options to format the row and column group labels (note that in the CVS version the option name for the column group labels has changed). In case you are not aware of it I should mention that the Sweave function in the tools package is wonderful for creating automated reports. HTH David Dear All: I am working on writing some R functions to make statistical reports automatically. Dr. Harrell's Hmisc has all the wonderful stuff. But sometimes I need change some formats, so I want to read through it and make some modifications to fit my project. Ideally, I want proceed as following: 1. change some source of Hmisc 2. compile and install the modified Hmisc 3. debug my modified functions. And I am working on windows 2000. Could anyone give some suggestions on the tools and the best way to do this? 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 -- David Whiting University of Newcastle upon Tyne, 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
Re: [R] Supressing empty sections with Sweave
Mikkel Grum [EMAIL PROTECTED] writes: Hi Mikkel, One way would be to use cat(\\section{, diseaseName, }\n) with if (sum(matrixz) 0) within a for loop (or perhaps using one of the apply family of functions (probably lapply?)). To some extent this by-passes the separation of code and documentation that literal programming is about but I couldn't think of a better way to solve the problem just now. Sorry this is not a full worked example, but I'm off to the pub now for a few pints to welcome 2005. Dave Dear useRs, I'm writing regular survey reports using Sweave. Each report has several sections along the lines of: \section*{Disease X} MapX,fig=TRUE,echo=FALSE= image(vectorx,vectory,matrixz) @ Notes with or without Sexpr{a}. \vfill \pagebreak \section*{Disease Y} MapY,fig=TRUE,echo=FALSE= ...etc. Often one or more of the diseases is not observed (all values in matrixz are 0), in which case I would prefer not to display the section at all. Does any one no whether it is possible automate this with Sweave? Mikkel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David Whiting University of Newcastle upon Tyne, 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
Re: [R] numeric(0)
(Ted Harding) [EMAIL PROTECTED] writes: [...] What's the best place to look for the details on operator precedence and the like in R? ?Syntax ?Arithmetic -- David Whiting University of Newcastle upon Tyne, 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
Re: [R] Sweave and LaTeX beamer class
Hi Bernd, I think it is because you are trying to place a chunk of R code within a LaTeX command. I'm not sure that Sweave will be able to handle that. In situations analogous to this I process the R chunk earlier in my document and create an object that I then access in the LaTeX chunk using \Sexpr{}. Re-working your example might be something like this (untested): # \documentclass{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{ngerman} \begin{document} = x - 1+1 @ \frame{ \frametitle{test} test \Sexpr{x}} \end{document} # Dave Bernd Weiss [EMAIL PROTECTED] writes: Hi, has anyonne experienced problems between the LaTeX beamer class and Sweave? The following code does not work properly: # \documentclass{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{ngerman} \begin{document} \frame{ \frametitle{test} test = 1+1 @ } \end{document} # Below is the error code: # loading : Context Support Macros / PDF (2004.10.26) ) (d:\programme\texmf\tex\latex\hyperref\nameref.sty) (testset.out) (testset.out) (testset.nav) (d:\programme\texmf\tex\latex\ae\t1aett.fd) Runaway argument? 1 + 1 \end {Sinput} \begin {Soutput} [1] 2 \end {Soutput} \end {Sch\ETC. ! Paragraph ended before [EMAIL PROTECTED] was complete. to be read again \par l.26 } ? x No pages of output. Transcript written on testset.log. # Thanks in advance, Bernd __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to get how many lines there are in a file.
Thomas Lumley [EMAIL PROTECTED] writes: [...] If the file is large enough that you don't want to read the whole thing at once you can read it in chunks using readLines(). If all the lines are the same length you can find the size of the file and divide by the length of a line. Also, you don't say what OS you are on. If it isn't Windows the easiest thing would be to use wc. Part of the reason I got into Linux was because I needed to do (little?) things that I found tricky to do in Windows and bit-by-bit I accumulated various *nix tools that had been ported to DOS/Windows, such as these found here: http://unxutils.sourceforge.net/ So if your OS is Windows you could stick with it and still use wc (assuming that it works in the same way as under Linux---I haven't tested the version at this location). Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] A somewhat off the line question to a log normal distrib
Robin Hankin [EMAIL PROTECTED] writes: [stuff about the CLT deleted] So you can use R usefully to eveluate general statisical issues of this kind! absolutely! R is excellent for this sort of thing. I use it for teaching stats all the time. I'd say that without a tool like R you cannot learn statistics. I believe Fisher and a few others managed to get by without it. -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: Informix database
Yasser El-Zein [EMAIL PROTECTED] writes: There is no DBI implementation for Informix. I would appreciate some pointers to R's Java extension, if exists. I already have a solution for S-PLUS. I am interested in finding one for R to compare the two, otherwise my company will go with S-PLUS. unixODBC works fine for me using MySQL with R and there appears to be an Informix driver that works: The driver from informix works fine, but you need to have a look at the doc in the manuals section of the this site http://www.unixodbc.org/drivers.html I haven't tried it, but it looks in principle like you should be able to access the Informix database from R via unixODBC. Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] CDs for R?
(Ted Harding) [EMAIL PROTECTED] writes: [...] There's something of a hidden assumption that R users can readily download whatever they need from CRAN. [...] What I'd like to suggest, for consideration, is that along with the stirling work done at many centres to set up and maintain mirrors of CRAN, some might consider offering also the service of burning CDs on request, for a reasonable charge. The difficulty, of course, is that it's going to take someone's time om something which may well not be their proper business. I have been in a similar situation a fair bit in the past and understand your position. Now I'm back in the UK and have a reasonably fast broadband connection at home I'd be willing to help out now and then. I guess that to make this work more generally we would need to work out how to make sure that only the CDs get burned and not the prospective customer or supplier. As for charges, I think I'd only be interested in covering costs of the CDs and postage. I don't have industrial strength hardware so I could not get into mass production. Perhaps we could establish informal groups of R buddies where, for example, I help you and a small number of other people out each time there is an update and we establish some kind of trust between ourselves, rather than new people coming to me each time. People could sign up to be suppliers and be allocated or choose a group of people they provide the service to. I would feel comfortable with something like this working for people who have been on the R-help list for a while and have some recgonised identity, and something to lose in terms of reputation if they take advantage. But, it is possible that new users might need it the most and, by definition, we might not feel comfortable dealing with new people. Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R and fluxbox: 100% CPU usage
Hi, In July I reported a problem I was having with R and the fluxbox windows manager (with Linux). The interaction of R and fluxbox causes CPU to go to 100% when trying to create even a simple plot. It is the R process that is at 100%. R with any other window manager was fine, and all other applications (that I use) seem to run okay in fluxbox. I have updated both R (2.0.0) and fluxbox (0.9.10) and still have the same problem. I am not very familiar with gdb but gave it a go. I ran R and created a plot so that the R process was at 100% CPU usage. I then started gdb and attached the R process and CPU usage returned to normal (but I didn't get my plot). I detached the process and CPU usage went back up to 100%, attached it again and it went back to normal . . .. I would love to get this sorted out because I would like to use fluxbox, but can't because I am so dependent on R. Any ideas how I should proceed (incl. possibly spending more time reading the gdb man page). Thanks. Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R under Pocket PC
Peter Dalgaard [EMAIL PROTECTED] writes: Prof Brian Ripley [EMAIL PROTECTED] writes: On Tue, 9 Nov 2004, Lars Strand wrote: Will R run under Windows Pocket PC? We don't know! There are no binary versions of R for that platform, but perhaps you could find a suitable compiler and manage to build the sources. The PDA idea is quite interesting on all sorts of hardware. Unfortunately, the tools for (cross-)building software tend to be rather hackish and poorly documented. I believe people have had some success with the Sharp Zaurus, but that of course runs a Linux variant. [...] If the OP has a Compaq Ipaq and does not mind using Linux it seems to be possible to runs linux on the Ipaq and therefore it might conceivably be able to run R. http://www.ipaqlinux.com/ It is interesting this has come up at this time. Two days ago I installed Linux on a Psion 5MX (16Mb RAM) and am tickled pink by it. Installation is easy. At the moment I only have a small compactflash disk so I have not been able to install X windows or R yet. It runs debian woody. Linux is installed on the CF so it is actually a dual-boot machine---I have both the wonderful Psion software [why did they stop making them?] and can boot into Linux when I need it. When in Linux switching it on and off is instantaneous, just like any ordinary PDA. My ultimate aim is to have R, emacs, ESS and latex on it. Today I ordered a 1Gb CF disk and expect to get it in a week or two and I will let you know how I get on. Here's the howto: http://linux-7110.sourceforge.net/howtos/series5mx/5MXHOWTO.htm Some screenshots: (there's one with emacs about half way down the page and octave and gnuplot at the bottom). http://www.openpsion.org/howtos/series5mx/5MXHOWTO/5MX_howto_11.htm -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R under Pocket PC
Gabor Grothendieck [EMAIL PROTECTED] writes: David Whiting david.whiting at ncl.ac.uk writes: : It is interesting this has come up at this time. Two days ago I : installed Linux on a Psion 5MX (16Mb RAM) and am tickled pink by : it. Installation is easy. At the moment I only have a small : compactflash disk so I have not been able to install X windows or R : yet. You could see if MacAnova will install -- its an R/S-like package. Its pretty small (even runs on 640K DOS) and is quite portable. Its not as powerful as R but its still amazingly powerful and you might be able to fit it on. Thanks. I took a quick look and I think I would have to cross-compile it (I didn't find an ARM binary). When I get my larger compactflash card I am hoping that I will be able to just get the ARM debian package (and all the assorted dependencies) without having to setup a cross-compiling tool chain---I will have to take a look and see what is involved in doing this. I don't have a compiler installed on the Psion and probably would not have enough room for all the libraries (just guessing here). Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] A little more on R, mdbtools and Access databases
Anne York [EMAIL PROTECTED] writes: Wow, thanks for all the good information and ideas on this topic. Have you used mdbtools to convert a data base to something like MySQL or other open source data base? Yes, that's mostly how I have used mdbtools so far. I modified mdb-export and created a script to use my modified mdb-export and mdb-schema to act like MySQL's mysqldump, i.e. to produce CREATE TABLE and INSERT statements. That way I was able to get tables straight from an Access database into MySQL. Here's a link to what I did: http://sourceforge.net/tracker/?group_id=2294atid=302294func=detailaid=857342 With those changes and the mdbdump script I am able to do the following to get a table into MySQL: mdbdump accessDB accessTable | mysql mysqlDB As it is now mdb-export produces output in delimited format so you could use mdb-schema to create the table, export the data using mdb-export and then load it into mysql (or whatever). [it looks like the INSERT statements option has been added to mdb-export, but I am not sure about the MySQL backend] It seems that if I needed to do unions or intersections, I would have to do the conversion and use the other database from R since I'd rather work on my Linux machine. Another alternative would be to use mdbtools with the R functions I posted earlier to read the tables into R and then use RODBC to save (sqlSave) them into another database. This would probably be the easiest because all you need to do is get the current mdb-tools as it is now (my changes were made to an old version). This is now the my preferred route. BTW, I have now tidied the functions up a little so they don't create temporary files anymore. On the negative side, Brian Ripley reported problems compiling mdbtools, and on the Debian website, there were some security alerts (overflow problems) about mdbtools. Clearly, you were able to compile mdbtools. I had to make some symlinks to get it all to play properly (it seemed to expect libraries in /usr/lib when they were in /usr/local/lib), but it seemed to compile okay. The lib problem might have been a problem on my side though. Do you know anything about the security risks? Not a sausage. I use on my local machine so I don't think that they apply to my situation. I could easily be wrong though... Dave -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] A little more on R, mdbtools and Access databases
Hi again, I have played a little more with mdbtools and R. I downloaded the latest version of mdbtools from sourceforge (version 0.6pre1). Quickly scanning the mailing list suggests that ODBC seems to work with PHP but I have not been able to get it to work with R. I can make a connection to the database and when I do a query I get back the names of the rows but not the data. I must admit I have not spent long trying to figure it out. For my own use I am able to work directly with a database file on my local machine, and to make things easier for myself I have concentrated on making some simple functions (based on those I posted yesterday) that use mdbtools to: i) get table names, ii) describe tables, iii) read tables into R, and iv) use the (basic) SQL functionality of mdbtools to perform simple queries (really only able to select subsets of columns and rows) Here is an example session using a database I found on the web at http://www.microsoft-accesssolutions.co.uk/downloads/login.zip db - /home/dave/tmp/login.mdb mdbTables(db) [1] MSysObjects MSysACEs MSysQueries [4] MSysRelationships MSysAccessObjects tblEmployees mytab - mdbTables(db)[6] mytab [1] tblEmployees x - mdbReadTable(db, mytab) str(x) `data.frame': 4 obs. of 4 variables: $ lngEmpID : int 1 2 3 4 $ strEmpName: Factor w/ 4 levels David,Gavin,..: 3 2 4 1 $ strEmpPassword: Factor w/ 4 levels david,gavin,..: 3 2 4 1 $ strAccess : Factor w/ 2 levels Admin,User: 1 2 2 2 head(x) lngEmpID strEmpName strEmpPassword strAccess 11 Graham graham Admin 22 Gavin gavin User 33 Lynne lynne User 44 David david User mdbDescribe(db, mytab) ColumnName Type Size 1 lngEmpID Long Integer4 2 strEmpName Text 20 3 strEmpPassword Text 20 4 strAccess Text 40 mdbQuery(db, select lngEmpID, strAccess FROM tblEmployees where lngEmpID 3) lngEmpID strAccess 11 Admin 22 User Here are the functions: ### Some quick code to make use of mdb-tools to use MS Access tables in R. ### 2004-11-02 ### David Whiting require(gdata) # for the trim function. mdbTables - function(dbname) { system(paste(mdb-tables -d '\t' -S, dbname), intern=TRUE) } mdbReadTable - function(dbname,tableName) { tableName - dQuote(tableName) read.table(pipe(paste(mdb-export -d '\t' , dbname, tableName)), sep=\t, header=TRUE) } mdbDescribe - function(dbname,tableName) { tableName - dQuote(tableName) cat(describe table , tableName, \ngo, file = tempR.sql) mdesc - system(paste(mdb-sql -i tempR.sql , dbname), intern=TRUE) mdesc - strsplit(substring(mdesc[-c(1:3,5, length(mdesc), length(mdesc)-1)], 2), \\|) tabDesc - rbind(mdesc[[2]]) for (i in 3:length(mdesc)) { tabDesc - rbind(tabDesc, mdesc[[i]]) } tabDesc - matrix(trim(tabDesc), ncol=3) tabDesc - data.frame(tabDesc) names(tabDesc) - c(ColumnName, Type, Size) tabDesc$Size - as.numeric(levels(tabDesc$Size)[tabDesc$Size]) system(rm -f tempR.sql) tabDesc } mdbQuery - function(dbname, mstatement, header=FALSE, footer=FALSE) { cat(mstatement, \ngo, file = tempR.sql) sqlOptions - -p if (!header) sqlOptions - paste(sqlOptions, H, sep=) if (!footer) sqlOptions - paste(sqlOptions, F, sep=) sqlStatement - paste(mdb-sql, sqlOptions) tmp - read.table(pipe(paste(sqlStatement, -i tempR.sql, dbname)), sep=\t) names(tmp) - trim(unlist(strsplit(substr(mstatement, 7, regexpr( [Ff][Rr][Oo][Mm], mstatement)[1]), ,))) system(rm -f tempR.sql) tmp } -- David Whiting University of Newcastle upon Tyne, UK __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ms access -- mysql -- R in Linux
Anne York [EMAIL PROTECTED] writes: I am trying to use some ms access databases in R (version 1.9.1 or 2.0 on a Debian system). In searching the net for promising software to do this, I found mdbtools. Mdbtools claims the ability to convert schemas and tables in MS Access to MySQL and other databases. http://mdbtools.sourceforge.net/ I'm wondering if anyone in the R community has tried using this software to use MS-Access databases in R with a Linux system. If so, Were you successful? What kind of problems did you encounter? I have used it several times. The ODBC driver is not really (at all?) working but the command line tools seem to work well enough. I modified mdb-export and created a script that worked like mysqldump (to produce CREATE TABLE and INSERT statements) so that I was able to get the tables into MySQL to use with R. The latest version is quite a bit more recent than the one I have been using and I believe it has more features. Here is something that I have just tried and seems to work and avoids the need to take your data into another database: x - read.table(pipe('mdb-export -d \t databasename.mdb tableName'), sep=\t, header=TRUE) mdb-export exports the contents of a table from an Access database (fields separated with commas by default). The -d option specifies the delimiter (I prefer to use a tab). This seems to work well on my relatively small test database. I guess it would not take much work to write a little set of functions to get the table names (using mdb-tables) and do some other useful things. Not as good as having a working ODBC driver, but quite nice all the same. I'll have spend a little more time playing with this... Dave -- David Whiting University of Newcastle upon Tyne, UK. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ms access -- mysql -- R in Linux
Marc Schwartz [EMAIL PROTECTED] writes: [...] The issue at this point (among many I suspect) is that the mdbtools package is read-only to Access, though there are longer term plans to enable write functionality. So for the time being at least, there is no actual management ability to modify existing tables and queries. I've just checked some recent mailing list posts and it seems that write/update support for Jet3 (access 97) databases is underway. At least parts of it are described as primitive, but there is hope... -- David Whiting University of Newcastle upon Tyne, UK. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] ms access -- mysql -- R in Linux
David Whiting [EMAIL PROTECTED] writes: I'll have spend a little more time playing with this... Well, here's a simple start. There's more checking that needs to be done, but this makes the process a little more straight forward: mdbTables - function(dbname) { system(paste(mdb-tables -d '\t' -S, dbname), intern=TRUE) } mdbExport - function(dbname,tableName) { tableName - dQuote(tableName) read.table(pipe(paste(mdb-export -d '\t' , dbname, tableName)), sep=\t, header=TRUE) } With these functions you can now do: mytabs - mdbTables(myAccessDB.mdb) to get the list of tables in the DB. The first 5 seem to be information about the database and the tables seem to start from the 6th element of the vector. If the table you want is the one named in the 9th element of the vector: mytab - mdbTables(myAccessDB.mdb)[9] and you want that table in R: x - mdbExport(myAccessDB.mdb, mytab) At the moment you have to specify the extension (.mdb) otherwise mdb-export cannot find the file. -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] X11 device problem on linux: 100% cpu usage
--- Barry Rowlingson [EMAIL PROTECTED] wrote: David Whiting wrote: I'm using R 1.9.1 (patched, 5th July) on linux (Mandrake 9.2) and am having a problem with the X11() device. Trying to plot(1:10) results in my CPU going to 100% I'm not sure where to start with identifying the cause. Can someone suggest some things that I should look at? First off, you can try and figure out if its the client (R) or the server (your X-windows display server). [...] Thanks Barry. I don't have another machine I can play with at the moment, so I dug out an old R-1.8.1 rpm and installed that: same problem. I then tried a different window manager and the problem disappeared. So somehow fluxbox (my usual window manager) sees to be having a proble with R (everything else seems to run okay in fluxbox). For now I'll just use a different window manager until I have time to investigate this further. Thanks again. Dave __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] X11 device problem on linux: 100% cpu usage
Hi, I'm using R 1.9.1 (patched, 5th July) on linux (Mandrake 9.2) and am having a problem with the X11() device. Trying to plot(1:10) results in my CPU going to 100% and I have to terminate the process. Using postscript() with the same plot is fine. Everything else on my system seems to work fine. I have googled the R site for X11 and (problem OR error OR cpu) and have not seen anything that is recent or looks relevent, so I think this is a problem I have created myself. I'm not sure where to start with identifying the cause. Can someone suggest some things that I should look at? Thanks. Dave. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Size of R user base
Philippe Grosjean [EMAIL PROTECTED] writes: [...] A last comment/question: would it be possible to add some code in R that does the following: 1) it is triggered only if the software was used at least, let's say 10, or 20 times on the computer where it was installed, 2) then it checks if an update of R is available (just by looking if a given link in a centralized web site -CRAN?- exists), 3) when it finds that link, it just warns the user of an update in a not annoying way, for instance like that: [...] An update is available at http://cran.r-project.org. and, 4) it deactivate itself once the link is found. [...] Of course, this will only work with computers connected to the internet,... but at least, it could be one way to evaluate the number of R users. Would that be an infringment of Open Source, or any other rule of freedom? I don't know, but it does seem to be quite widespread (at least for commercial software). so, why an Open Source software would not be able to monitor the number of users? Smoothwall (www.smoothwall.org) does (did?) that, so there is an Open Source precedent. They did it both to keep an eye on the number of installations and to inform users of updates. I have no idea how accurate they think their statistics are though. Also, Smoothwall is a firewall so it going to be connected to the internet frequently and judging by the discussions so far the definition of a Smoothwall installation seems to be easier to pin-down than that of an R-user. One other concern: would it cause some kind of lag on startup if it has to check, especially when a machine is not connected or has a slow connection? -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [Way OT] [R] Size of R user base
Jason Turner [EMAIL PROTECTED] writes: And the Huli of Papua New Guinea use '15' to mean a very large number and '15 times 15 samting (something)' to mean something close to infinity. Dirk Eddelbuettel wrote: My preference goes with the numbering scheme attributed to a tribe on some island in the Pacific which consists of a 'factor' with four levels: 'one', 'two', 'three', and 'lots'. Australia. I've been there. Nice place. ;) Jason (who is an Australian) -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] tapply() and barplot() help files for 1.8.1
Martin Maechler [EMAIL PROTECTED] writes: and I like to help you. As I keep installed `(almost) all released versions of R ever installed on our machines' I can easily run 1.8.1 (or 1.4.x or 1.0.x ...) for you. The only difference between the help page help(tapply) is an extra require(stats) statement at the beginning of the `Examples' section in 1.9.0. and the only change to tapply() is group - rep.int(one, nx)#- to contain the splitting vector instead of group - rep(one, nx)#- to contain the splitting vector which hardly should have adverse results. In barplot, there's the new 'offset' option --- not in NEWS () and another change that may be a problem. Can you dig harder and if possible provide a reproducible (small..) example to make progress here... Last night I found I had a backup of the source of 1.8.0, built that and tested an example and it worked as in 1.9.0. I then started to question my sanity (or at least my competence). The code that follows should be a reproducible example. It creates a data frame that has the same structure as the data I am working with (with a number of other columns dropped) and is followed by the function that creates the barplot. The changes I have had to make to make it work as I thought it was working with 1.8.1 have ## NEW BIT after them, i.e. those lines were not there in the version I ran with 1.8.1. The important new lines are: x - matrix(x) ## NEW BIT and beside = TRUE, ## NEW BIT --- EXAMPLE --- ## Create some fake data. x - c(rep(, 926), rep(All Other Perinatal Causes, 46), rep(Anaemia, 3), rep(Congenital Abnormalities, 1), rep(Unsp. Direct Maternal Causes, 24)) y - runif(length(x)) tempdat - data.frame(smi=x, yllperdth=y) ## Define the function to make my barplot bodShare - function(x, fld, main = , userpar = 18, xlimMult=1.3 ) { ### # A horizontal barchart to display BoD shares # ### z - subset(x, as.character(x[,fld]) != ) z[, fld] - factor(z[, fld]) ## We need to change the parameters of the chart. ## First save the old settings. oldpar - par(mar) newpar - par(mar) ## Increase the size of the margin on the left so there ## is enough space for the long text labels (which will ## be displayed horizontally on the y-axis). newpar[2] - userpar ## Reduce the top margin because I will use a \caption in LaTeX ## instead. newpar[3] - 1 ## Now apply the new settings. par(mar = newpar) ## Calculate the % of YLLs for each group in the cause classification. x - tapply(z$yllperdth, z[, fld], sum) totalYLLs - sum(x) x - x / totalYLLs * 100 x - sort(x) causeNames - names(x) ## NEW BIT x - matrix(x) ## NEW BIT ## Plot the chart. horiz = TRUE makes it a bar instead of ## column chart. las = 1 prints the labels horizontally. xplot - barplot(x, ## main = main, horiz = TRUE, beside = TRUE,## NEW BIT names.arg = causeNames, ## NEW BIT xlab = Percent of YLLs, xlim = c(0, max(x) * xlimMult), las = 1) text(x + (max(x) * .15), xplot, formatC(x, digits=1, format='f')) ## Reset the old margin parameters. par(mar = oldpar) ## Write data to a table for export. # First we need to remove newlines from labels. names(x) - sub(\n, , names(x)) write.table(as.table(x), file = paste(tables/, fld, .csv, sep=), col.names=NA, sep=\t) names(x) - causeNames x[length(x)] } ## Create the barplot. bodShare(tempdat, smi) -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tapply() and barplot() help files for 1.8.1
Hi, I've just upgraded to 1.9.0 and one of my Sweave files that produces a number of barplots in a standard manner now produces them in a different way. I have made a couple of small changes to my code to get the back the output I was getting before upgrading and now (mostly out of curiosity) would like to understand what has changed. I *think* I've tracked it down to tapply() and/or barplot() and have not seen anything in the NEWS file regarding changes to these functions (as far a I can see). As part of doing my homework, I would like to read the version 1.8.1 help files for these two functions, but now that I've upgraded I'm not sure where I can find them. Is there a simple way for me to get copies of these two help files to compare with the versions in 1.9.0? As far as I can see, barplot() and tapply() in 1.9.0 work as described in their 1.9.0 help files (which does not surprise me). I've been lurking on this list long enough to know that if there has been a change it is documented, so it must be that I just haven't found it yet. If there hasn't been a change, then I am totally perplexed, because I have been running this Sweave file several times a day for the last few weeks and have not changed that part of it (I've been changing the LaTeX parts). In the part of the code that has changed I use tapply() to summarise some data and then plot it with barplot(). I now have to use matrix() on the output of tapply() before using barplot() because tapply() produces a list and barplot() wants a vector or matrix. In the code below, z is a dataframe, yllperdth is a numeric and fld is the name of a factor, both in the dataframe. Old version (as used with R 1.8.1): ## Calculate the % of YLLs for each group in the cause classification. x - tapply(z$yllperdth, z[, fld], sum) totalYLLs - sum(x) x - x / totalYLLs * 100 x - sort(x) ## Plot the chart. horiz = TRUE makes it a bar instead of ## column chart. las = 1 prints the labels horizontally. xplot - barplot(x, horiz = TRUE, xlab = Percent of YLLs, las = 1) New Version (as used with R 1.9.0): ## Calculate the % of YLLs for each group in the cause classification. x - tapply(z$yllperdth, z[, fld], sum) totalYLLs - sum(x) x - x / totalYLLs * 100 x - sort(x) causeNames - names(x) ## NEW BIT x - matrix(x) ## NEW BIT ## Plot the chart. horiz = TRUE makes it a bar instead of ## column chart. las = 1 prints the labels horizontally. xplot - barplot(x, beside = TRUE, ## NEW BIT names.arg = causeNames, ## NEW BIT horiz = TRUE, xlab = Percent of YLLs, las = 1) version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major1 minor9.0 year 2004 month04 day 12 language R A little while before upgrading I noted my previous R version (for a post that I redrafted 7 times and never sent because I found the answer through refining my draft), and it was: version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Patched major1 minor8.1 year 2004 month02 day 16 language R So, can I get the old help files? Or it is easy to point me to a documented change? Or is it clear from my code what has changed or what I am or was doing wrong? Thanks. Dave -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] length() of vector after using strptime()
Hi, I am trying to parse a date (that is read in as a factor) and add it to a dataframe. The length of the parsed date is shorter than the length of unparsed date and I therefore cannot add it to the dataframe: x [1] 20030807 20030807 20030807 20030808 20030809 20030809 20030809 20030809 [9] 20030808 20030808 20030809 20030808 20030808 20030819 20030819 20030821 . . . [129] 20030808 20030805 20030726 20030810 20030805 20030811 20030816 20030818 [137] 20030811 length(x) [1] 137 xParsed - strptime(as.character(x), %Y%m%d) xParsed [1] 2003-08-07 2003-08-07 2003-08-07 2003-08-08 2003-08-09 [6] 2003-08-09 2003-08-09 2003-08-09 2003-08-08 2003-08-08 . . . [131] 2003-07-26 2003-08-10 2003-08-05 2003-08-11 2003-08-16 [136] 2003-08-18 2003-08-11 length(xParsed) [1] 9 dta$dateint - xParsed Error in $-.data.frame(`*tmp*`, dateint, value = xParsed) : replacement has 9 rows, data has 137 platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major1 minor8.0 year 2003 month10 day 08 language R Can someone tell me what I'm doing wrong? Thanks. -- David Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Statistical computing
On Fri, Mar 28, 2003 at 12:43:25PM -0500, Frank E Harrell Jr wrote: On Fri, 28 Mar 2003 11:42:18 -0500 Tanya Murphy [EMAIL PROTECTED] wrote: Hello, I've been trying to familiarize myself with the computing tools of the trade (e.g. SAS, R, Perl, LaTex) and I've been getting somewhere with the individual programs, but I'm trying to get a better sense of how to integrate these tools. I'd like to use scripts and create reports in a more organized way. Can anyone recommend books or, better yet free online articles, on this topic? Maybe I should be a little more specific about what I do: I'm a research assistant in clinical epidemiology doing mainly data management and analysis. I do a number of repetitive tasks like updating a research database from the original clinic database and other sources, create reports, create graphical output for individual patients, as well as work on individual research projects. Unfortunately I am not working closely with 'real' statisticians who have probably developped good work habits using these tools. Any advice on 'the big picture' would be greatly appreciated. Thanks! Tanya Murphy Take a look at the following: http://hesweb1.med.virginia.edu/biostat/teaching/statcomp/notes.pdf http://hesweb1.med.virginia.edu/biostat/s/doc/splus.pdf http://hesweb1.med.virginia.edu/biostat/teaching/statcomp http://hesweb1.med.virginia.edu/biostat/presentations/feh/clinreport/dmcreport.pdf For statistical reports you have chosen well, in considering intergrating R and LaTeX. The Alzola-Harrell text also covers a bit about using make and Perl to run scripts (to get data from SAS to R, run R, etc.). I have been extremely impressed by the way sweave (combines LaTeX and R), and RODBC (in my case with MySQL) work together for data management, reporting, writing stuff and even creating presentations. I use a LaTeX document class called 'Prosper that creates PDF presentations with many of the features and appearance of MS Powerpoint presentations. For Sweave, take look at: http://www.ci.tuwien.ac.at/~leisch/Sweave/Sweave-manual-20021007.pdf http://cran.r-project.org/doc/Rnews/Rnews_2002-3.pdf (pages 28-31) For Prosper take a look at: http://sourceforge.net/projects/prosper/ and then google for: latex prosper and you will find many links to tutorials etc. Dave -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: R, w3m incl. images, ESS, ... [was Re: [R] mozilla and R --again]
One other thing to mention. w3m can be compiled with image support (which seemed strange to me at first considering w3m is a text browser). Any, this means that graphics can also be displayed inline. I have used Zed Shaw's html.r and run his example code. It works very nicely. I have a screen shot of the output if people want to see what it looks like but don't have a website on which to post it. If anyone wants to see it, let me know and I email it. It is a 14k png file, so is not too heavy. I have also downloaded Eric Lecoutre's R2HTML and will have a play with that. So, all (?) I need to do now is learn enough lisp to stick it all together. Dave. On Fri, Mar 28, 2003 at 06:35:39PM +, [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2003 at 06:38:22AM -0800, A.J. Rossini wrote: [...] fast. This does not provide all of the functionality of help.start() but might be a way of getting free of these java issues (for those happy to use emacs and ESS that is). Very, very interesting. Let me know if I can help. Without doubt. How about this problem: I can get input from the minibuffer and store it in a variable. I haven't yet found out how to call R from a lisp function (or more correctly do thing like eval-region/eval-my-search-function) and when I do I want to be able to pass the entered value to the function. I plan to try to work on this over the weekend so if you can give me some pointers in that direction it would be helpful. Please remember though that I am very, very new to lisp. Let us know if you make progress that you'd like to share! Okay, will do. BTW, what's the best way to handle discussion/collaboration on this? Off-list, at least until something more solid appears? It is probably a little tangential to R-help for now and I have not subscribed to the ESS list. Bye for now. Dave -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
R, w3m, ESS, ... [was Re: [R] mozilla and R -- again]
On Fri, Mar 28, 2003 at 06:38:22AM -0800, A.J. Rossini wrote: [...] fast. This does not provide all of the functionality of help.start() but might be a way of getting free of these java issues (for those happy to use emacs and ESS that is). Very, very interesting. Let me know if I can help. Without doubt. How about this problem: I can get input from the minibuffer and store it in a variable. I haven't yet found out how to call R from a lisp function (or more correctly do thing like eval-region/eval-my-search-function) and when I do I want to be able to pass the entered value to the function. I plan to try to work on this over the weekend so if you can give me some pointers in that direction it would be helpful. Please remember though that I am very, very new to lisp. Let us know if you make progress that you'd like to share! Okay, will do. BTW, what's the best way to handle discussion/collaboration on this? Off-list, at least until something more solid appears? It is probably a little tangential to R-help for now and I have not subscribed to the ESS list. Bye for now. Dave -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] mozilla and R -- again
On Thu, Mar 27, 2003 at 05:19:25PM -0800, Thomas Lumley wrote: On Thu, 27 Mar 2003, Frank E Harrell Jr wrote: With all the problems using java-based search on Linux I was wondering why java was needed. Could this have been done more simply? I am not very knowledgeable about java so please forgive me if the answer is obvious. Well, the searching needs a search program to be run, triggered by something you do in the browser. This requires either a program that can run in the browser (Java, as JavaScript I don't think can handle this sort of thing) or requires some way of calling R from the browser (even worse). Better solutions would seem to require either R doing the HTML rendering or R running an HTTP server. Neither is out of the question, but it isn't straightforward. Stata uses the former solution and I believe SAS uses the latter. -thomas I have just set up emacs to work with a text browser called w3m (using emacs-w3m). This is light and fast and displays webpages in an emacs buffer. It is surprisingly useful. I also have a little function that takes the output of help.search() and creates a webpage with hyperlinks and can therefore do a search that creates a webpage and then display the webpage in an emacs buffer. I have just start trying to cobble something together that combines these more formally and hope that I should be able to do something like M-x help-search, enter a search phrase and display the results as a webpage with links all in emacs/ESS/w3m. I don't have a clue about lisp (except that it seems to involve lots of brackets and has a considerable history) so this will is unlikely to move forward very fast. This does not provide all of the functionality of help.start() but might be a way of getting free of these java issues (for those happy to use emacs and ESS that is). I am doing this on linux, but w3m is also available for MS Windows. BTW just to push it I also used sweave(), xtable and latex2html together - it was quite interesting, although latex2html does not recognise the code environment - something else to tiniker with, perhaps. I haven't yet tried the html package that was announced here a short while ago, but the possibility of combining these as an alternative way of displaying output from R (esp. large tables?) could be fun to explore. Dave __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R]
Try the following function: student.exercise - function (i.think.so = TRUE) { if (i.think.so) { cat(Hmmm...how many marks do I get for answering this?\n) } else { cat(Sorry, my mistake\n) } } On Tue, Mar 25, 2003 at 12:50:11PM +0100, Cesar Ortega wrote: Hi there, Thank you in advance for your help. I need to do the following: 1. Take one file from excell and one from SPSS and with the data calculate: ESTIMATED N= SUM {1/PI(i)}; PI is the proportion ESTIMATED T(Y)= SUM {Yi/PI(i)}; i belongs to the sample. GINMi=[SUMi{(Yi/PI(i))*[1/PI(i)+SUMj(2/PI(j)]}]/[(2*ESTIMATED N*ESTIMATED T)]. i belongs to M (1000,etc.) times, WHERE j=i+1 WE HAVE ONLY ONE VARIABLE Y, BUT WITH THE FIRST POSITION i AND THE NEXT j, IN THE ASCENDING ORDER. And last to get the errors as: E1= [SUMi {|GINP-GINMi |}]/[M] ; i belongs M E2= SQRT[SUMi {|GINP-GINMi |}]/[M]; i belongs TO M Thanks, Cesar Ortega __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [stuart.leask@nottingham.ac.uk: [R] R in your pocket on a SharpZaurus]
Ah, but the interesting thing is that they are coming out with a 'clam' version like the 5MX. Details are limited at the moment, but that could mean the combination of 5MX usability with a supported linux distro. I am drooling in anticipation. Sounds like a I've finally finished my PhD and deserve a treat situation to me :) Dave On Thu, Mar 06, 2003 at 09:17:20AM -, Nigel Unwin wrote: Hi Dave Interesting indeed. I had a look at the Zaurus website. Nice looking machine, and the graphics appear to be very good. The main draw back based on the web pictures/video is that the key pad is small and cramped and really wouldn't allow the ease/efficiency of use the series 5 does but its getting closer to something that could be a replacement or advance on the series 5. Cheers for now Nigel To find out more about our work visit our web site: www.ncl.ac.uk/hopit - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Nigel Unwin [EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 9:15 AM Subject: [EMAIL PROTECTED]: [R] R in your pocket on a Sharp Zaurus] Interesting... and Sharp are coming out with a clam-verison of this PDA (i.e. like this Psion 5MX). Dave -- David Whiting Adult Morbidity and Mortality Project (AMMP) PO Box 65243, Aga Khan Foundation Building - Ground Floor Plot No 344 Urambo Street, Upanga, Dar es Salaam, Tanzania. Tel: +255 22 2153388, Fax: +255 22 2153385 AMMP website: www.ncl.ac.uk/ammp Against MS attachments. Why? See for example: http://www.goldmark.org/netrants/no-word/attach.html http://linuxtoday.com/news_story.php3?ltsn=2002-01-11-002-20-OP -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [stuart.leask@nottingham.ac.uk: [R] R in your pocket on a SharpZaurus]
Oops, sorry folks, I didn't mean to send any of these emails to the R list, I thought I was having a private discussion...I'm going to have to see what I did wrong. Dave iOn Thu, Mar 06, 2003 at 11:35:35AM +0100, Peter Dalgaard BSA wrote: [EMAIL PROTECTED] writes: Ah, but the interesting thing is that they are coming out with a 'clam' version like the 5MX. Details are limited at the moment, but that could mean the combination of 5MX usability with a supported linux distro. I am drooling in anticipation. Sounds like a I've finally finished my PhD and deserve a treat situation to me :) SL-C700, yes. I've been looking at that one too. Terminally cute... But I do wonder if you two are not actually talking about the same machine. Packing a full QWERTY keyboard in between F7-F12 of a normal keyboard has got to get a little cramped. For the uninitiated: http://www.the-gadgeteer.com/sharp-c700-review.html On Thu, Mar 06, 2003 at 09:17:20AM -, Nigel Unwin wrote: Hi Dave Interesting indeed. I had a look at the Zaurus website. Nice looking machine, and the graphics appear to be very good. The main draw back based on the web pictures/video is that the key pad is small and cramped and really wouldn't allow the ease/efficiency of use the series 5 does but its getting closer to something that could be a replacement or advance on the series 5. Interesting... and Sharp are coming out with a clam-verison of this PDA (i.e. like this Psion 5MX). -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] ESRI shape file import and time-space models
On Thu, Feb 13, 2003 at 12:36:51PM +0100, [EMAIL PROTECTED] wrote: Dear R user, I am running R under Windows 2000. I am looking for a routine for importing -shape files (ESRI) into R -dbase files (FOXPRO) into R I assume that as you say dbase (Foxpro) you mean Foxpro version 3.0, e.g. 2.x. I don't know of a way of opening dbase/foxpro files from within R (I think I saw once that RODBC can connect with dbase files, and if it does I'm sure you'll hear from someone else who knows more about it than me). If you have Foxpro and don't need an elegant solution, but just need to get the job done then you can export files from foxpro as tab-delimited files (COPY TO foxdata.txt DELIM WITH TAB) which you can then read into R with: dta - read.delim(foxdata.txt, header=FALSE, sep=\t, strip.white = TRUE) This gets the data in, but does not give you the field names. I have written a little foxpro program that creates a tab-delimited file with the headers (field names) that seems to work. Again, I read the data into R with read.delim(). Let me know if you want me to send you the Foxpro program. HTH, Dave -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] calling sweave function from latex
You say that you call R code embedded in your LaTeX document. I tend to think of it as LaTeX embedded in my R code. I think the answer to your question is 'no', but there might be ways to work around it. I use AUCTeX in emacs and can select a region of foo.sw and run latex on that. This works fine although you won't have access to R objects using \Sexpr{}. In practice I tend to use eval=FALSE to comment out R code chunks that I have run previously if I do not need to update or recreated their objects. This means that running Sweave on foo.sw then does not take too long to run the R chunks that do need to be run, i.e. foo.tex is created pretty quickly. Running latex does not then usually take long either. I use search and replace or the chunk navigation hotkeys (e.g. M-n g) when I need to change eval=FALSE to eval=TRUE. Creating a Makefile to run R with Sweave (as indicated in the FAQ in the Sweave manual) and then latex the resulting foo.tex should work pretty well to automate the process. I am still new to Sweave, but have had a lot of fun with it so far. I use emacs with ESS, Sweave, RefTex mode, LaTeX mode and Prosper - a presentation class that creates PDF presentations which (can if you want) look like MS Powerpoint presentations but with the advantage of LaTeX formatting. All the tools I need for analysis, writing, and presentations working together. My first serious use of this combination was last week. I had a foo.Rnw file which produced both my presentation and accompanying notes to handout. I discovered a mistake in my R code shortly before giving my presentation, fixed it, Sweave'd the file and updated my presentation and notes painlessly. A nice way to work. Dave. On Wed, Jan 29, 2003 at 02:12:15PM +1300, Sam McClatchie wrote: System info: Mandrake 9.0 R Version 1.6.1 ESS 5.1.21 Emacs 21.2.1 --- Colleagues I've been calling R-code embedded in my LaTex document using Sweave, but would like to make things more convenient. At present as I understand it you first process the R chunks of code using the Sweave function called from within R to process a precursor file e.g. foo.sw to get a LaTex file (foo.sw.tex) that you then process with latex foo.sw.tex. example code segment %\item {\bf Matched trawl and acoustic data} \label{real data} \item {\bf Results} sweave code echo=false,results=hide= average.trawl.spp.composition() @ insert figure generated from sweave code \begin{figure} \includegraphics[scale=0.6]{../figures/bycatch_by_weight} \caption{\label{catch by weight} Proportions of selected species (from Table \ref{ts length regressions}) in the fish assemblage using catch rate ($kg\ km{-1}$) as an approximation for fish density (neglecting variable capture efficiencies). Note: there were no oblique banded rattails in this dataset, although we have a \textit{TS-length} regression for them (see Table \ref{ts length regressions}). Box plot centre line = meadian, box limits are $25^{th}$ and $75^{th}$ quartiles, whiskers represent 1.5 times the interquartile range from the median, and points outside the whiskers are the tails of the distributions.} \end{figure} --- This works fine, but it is cumbersome for someone who likes to write a bit and then latex that additional bit. Of course I can just add the new LaTex code chunks to the foo.sw.tex and latex that, but I have to remember to copy the foo.sw.tex back to foo.sw or the versions get mixed up. Trivial, but annoying. The question is: can I call the Sweave function from within LaTex so I just latex the foo.sw.tex and the Sweave chunks will also get processed. This would be much tidier. One suspects that the short answer is 'no'. Best fishes Sam -- Sam McClatchie, Research scientist (fisheries acoustics)) NIWA (National Institute of Water Atmospheric Research Ltd) PO Box 14 901, Kilbirnie, Wellington, New Zealand [EMAIL PROTECTED] Research home page http://www.smcc.150m.com/ /\ xX( /// \\\ /// %)Xx / \\ (((@ (((% ..xX(?O?)Xx __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Dave Whiting Dar es Salaam, Tanzania __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help