Re: [R] How to get commands history as a character vector instead of displaying them?
Thanks, Wacek and Romain! Your solutions worked very well in RGui and Rterm in interactive mode. My final purpose was to obtain the file name of the postscript device in Rweb (http://pbil.univ-lyon1.fr/Rweb/); now I found savehistory() would not work because Rweb was non-interactive. I didn't realize it until I try(savehistory()) and got an error message. Now I found a solution by myself: we can list the *.ps files and pick the most recently created (modified, visited, ...) one, e.g. x = file.info(list.files(pattern = .*\\.ps$)) x = x[order(x$atime), ] rownames(x)[nrow(x)] Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Mon, Mar 23, 2009 at 6:13 PM, Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: Romain Francois wrote: Yihui Xie wrote: Hi Everyone, I want to get the commands history as a character vector instead of just displaying them, but the function history() just returns NULL. I checked the source code of 'history' and could not find a solution. Anybody has an idea? Thanks! history eventually calls file.show, which will use the pager option to determine how to show the file, so you can do something like that: history - function( ... ){ old.op - options( pager = function( files, header, title, delete.file ) readLines( files ) ); on.exit( options( old.op ) ) utils::history(...) } history( pattern = png ) i think the following is an acceptable alternative: history = function() { file = tempfile() on.exit(unlink(file)) savehistory(file) readLines(file) } the output is *lines* of text, but if you need whole executable expressions, you can parse the output: 1 + 1 ph = parse(text=history()) as.list(ph) ph[length(ph)-1] # expression(1 + 1) eval(ph[length(ph)-1]) # [1] 2 vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convert Character to Date
Hello, I have a date in the format Year-Month Name (e.g. 1990-January) and R classes it as a character. I want to convert this character into a date format, but when I try as.Date(1990-January, %Y-%B), I get back NA. The function strptime also gives me NA back. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Convert Character to Date
The yearmon class in the zoo package can represent year/months: library(zoo) ym - as.yearmon(1990-January, %Y-%B); ym [1] Jan 1990 as.Date(ym) [1] 1990-01-01 On Tue, Mar 31, 2009 at 3:14 AM, Bob Roberts quagmire54...@yahoo.com wrote: Hello, I have a date in the format Year-Month Name (e.g. 1990-January) and R classes it as a character. I want to convert this character into a date format, but when I try as.Date(1990-January, %Y-%B), I get back NA. The function strptime also gives me NA back. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Package candisc
Hi listers, I am working on an canonical discriminant analysis, but I am having some trouble to use the CANDISC function... I just installed the last R version and installed the package CANDISC... But, I am getting the following message because about a permission: The downloaded packages are in C:\Users\Marcio\AppData\Local\Temp\Rtmpz2kFUm\downloaded_packages updating HTML package descriptions Warning message: In file.create(f.tg) : cannot create file 'C:\PROGRA~1\R\R-28~1.1/doc/html/packages.html', reason 'Permission denied' Could anybody tell me if I am forgeting about something in order to use the CANDISC function! Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/Package-candisc-tp22797571p22797571.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] data.table is on CRAN (enhanced data.frame for time series joins and more)
Dear all, The data.table package was released back in August 2008. This email is to publicise its existence in response to several suggestions to do so. It seems I didn't send a general announcement about it at the time and therefore perhaps, not surprisingly, not many people know about it. Glancing at some r-help threads recently supports the idea of sending a public announcement. The main difference between data.frame and data.table is enhanced functionality in [.data.table where most documentation for this package lives i.e. help([.data.table). Selected extracts from the package documentation follow. The package builds on base R functionality to reduce 2 types of time : 1. programming time (easier to write, read, debug and maintain) 2. compute time when combining database like operations (subset, with and by) and provides similar joins that merge provides but faster. This is achieved by using R's column based ordered in-memory data.frame, eval within the environment of a list (i.e. with), the [.data.table mechanism to condense the features and compiled C to make certain operations fast. [.data.table is like [.data.frame but i and j can be expressions of column names directly. Furthermore i may itself be a data.table which invokes a fast table join using binary search in O(log n) time. Allowing i to be data.table is consistent with subsetting an n-dimension array by an n-column matrix in base R. data.tables do not have rownames but may instead have a key of one or more columns using setkey. This key may be used for row indexing instead of rownames. Examples comparing [.data.frame and [.data.table : DF = data.frame(a=1:5, b=6:10) DT = data.table(a=1:5, b=6:10) tt = subset(DF,a==3) ss = DT[a==3]# just use the column name 'a' directly. No need to remember the comma. The i argument is like the 'where' in SQL. identical(as.data.table(tt), ss) tt = with(subset(DF,a==3),a+b+1) ss = DT[a==3,a+b+1]# j is like select in SQL and the select argument of subset in base R. j can be an expression of column names directly, including a data.table of multiple expressions. Here the j expression is executed just for the rows matching the i argument. identical(tt, ss) # Examples above use vector scans i.e. the a==3 expression first creates a logical vector as long as the total number of rows and then evaluates a==3 for every row. # Examples below use binary search, invoked by passing in a data.table as the i argument. Joins in SQL are performed in the where clause and the i argument is like where, so this seems very natural (to me anyway!) DT = data.table(a=letters[1:5], b=6:10) setkey(DT,a) identical(DT[J(d)], DT[4])# binary search to row for 'd' DT = data.table(id=rep(c(A,B),each=3), date=c(20080501L,20080502L,20080506L), v=1:6) setkey(DT,id,date) DT[A]# all 3 rows for A since mult by default is all DT[J(A,20080502L)] # row for A where date also matches exactly DT[J(A,20080505L)] # NA since 5 May is missing (outer join by default) DT[J(A,20080505L),nomatch=0] # inner join instead dts = c(20080501L, 20080502L, 20080505L, 20080506L, 20080507L, 20080508L) DT[J(A,dts)] # 3 of the dates in dts match exactly DT[J(A,dts),roll=TRUE] # roll previous data forward i.e. return the prevailing observation DT[J(A,dts),rolltolast=TRUE] # roll all but last observation forward tables(mb=TRUE) # prints table names, number of rows, size in memory Thanks to all those who have made suggestions and feedback so far. Further comments and feedback on the package would be much appreciated. Regards, Matthew ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convert date to integer
Hello, I have a dataframe containing dates, times and other parameters. The times have the format h:m, e.g. 13:00 or 5:30, R classes them as factors. I want to change the times to integers e.g. 13:00 - 1300. I tried to use chron to create a chronological object, but it didn't work for the times (yust for the dates). - Tamara Hoebinger University of Vienna -- View this message in context: http://www.nabble.com/Convert-date-to-integer-tp22800457p22800457.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Efficient calculation of partial correlations in R
Hello, I'm looking for an efficient function for calculating partial correlations. I'm currently using the pcor.test () function, which is equivalent to the cor.test() function, and can receive only single vectors as input. I'm looking for something which is equivalent to the cor() function, and can receive matrixes as input (which should make the calculations much more efficient). Thanks, Schragi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to increase the limit for max.print in R
Hi All, I am using DNAcopy package in R for copy number analysis of 500K chip. The final output which I get from DNA copy is too big to be printed in a file. So I am getting an error as reached getOption(max.print) -- omitted 475569 rows Can somebody please provide me the pointers with how to increase the limit for max.print . Thanks, Pooja DISCLAIMER\ ==\ \ \ [[alternative HTML version ...{{dropped:7}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Row/columns names within 'assign' command
Dear all, I am attempting to add row and column names to a series of tables (120 in total) which have 2 variable parts to their name. These tables are created as follows: # Create table indexes index - expand.grid(year = sprintf(%04d, seq(1986, 1995)), month = sprintf(%02d, 1:12)) # Read in and assign file names to individual objects with variable name components for (i in seq(nrow(index))) { assign(paste(Fekete_,index$year[i], index$month[i], sep=''), read.table(file=paste(C:\\Data\\comp_runoff_hd_, index$year[i], index$month[i], .asc, sep=), header=FALSE, sep=)) # Create index of file names files - print(ls()[1:120], quote=FALSE) # This is the best way I could manage to successfully attribute all the table names to a single list - I realise it's horrible coding (especially as it relies on the first 120 objects stored in the memory actually being the objects I want to use)... files [1] Fekete_198601 Fekete_198602 Fekete_198603 Fekete_198604 [5] Fekete_198605 Fekete_198606 Fekete_198607 Fekete_198608 [9] Fekete_198609 Fekete_198610 Fekete_198611 Fekete_198612 [13] Fekete_198701 Fekete_198702 Fekete_198703 Fekete_198704 [17] Fekete_198705 Fekete_198706 Fekete_198707 Fekete_198708 ...[truncated - there are 120 in total] # Provide column and row names according to lat/longs. rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)) for (i in 1:120) { Fekete_table - get(paste(Fekete_, index$year[i], index$month[i], sep='')) colnames(Fekete_table) - columnnames rownames(Fekete_table) - rnames assign(paste(Fekete_,index$year[i], index$month[i], sep=''), colnames(Fekete_table)) } As you can see, I'm in a bit of a muddle during the column/row name assignments. In fact, this loop simply writes over the existing data in the tables and replaces it with all the column name values (whilst colnames remains NULL). The problem I've been having is that I can't seem to tell R to assign these column/row heading values to the colnames/rownames within an assign command - it seems to result in errors even when I try breaking this assignment process down into steps. How do I go about assigning rows and columns in this way, and how do I create a better way of indexing the file names? Many thanks for any help offered, Steve _ 25GB of FREE Online Storage – Find out more __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Does R support double-exponential smoothing?
I want to use double-exponential smoothing to forecast time series datas,but I couldn't find it in the document,does R support this method? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to increase the limit for max.print in R
On Tue, 2009-03-31 at 14:47 +0530, pooja arora wrote: Hi All, I am using DNAcopy package in R for copy number analysis of 500K chip. The final output which I get from DNA copy is too big to be printed in a file. So I am getting an error as reached getOption(max.print) -- omitted 475569 rows Can somebody please provide me the pointers with how to increase the limit for max.print . Thanks, Pooja Hi Pooja, You must use options command, something like this options(max.print=5.5E5) For more information type? ?options -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] summarize logical string
you need rle(), e.g., x - c(0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0) rle(x)$lengths I hope it helps. Best, Dimitris dba...@cnb.csic.es wrote: Hello everyone, I am a newbie, working on a gene clustering problem, and I have problems in summarizing a logical string into number of repeats of each value. In other words, how could I obtain from 0 1 1 1 0 0 0 0 1 1 0 1 0 0 this: 1 3 4 2 1 1 2 so a string that gives me the number of repeated values, no matter zeros or ones. I've been diving in the manuals and the mailing list but, nothing interesting, apparently... I would be very grateful if anyone could give me some advice. Djordje Bajic Logic of Genomic Systems Lab Centro Nacional De Biotecnología - CSIC Cantoblanco, Madrid, España __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] summarize logical string
Thank you very much, rapid and very helpful. Best, Djordje you need rle(), e.g., x - c(0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0) rle(x)$lengths I hope it helps. Best, Dimitris dba...@cnb.csic.es wrote: Hello everyone, I am a newbie, working on a gene clustering problem, and I have problems in summarizing a logical string into number of repeats of each value. In other words, how could I obtain from 0 1 1 1 0 0 0 0 1 1 0 1 0 0 this: 1 3 4 2 1 1 2 so a string that gives me the number of repeated values, no matter zeros or ones. I've been diving in the manuals and the mailing list but, nothing interesting, apparently... I would be very grateful if anyone could give me some advice. Djordje Bajic Logic of Genomic Systems Lab Centro Nacional De Biotecnología - CSIC Cantoblanco, Madrid, España __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] summarize logical string
Hello everyone, I am a newbie, working on a gene clustering problem, and I have problems in summarizing a logical string into number of repeats of each value. In other words, how could I obtain from 0 1 1 1 0 0 0 0 1 1 0 1 0 0 this: 1 3 4 2 1 1 2 so a string that gives me the number of repeated values, no matter zeros or ones. I've been diving in the manuals and the mailing list but, nothing interesting, apparently... I would be very grateful if anyone could give me some advice. Djordje Bajic Logic of Genomic Systems Lab Centro Nacional De Biotecnología - CSIC Cantoblanco, Madrid, España __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] To save Trellis Plots on A3 size paper (Portrait and Landscape)
Debabrata Midya Debabrata.Midya at commerce.nsw.gov.au writes: I like to save Trellis Plots on A3 size paper (Portrait and Landscape). Since a3 is not among the paper choices, you could give the width and height in inches (b...) explicitly. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] To save Trellis Plots on A3 size paper (Portrait and Landscape)
Debabrata Midya wrote: I like to save Trellis Plots on A3 size paper (Portrait and Landscape). Since a3 is not among the paper choices, you could give the width and height in inches (b...) explicitly. Dieter -- View this message in context: http://www.nabble.com/To-save-Trellis-Plots-on-A3-size-paper-%28Portrait-and%09Landscape%29-tp22796457p22801875.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unicode only works with a second one
Hi Thomas, I get the zodiac symbols okay without the trailing \u3030 on FC9 Linux and R-2.8.1. Perhaps it's only on Windows. Might try it at work tomorrow where I can boot into WinXP. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to increase the limit for max.print in R
Thanks, it Worked. Do you have any idea how much is the max limit for max.print Thanks and Regards, Pooja Arora | Associate Software Engineer- Washu-caB2B | Persistent Systems Limited pooja_ar...@persistent.co.in | Cell: +91 9923223668 | Tel: +91 (20) 3023 4007 Innovation in software product design, development and delivery- www.persistentsys.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bernardo Rangel Tura Sent: Tuesday, March 31, 2009 2:59 PM To: r-help@r-project.org Subject: Re: [R] how to increase the limit for max.print in R On Tue, 2009-03-31 at 14:47 +0530, pooja arora wrote: Hi All, I am using DNAcopy package in R for copy number analysis of 500K chip. The final output which I get from DNA copy is too big to be printed in a file. So I am getting an error as reached getOption(max.print) -- omitted 475569 rows Can somebody please provide me the pointers with how to increase the limit for max.print . Thanks, Pooja Hi Pooja, You must use options command, something like this options(max.print=5.5E5) For more information type? ?options -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. DISCLAIMER\ ==\ \ ...{{dropped:4}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Programming objects in R
I am planning a project where an object-oriented approach would be appropriate, and for a number of reasons I would prefer using either Python or R. My problem at the moment is to find out how to do OO programming in R. Are there any introductory texts anywhere ? Tom -- ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : bac...@psych.uib.noURL : http://www.galton.uib.no/ | ++ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Convert date to integer
thoeb t.hoebinger at gmail.com writes: Hello, I have a dataframe containing dates, times and other parameters. The times have the format h:m, e.g. 13:00 or 5:30, R classes them as factors. Probably you have read in the data from a file with read.table; check stringsAsFactors in the docs to avoid the conversion from the beginning. I want to change the times to integers e.g. 13:00 - 1300. I tried to use chron to create a chronological object, but it didn't work for the times (yust for the dates). If that's all (no NA?) a simple replace might work df = data.frame(tstr=c(13:00,5:30)) df$tint = as.integer(gsub(:,,as.character(df$tstr))) Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nonparametric analysis of repeated measurements data with sm library
Dear all, Does anybody know how to get more evaluation points in performing Nonparametric analysis of repeated measurements data with sm library. The following command gives the estimation for 50 points, but I would like to increase to 100 points But I do not know how to do that. library(sm) provide.data(citrate, options=list(describe=FALSE)) provide.data(dogs, options=list(describe=FALSE)) a - sm.rm(y=citrate, display.rice=TRUE) a$eval.points Many thanks in advance. Alphonse [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nonparametric analysis of repeated measurements data with sm library
Dear all, Does anybody know how to get more evaluation points in performing Nonparametric analysis of repeated measurements data with sm library. The following command gives the estimation for 50 points, but I would like to increase to 100 points But I do not know how to do that. library(sm) provide.data(citrate, options=list(describe=FALSE)) provide.data(dogs, options=list(describe=FALSE)) a - sm.rm(y=citrate, display.rice=TRUE) a$eval.points Many thanks in advance. Alphonse [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot Geotiff
Is there a way to plot Geotiff, combining it with spatial (vector) data? Paulo E. Cardoso [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programming objects in R
I think that 'Software for Data Analysis' by John Chambers should certainly be on the reading list. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Tom Backer Johnsen wrote: I am planning a project where an object-oriented approach would be appropriate, and for a number of reasons I would prefer using either Python or R. My problem at the moment is to find out how to do OO programming in R. Are there any introductory texts anywhere ? Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error during DPpackage compilation
Dear All, I've had trouble compiling DPpackage as a user in one system. It works fine as root in other machines. I can see any clues in error messages My guess is that it is a permissions matter. Any help is appreciated. OS: Linux Kernel: 2.6.27 SMP Arch: Intel 64 bits gfortran not available Thank you. --8- g77 -fpic -g -O2 -c LDDPdensity.f -o LDDPdensity.o LDDPdensity.f: In subroutine `lddpcdensity': LDDPdensity.f:12: mcmc,nsave,seed, 1 LDDPdensity.f:226: (continued): real*8 thetasave(nsave,p+p*(p+1)/2+3) 2 Invalid declaration of or reference to symbol `nsave' at (2) [initially seen at (1)] LDDPdensity.f:12: mcmc,nsave,seed, 1 LDDPdensity.f:236: (continued): integer mcmc(3),nburn,nskip,nsave,ndisplay 2 Invalid declaration of or reference to symbol `nsave' at (2) [initially seen at (1)] LDDPdensity.f:9: cpo,thetasave,randsave, 1 LDDPdensity.f:291: (continued): open(unit=1,file='dppackage1.out',status='unknown', 2 Invalid declaration of or reference to symbol `thetasave' at (2) [initially seen at (1)] LDDPdensity.f:9: cpo,thetasave,randsave, 1 LDDPdensity.f:291: (continued): open(unit=1,file='dppackage1.out',status='unknown', 2 Invalid declaration of or reference to symbol `randsave' at (2) [initially seen at (1)] LDDPdensity.f:15: xtx,xtx2,xty,xty2,fs,fm,worksam,workcpo) 1 LDDPdensity.f:291: (continued): open(unit=1,file='dppackage1.out',status='unknown', 2 Invalid declaration of or reference to symbol `worksam' at (2) [initially seen at (1)] LDDPdensity.f:430: xty2=matmul(xtx2,mub) ^ Expression at (^) has incorrect data type or rank for its context LDDPdensity.f:430: warning: xty2=matmul(xtx2,mub) ^ Reference to unimplemented intrinsic `MATMUL' at (^) (assumed EXTERNAL) LDDPdensity.f:430: xty2=matmul(xtx2,mub) ^ Invalid declaration of or reference to symbol `matmul' at (^) [initially seen at (^)] LDDPdensity.f:458: betam=matmul(xtx,xty) ^ Expression at (^) has incorrect data type or rank for its context LDDPdensity.f:515: xty=matmul(sbeta0i,m0) ^ Expression at (^) has incorrect data type or rank for its context LDDPdensity.f:535: xty=xty+matmul(xtx2,betawork) ^ Expression at (^) has incorrect data type or rank for its context LDDPdensity.f:538: betawork=matmul(xtx,xty) ^ Expression at (^) has incorrect data type or rank for its context make: *** [LDDPdensity.o] Error 1 ERROR: compilation failed for package 'DPpackage' --8- Alexandre -- Alexandre Santos Aguiar, MD, SCT -- website: http://spsconsultoria.com/ Phone: +55-11-3717-4866 (SP) Phone: +55-21-3717-4866 (RJ) Voicemail: +55-11-2157-6891 (SP) Fax: +55-11-2501-1972 (SP) - New fax number! Please, update records. -- signature.asc Description: This is a digitally signed message part. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programming objects in R
The third chapter of the book R Programming for Bioinformatics by Robert Gentleman is on object-oriented programming in R. Dan Viar Chesapeake, VA On Tue, Mar 31, 2009 at 6:15 AM, Patrick Burns pbu...@pburns.seanet.com wrote: I think that 'Software for Data Analysis' by John Chambers should certainly be on the reading list. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Tom Backer Johnsen wrote: I am planning a project where an object-oriented approach would be appropriate, and for a number of reasons I would prefer using either Python or R. My problem at the moment is to find out how to do OO programming in R. Are there any introductory texts anywhere ? Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R Language Bloggers and Web Sites Owners
Dear List, Apologies in advance for non bloggers for the spam on the slightly off topic. This is an invitation to all R language bloggers to help spread the world at a forum where leading authors come together. Current only 1 R blogger is there- David Smith, from Revolution Computing. There are many from SAS (Jason Burke,Gary Conkins) ,one from SPSS (Jon Peck) and others from SAP,Aster Data .Visit www.smartdatacollective.com for a preview of the site. The Smart Data Collective is the Data-Driven Enterprise Community. Discuss business intelligence, data mining, data warehousing, enterprise data, e-gov, data integration, CRM, predictive analytics, risk management, and anything else data-related! It is a moderated site ,editorially independent but sponsored from Teradata. If you have a blog already, join smartdatacollective.com as a member and featured blogger (which, I hasten to add, involves no additional work on your part.) We can set up an RSS feed link to your existing blog so your posts automatically become part of the SmartData Collectivecontent flow with no further effort from you. As a member/contributor you'll be able to connect and interact with other experts and connect with many of the world's leading business organizations. You can create a profile to promote yourself and your work. The posts are moderated by an editor and we select only those that are on-target for this particular community. This is a great, no-hassle way to grow your professional reputation and reach lots of new readers. You will be listed as a featured blogger on the main page with a link back to your blog on each individual post and, of course, this is a non-exclusive agreement. You retain the copyright to your work. We also draw from our bloggers for webinars and other outreach efforts. Send me a note if you'd like to participate. Register at SmartData Collective End of Message Regards a...@socialmediatoday.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] which rows are duplicates?
Wacek Kusnierczyk wrote: Michael Dewey wrote: At 05:07 30/03/2009, Aaron M. Swoboda wrote: I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 i don't have any solution significantly better than what you have already been given. i now seem to have one: # dummy data data = data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace=TRUE)) # add a class column; identical rows have the same class id data$class = local({ rows = do.call('paste', c(data, sep='\r')) with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }) data # x y class # 1 2 2 3 # 2 2 1 2 # 3 2 1 2 # 4 1 2 1 # 5 2 2 3 this approach seems to be roughly comparable to michael's, depending on the shape (and size?) of the input: # dummy data frame, just integers n = 100; m = 100 data = as.data.frame( matrix(nrow=n, ncol=m, sample(n, m*n, replace=TRUE))) # do a simple benchmarking library(rbenchmark) benchmark(replications=100, order='elapsed', columns=c('test', 'elapsed'), waku=local({ rows = do.call('paste', c(data, sep='\r')) data$class = with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }), mide=local({ unique = unique(data) data = merge(data, cbind(unique, class=1:nrow(unique))) })) # test elapsed # 1 waku 0.503 # 2 mide 3.269 and for m = 10 and n = 1000 i get: # test elapsed # 1 waku 0.571 # 2 mide 15.836 while for m = 1000 and n = 10 i get: # test elapsed # 1 waku 1.110 # 2 mide 2.461 the type of the content should not have any impact on the ratio (pure guess, no testing done). whether my approach is more intuitive is arguable. note that, unlike in michael's solution, the final result (the data frame with a class column added) is in the original order. (and sorting would add a performance penalty in the other case.) my previous remarks about the treatment on NAs still apply; the do.call('paste', ... is taken from duplicated.data.frame. regards, vQ Does this do what you want? x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) data.u - unique(data) data.u x y z 1 1 2 3 2 3 4 4 data.u - cbind(data.u, set = 1:nrow(data.u)) merge(data, data.u) x y z set 1 1 2 3 1 2 1 2 3 1 3 3 4 4 2 You need to do a bit more work to get them back into the original row order if that is essential. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programming objects in R
Patrick Burns wrote: I think that 'Software for Data Analysis' by John Chambers should certainly be on the reading list. It seems that that is true. I have a number of R books, but not that one. Thanks for the suggestion. Tom Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Tom Backer Johnsen wrote: I am planning a project where an object-oriented approach would be appropriate, and for a number of reasons I would prefer using either Python or R. My problem at the moment is to find out how to do OO programming in R. Are there any introductory texts anywhere ? Tom -- ++ | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology | | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY | | Tel : +47-5558-9185Fax : +47-5558-9879 | | Email : bac...@psych.uib.noURL : http://www.galton.uib.no/ | ++ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Jarque-Bera test and Ljung-Box test for multivariate time series
Hi! I know that there is function in fBasics package for univariate Jarque-Bera test and a funtion for univariate Ljung-Box test in stats package. But I am wondering if there is a function somewhere to do the tests for multivariate time series? Thanks, John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Language Bloggers and Web Sites Owners
Ajay ohri wrote: Dear List, Apologies in advance for non bloggers for the spam on the slightly off topic. This is an invitation to all R language bloggers to help spread the world at a forum where leading authors come together. Current only 1 R blogger is there- David Smith, from Revolution Computing. no, there are (at least) two. following the suggestions from a few r developers, i have created a blog named 'Don't Use R!' [1] (well, they suggested a blog, not the title), but there are no entries there so far. the plan is to import into the blog some of my comments posted on this list. in case anyone gets furious, i intend to change the title to something less antimarketing-ish when the blog really starts off. (and fear not, i'm not going to spread the world.) best, vQ [1] http://dontuser.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R commands equivalent for STATA commands
Hello I need help to convert a few commands of STATA to R, can someone help me for these ones: 1) stsum, by(variable) 2) sts list, by(variable) 3) stset Time, failure(Status) Also where can I find R commands equivalent to STATA commands. Thank you in advance Sunita -- View this message in context: http://www.nabble.com/R-commands-equivalent-for-STATA-commands-tp22803257p22803257.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unicode only works with a second one
Thanks for the feedback. I did now try Vista (2.8.1), XP (2.9.0alpha) and Win2000 (2.8.1) and non did work compeletely, only on Vista/2.8.1 I got some symbols if I add the other sign. I will try the my.symbols later today, when i am at home. Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Factor Analysis Output from R and SAS
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I ran factor analysis using R and SAS. However, I had different outputs from R and SAS. Why they provide different outputs? Especially, the factor loadings are different. I did real dataset(n=264), however, I had an extremely different from R and SAS. Why this things happened? Which software is correct on? factanal uses ML-method for estimating the loadings. SAS and SPSS use the principal component method. Maybe you should better use princomp + varimax. However, the rotated solutions are basically the same :) Yours sincerely Sigbert -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJ0gWdWvYUYQkj1zkRAi/NAJ9gHEcXbYzafE9MEbL8ZnCY/B8inwCeORuB 0vQ81ucg86IrkJl+EJSP1n0= =lDR6 -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Efficient calculation of partial correlations in R
Dear Schragi, There's a function named partial.cor() in the Rcmdr package, but it's so simple that I'll just reproduce it here: partial.cor - function (X, ...) { R - cor(X, ...) RI - solve(R) D - 1/sqrt(diag(RI)) R - -RI * (D %o% D) diag(R) - 0 rownames(R) - colnames(R) - colnames(X) R } Of course, this gives you the partial correlation between each pair of variables controlling for all others, which is I assume what you want. I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Schragi Schwartz Sent: March-31-09 5:21 AM To: r-help@r-project.org Cc: 'Dror Hollander' Subject: [R] Efficient calculation of partial correlations in R Hello, I'm looking for an efficient function for calculating partial correlations. I'm currently using the pcor.test () function, which is equivalent to the cor.test() function, and can receive only single vectors as input. I'm looking for something which is equivalent to the cor() function, and can receive matrixes as input (which should make the calculations much more efficient). Thanks, Schragi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Mapping in R
Kelsey Scheitlin kns07g at fsu.edu writes: Hi, I am looking for a specific mapping capability in R that I can't seem to find, but think exists. I would like to make a border of a map have alternating black and white squares instead of the common latitude and longitude grid. (example: http://www.cccturtle.org/sat_maps/map0bw8.gif). If anyone knows if there is or is not a function capable if doing this could you please let me know? Thanks! Kelsey It's not QUITE what you're looking for, but plot(0:1,0:1,bty=n,axes=FALSE) box(bty=o,lwd=6,lty=FF) (See ?box, ?par under bty and Line Type Specification) Otherwise you can do this by using par(usr) to find the edges of the map, seq() to construct appropriate x and y sequences, and segments() to draw the lines. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R for Mac OS X Search in Help
Hi: A small query about R for Mac on OSX: when looking at the help system screens, it does not seem to be possible to search within them. For example, when looking at a long help page (e.g. for par) I often want to search for a particular parameter. But I don't see how. I just have to scroll and search by eye. Is there a better way? Thanks Robt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] scope of variables in R
I need to allocate (using C nomenclature) a set of global variables, some integer scalars and some double vectors. I have placed the name of such variables in the file containing the main script and the called functions: # # --- GLOBAL DATA CONSTANTS -- EntrThreshold - 1.e+35 NCMAX - 50 ncof - 0 ioff - 0 joff - 0 sig- 0.0 cc - vector(length=NCMAX) cr - vector(length=NCMAX) Function pwtset, called by function ford, changes the content of variable 'ncof' as confirmed by the debigging printed values. But when function pwset exits and the flow control returns to the caller ford then variable 'ncof' has not kept the value assigned by pwset, as if function pwset had allocated its own variable 'ncof'. My question is: how can I have R interpreter allocate globalvariables visible and accessible by all the functions in the same file ? pwtset - function(n) { cat(\n BEGIN 'pwtset' \n) if(n 100){ ncof - n }else{ ncof - n -100 } } BEGIN 'pwtset' function 'pwtset': ncof = 4 END 'pwtset' function 'ford': BEFORE calling wt1, ncof: 0 Thank you very much for removing my confusion. Maura tutti i telefonini TIM! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Factor Analysis Output from R and SAS
Dear Users, I ran factor analysis using R and SAS. However, I had different outputs from R and SAS. Why they provide different outputs? Especially, the factor loadings are different. I did real dataset(n=264), however, I had an extremely different from R and SAS. Why this things happened? Which software is correct on? Thanks in advance, - TY #R code with example data # A little demonstration, v2 is just v1 with noise, # and same for v4 vs. v3 and v6 vs. v5 # Last four cases are there to add noise # and introduce a positive manifold (g factor) v1 - c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 - c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 - c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 - c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 - c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 - c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 - cbind(v1,v2,v3,v4,v5,v6) cor(m1) # v1v2v3v4v5v6 #v1 1.000 0.9393083 0.5128866 0.4320310 0.4664948 0.4086076 #v2 0.9393083 1.000 0.4124441 0.4084281 0.4363925 0.4326113 #v3 0.5128866 0.4124441 1.000 0.8770750 0.5128866 0.4320310 #v4 0.4320310 0.4084281 0.8770750 1.000 0.4320310 0.4323259 #v5 0.4664948 0.4363925 0.5128866 0.4320310 1.000 0.9473451 #v6 0.4086076 0.4326113 0.4320310 0.4323259 0.9473451 1.000 factanal(m1, factors=3) # varimax is the default # Output from R #Call: #factanal(x = m1, factors = 3) #Uniquenesses: # v1v2v3v4v5v6 #0.005 0.101 0.005 0.224 0.084 0.005 #Loadings: # Factor1 Factor2 Factor3 #v1 0.944 0.182 0.267 #v2 0.905 0.235 0.159 #v3 0.236 0.210 0.946 #v4 0.180 0.242 0.828 #v5 0.242 0.881 0.286 #v6 0.193 0.959 0.196 # Factor1 Factor2 Factor3 #SS loadings 1.893 1.886 1.797 #Proportion Var 0.316 0.314 0.300 #Cumulative Var 0.316 0.630 0.929 #The degrees of freedom for the model is 0 and the fit was 0.4755 /* SAS code with example data*/ data fact; input v1-v6; datalines; 1 1 3 3 1 1 1 2 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 2 1 1 3 4 1 1 1 1 3 3 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 1 1 1 4 4 5 5 6 6 5 6 4 6 4 5 6 5 6 4 5 4 ; run; proc factor data=fact rotate=varimax method=p nfactors=3; var v1-v6; run; /* Output from SAS*/ The FACTOR Procedure Initial Factor Method: Principal Components Prior Communality Estimates: ONE Eigenvalues of the Correlation Matrix: Total = 6 Average = 1 EigenvalueDifference ProportionCumulative 13.696030772.62291629 0.61600.6160 21.073114480.07234039 0.17890.7949 31.000774090.83977061 0.16680.9617 40.161003480.12004232 0.02680.9885 50.040961160.01284515 0.00680.9953 60.02811601 0.00471. 3 factors will be retained by the NFACTOR criterion. Factor Pattern Factor1 Factor2 Factor3 v1 0.79880 0.54995-0.17614 v2 0.77036 0.56171-0.24862 v3 0.79475 -0.07685 0.54982 v4 0.75757 -0.08736 0.59785 v5 0.80878 -0.45610-0.33437 v6 0.1 -0.48331-0.36933 Variance Explained by Each Factor Factor1 Factor2 Factor3 3.6960308 1.0731145 1.0007741 Final Communality Estimates: Total = 5.769919 v1 v2 v3 v4 v5 v6 0.97154741 0.97078498 0.93983835 0.93897798 0.97394719 0.97482345 The FACTOR Procedure Rotation Method: Varimax Orthogonal Transformation Matrix 1 2 3 1
Re: [R] Factor Analysis Output from R and SAS
Dear TY, Considering that you used different methods -- maximum-likelihood factor analysis in R and principal components analysis in SAS -- the results are quite similar (although the three rotated factors/components come out in different orders). I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tae-Young Heo Sent: March-31-09 7:07 AM To: r-help@r-project.org Subject: [R] Factor Analysis Output from R and SAS Dear Users, I ran factor analysis using R and SAS. However, I had different outputs from R and SAS. Why they provide different outputs? Especially, the factor loadings are different. I did real dataset(n=264), however, I had an extremely different from R and SAS. Why this things happened? Which software is correct on? Thanks in advance, - TY #R code with example data # A little demonstration, v2 is just v1 with noise, # and same for v4 vs. v3 and v6 vs. v5 # Last four cases are there to add noise # and introduce a positive manifold (g factor) v1 - c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 - c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 - c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 - c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 - c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 - c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 - cbind(v1,v2,v3,v4,v5,v6) cor(m1) # v1v2v3v4v5v6 #v1 1.000 0.9393083 0.5128866 0.4320310 0.4664948 0.4086076 #v2 0.9393083 1.000 0.4124441 0.4084281 0.4363925 0.4326113 #v3 0.5128866 0.4124441 1.000 0.8770750 0.5128866 0.4320310 #v4 0.4320310 0.4084281 0.8770750 1.000 0.4320310 0.4323259 #v5 0.4664948 0.4363925 0.5128866 0.4320310 1.000 0.9473451 #v6 0.4086076 0.4326113 0.4320310 0.4323259 0.9473451 1.000 factanal(m1, factors=3) # varimax is the default # Output from R #Call: #factanal(x = m1, factors = 3) #Uniquenesses: # v1v2v3v4v5v6 #0.005 0.101 0.005 0.224 0.084 0.005 #Loadings: # Factor1 Factor2 Factor3 #v1 0.944 0.182 0.267 #v2 0.905 0.235 0.159 #v3 0.236 0.210 0.946 #v4 0.180 0.242 0.828 #v5 0.242 0.881 0.286 #v6 0.193 0.959 0.196 # Factor1 Factor2 Factor3 #SS loadings 1.893 1.886 1.797 #Proportion Var 0.316 0.314 0.300 #Cumulative Var 0.316 0.630 0.929 #The degrees of freedom for the model is 0 and the fit was 0.4755 /* SAS code with example data*/ data fact; input v1-v6; datalines; 1 1 3 3 1 1 1 2 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 2 1 1 3 4 1 1 1 1 3 3 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 1 1 1 4 4 5 5 6 6 5 6 4 6 4 5 6 5 6 4 5 4 ; run; proc factor data=fact rotate=varimax method=p nfactors=3; var v1-v6; run; /* Output from SAS*/ The FACTOR Procedure Initial Factor Method: Principal Components Prior Communality Estimates: ONE Eigenvalues of the Correlation Matrix: Total = 6 Average = 1 EigenvalueDifference ProportionCumulative 13.696030772.62291629 0.61600.6160 21.073114480.07234039 0.17890.7949 31.000774090.83977061 0.16680.9617 40.161003480.12004232 0.02680.9885 50.040961160.01284515 0.00680.9953 60.02811601 0.00471. 3 factors will be retained by the NFACTOR criterion. Factor Pattern Factor1 Factor2 Factor3 v1 0.79880 0.54995-0.17614 v2 0.77036 0.56171-0.24862 v3 0.79475 -0.07685 0.54982 v4 0.75757 -0.08736 0.59785 v5 0.80878 -0.45610-0.33437 v6 0.1 -0.48331-0.36933 Variance Explained by Each Factor Factor1 Factor2 Factor3 3.6960308 1.0731145
Re: [R] which rows are duplicates?
Wacek Kusnierczyk wrote: Wacek Kusnierczyk wrote: Michael Dewey wrote: At 05:07 30/03/2009, Aaron M. Swoboda wrote: I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 i don't have any solution significantly better than what you have already been given. i now seem to have one: # dummy data data = data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace=TRUE)) # add a class column; identical rows have the same class id data$class = local({ rows = do.call('paste', c(data, sep='\r')) with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }) data # x y class # 1 2 2 3 # 2 2 1 2 # 3 2 1 2 # 4 1 2 1 # 5 2 2 3 another approach (maybe a bit cleaner) seems to be: data - data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace = TRUE)) vals - do.call('paste', c(data, sep = '\r')) data$class - match(vals, unique(vals)) data I have tried benchmarking it. Best, Dimitris this approach seems to be roughly comparable to michael's, depending on the shape (and size?) of the input: # dummy data frame, just integers n = 100; m = 100 data = as.data.frame( matrix(nrow=n, ncol=m, sample(n, m*n, replace=TRUE))) # do a simple benchmarking library(rbenchmark) benchmark(replications=100, order='elapsed', columns=c('test', 'elapsed'), waku=local({ rows = do.call('paste', c(data, sep='\r')) data$class = with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }), mide=local({ unique = unique(data) data = merge(data, cbind(unique, class=1:nrow(unique))) })) # test elapsed # 1 waku 0.503 # 2 mide 3.269 and for m = 10 and n = 1000 i get: # test elapsed # 1 waku 0.571 # 2 mide 15.836 while for m = 1000 and n = 10 i get: # test elapsed # 1 waku 1.110 # 2 mide 2.461 the type of the content should not have any impact on the ratio (pure guess, no testing done). whether my approach is more intuitive is arguable. note that, unlike in michael's solution, the final result (the data frame with a class column added) is in the original order. (and sorting would add a performance penalty in the other case.) my previous remarks about the treatment on NAs still apply; the do.call('paste', ... is taken from duplicated.data.frame. regards, vQ Does this do what you want? x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) data.u - unique(data) data.u x y z 1 1 2 3 2 3 4 4 data.u - cbind(data.u, set = 1:nrow(data.u)) merge(data, data.u) x y z set 1 1 2 3 1 2 1 2 3 1 3 3 4 4 2 You need to do a bit more work to get them back into the original row order if that is essential. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] which rows are duplicates?
Dimitris Rizopoulos wrote: Wacek Kusnierczyk wrote: Wacek Kusnierczyk wrote: Michael Dewey wrote: At 05:07 30/03/2009, Aaron M. Swoboda wrote: I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 i don't have any solution significantly better than what you have already been given. i now seem to have one: # dummy data data = data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace=TRUE)) # add a class column; identical rows have the same class id data$class = local({ rows = do.call('paste', c(data, sep='\r')) with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }) data # x y class # 1 2 2 3 # 2 2 1 2 # 3 2 1 2 # 4 1 2 1 # 5 2 2 3 another approach (maybe a bit cleaner) seems to be: data - data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace = TRUE)) vals - do.call('paste', c(data, sep = '\r')) data$class - match(vals, unique(vals)) data I have tried benchmarking it. sorry, I wanted to write: I have *not* tried benchmarking it. Best, Dimitris Best, Dimitris this approach seems to be roughly comparable to michael's, depending on the shape (and size?) of the input: # dummy data frame, just integers n = 100; m = 100 data = as.data.frame( matrix(nrow=n, ncol=m, sample(n, m*n, replace=TRUE))) # do a simple benchmarking library(rbenchmark) benchmark(replications=100, order='elapsed', columns=c('test', 'elapsed'), waku=local({ rows = do.call('paste', c(data, sep='\r')) data$class = with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }), mide=local({ unique = unique(data) data = merge(data, cbind(unique, class=1:nrow(unique))) })) # test elapsed # 1 waku 0.503 # 2 mide 3.269 and for m = 10 and n = 1000 i get: # test elapsed # 1 waku 0.571 # 2 mide 15.836 while for m = 1000 and n = 10 i get: # test elapsed # 1 waku 1.110 # 2 mide 2.461 the type of the content should not have any impact on the ratio (pure guess, no testing done). whether my approach is more intuitive is arguable. note that, unlike in michael's solution, the final result (the data frame with a class column added) is in the original order. (and sorting would add a performance penalty in the other case.) my previous remarks about the treatment on NAs still apply; the do.call('paste', ... is taken from duplicated.data.frame. regards, vQ Does this do what you want? x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) data.u - unique(data) data.u x y z 1 1 2 3 2 3 4 4 data.u - cbind(data.u, set = 1:nrow(data.u)) merge(data, data.u) x y z set 1 1 2 3 1 2 1 2 3 1 3 3 4 4 2 You need to do a bit more work to get them back into the original row order if that is essential. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Function rmultiregfp from package bayesm gone?
Hi, I have been using the function rmultiregfp from the bayesm package for a long time. In the current version of the package this function (and the corresponding init.rmultiregfp) is no longer available, does anyone know why? Can someone who has the old bayesm still on his computer please post the code of these two functions? Would be a great help as I have them both in a number of old functions that I have written. Thanks a lot, J -- View this message in context: http://www.nabble.com/Function-rmultiregfp-from-package-bayesm-gone--tp22804155p22804155.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scope of variables in R
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, A) you should give and return the variables through input/output parameter of the functions, e.g. pwtset - function(n, inout) { if (n 100){ inout$ncof - n } else { inout$ncof - n -100 } ... return(inout) } ford - function(inout) { ... n - 104 inout - pwtset(n, inout) print(inout$ncof) ... return (inout) } inout - list(ncof=0, ioff=0, joff=0, sig=0.0) inout - ford(inout) ... B) If you really need access to the global variables then use assign and get pwtset - function(n) { if (n 100){ ncof - n } else { ncof - n -100 } assign (ncof, ncof, envir=.GlobalEnv) ... return(inout) } ford - function(inout) { ... n - 104 inout - pwtset(n, inout) ncof - get(ncof, envir=.GlobalEnv) print(ncof) ... } ... ford() ... This programing style has a serious disadvantage: Debugging can become very difficult, since the value of ncof in .GlobalEnv might not be what you expect. Yours sincerely Sigbert -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJ0g4jWvYUYQkj1zkRAiopAJ49Vo+NriS+R7/24QGwtPB43wI/HQCdGvYE PjgZ+Vn0P30D5S3WvJrMX9s= =e9rL -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] which rows are duplicates?
Dimitris Rizopoulos wrote: another approach (maybe a bit cleaner) seems to be: data - data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace = TRUE)) vals - do.call('paste', c(data, sep = '\r')) data$class - match(vals, unique(vals)) data I have tried benchmarking it. sorry, I wanted to write: I have *not* tried benchmarking it. # dummy data frame, just integers n = 100; m = 100 data = as.data.frame( matrix(nrow=n, ncol=m, sample(n, m*n, replace=TRUE))) # do a simple benchmarking library(rbenchmark) benchmark( replications=100, order='elapsed', columns=c('test', 'elapsed'), waku=local({ rows = do.call('paste', c(data, sep='\r')) data$class = with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }), diri=local({ values = do.call('paste', c(data, sep='\r')) data$class = match(values, unique(values)) }) ) # test elapsed # 2 diri0.43 # 1 waku0.52 comparable for m=n=100 (and even better for n m), but way cleaner code, and the class ids are now better sorted. that's collaborative problem solving ;) best, vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to specify axis interval unit...
Dear R Users: Greetings! Is there any way to specify the axis interval unit for barplots in R.? Any help is deeply appreciated. Thanks in advance! Prasanth VP, Global Manager - Biometrics, Delta Technology Management Services Pvt Ltd, Plot No: 13/2, Sector - I, Third Floor, HUDA Techno Enclave, Madhapur, Hyderabad - 500 033. Office: +91-40-3028 0659 Mobile : +91-9848 290025 http://www.deltaintech.com/ www.deltaintech.com http://www.deltaintech.com/ ** http://www.deltaintech.com/ 'The information contained in this email is confidential and may contain proprietary information. It is meant solely for the intended recipient. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted in reliance on this, is prohibited and may be unlawful. No liability or responsibility is accepted if information or data is, for whatever reason corrupted or does not reach its intended recipient. No warranty is given that this email is free of viruses. The views expressed in this email are, unless otherwise stated, those of the author and not those of DELTA Technology and Management Services pvt ltd or its management. DELTA Technology and Management Services pvt ltd reserves the right to monitor intercept and block emails addressed to its users or take any other action in accordance with its email use policy' http://www.deltaintech.com/ Thank you in advance for your cooperation. http://www.deltaintech.com/ ** http://www.deltaintech.com/ P Please don't print this e-mail unless you really need to. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 3d cloud plot with point size reflecting variable value
Hello all, I'm using the cloud function to plot the iris data as per the document: http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/fichiers/_gallery.pdf I'd like to change the point size to reflect a fourth variable, as done here http://www.cis.hut.fi/projects/somtoolbox/download/pics2/shotvs2_origdata.png Does anybody know how to do this? There doesn't seem to be an option in cloud() Thanks, Richie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] naming vectors/ matrices in R
I would like to create a series of vectors in a loop and name them with letters. I know the command letters gives me the 26 letters of the alphabet. For example, I have a dataframe, called A, with 6 columns. B-length(A) C-letters(1:B) [1] a b c d e f I would like to extract the first letter a, and put the first column of dataframe A in a vector called a C-e[1] [1] a but when I type e[1]=A[,1] Warning message: In e[1] =A[, 1] : number of items to replace is not a multiple of replacement length It thinks I am trying to replace the first element of e with the first column of A. is there any other way in which I can achieve this? Thanks in advance -- View this message in context: http://www.nabble.com/naming-vectors--matrices-in-R-tp22802121p22802121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Doubt(load large amount of data) -reg
Dear Developers, I want to import the large size (566.639 kb) of data in R. I will try through txt, excel,xml,in this way I successes only small amount of data .but I want to load or import large amount of data in R .so please give me Suggestion Shanthi Rangasamy Ph. D. Student Electronics and Communications Department CEIT - IK4 Research Alliance Pº. Manuel Lardizábal, 15 20.018 Donostia-San Sebastián SPAIN Tel. +34 943 212 800 (Ext. 2804) Fax: +34 943 213 076 http://www.ceit.es/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] which rows are duplicates?
Dimitris Rizopoulos wrote: Wacek Kusnierczyk wrote: Wacek Kusnierczyk wrote: Michael Dewey wrote: At 05:07 30/03/2009, Aaron M. Swoboda wrote: I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. x - c(1,3,1) y - c(2,4,2) z - c(3,4,3) data - data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 i don't have any solution significantly better than what you have already been given. i now seem to have one: # dummy data data = data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace=TRUE)) # add a class column; identical rows have the same class id data$class = local({ rows = do.call('paste', c(data, sep='\r')) with( rle(sort(rows)), rep(1:length(values), lengths)[rank(rows)] ) }) data # x y class # 1 2 2 3 # 2 2 1 2 # 3 2 1 2 # 4 1 2 1 # 5 2 2 3 another approach (maybe a bit cleaner) seems to be: data - data.frame(x=sample(1:2, 5, replace=TRUE), y=sample(1:2, 5, replace = TRUE)) vals - do.call('paste', c(data, sep = '\r')) data$class - match(vals, unique(vals)) data wow, cool! this seems unbeatable ;) i guess it can't be slower than any of the others. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Mapping in R
It is relatively easy to do a small function for this in R: a) select the desired width for your border b) through a fix number or through the use of pretty(), establish the number of rectangles you want along your border. Then e.g., you can use rect() you build the sequence of black-white rectangles along your border. Hope this helps. Javier García-Pintado ... Kelsey Scheitlin kns07g at fsu.edu writes: Hi, I am looking for a specific mapping capability in R that I can't seem to find, but think exists. I would like to make a border of a map have alternating black and white squares instead of the common latitude and longitude grid. (example: http://www.cccturtle.org/sat_maps/map0bw8.gif). If anyone knows if there is or is not a function capable if doing this could you please let me know? Thanks! Kelsey It's not QUITE what you're looking for, but plot(0:1,0:1,bty=n,axes=FALSE) box(bty=o,lwd=6,lty=FF) (See ?box, ?par under bty and Line Type Specification) Otherwise you can do this by using par(usr) to find the edges of the map, seq() to construct appropriate x and y sequences, and segments() to draw the lines. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RMySQL compile
Try this: PKG_CPPFLAGS=-I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include-I/usr/lib/gtk-2.0/include -I/usr/local/include PKG_LIBS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib -lmysqlclient R CMD INSTALL RMySQL I had to refresh my memory from the inst/INSTALL file on how to do this. You might have to tweak it a bit, and also please send the full output of the command next time. Best, Jeff sten...@go.com wrote: I am trying to install RMySQL on OpenSolaris and need to pass some options to configure. Tried the 3 recommended ways of doing it and nothing works, configure cannot find the headers and the libs. I ran configure manually and that worked fine ./configureCC=ccCFLAGS=-dalign-KPIC-xlic_lib=sunperf LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib CPPFLAGS=-I/usr/local/lib/R/include-I/usr/mysql/5.0/include/mysql -I/opt/csw/include-I/usr/sfw/include-I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --with-mysql-inc=/usr/mysql/include/mysql --with-mysql-lib=/usr/mysql/lib/mysql checking mysql.h usability... yes checking mysql.h presence... yes checking for mysql.h... yes configure: creating ./config.status config.status: creating src/Makevars but then there is no makefile. Pls advise how to run make manually or help with the syntax: I tried with quotes after the second = and the first = and neither worked R CMD INSTALL --configure-args=CC=cc --configure-args=CFLAGS=-dalign -KPIC -xlic_lib=sunperf --configure-args=LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib --configure-args=CPPFLAGS=-I/usr/local/lib/R/include -I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --configure-args=--with-mysql-inc=/usr/mysql/include/mysql --configure-args=--with-mysql-lib=/usr/mysql/lib/mysql RMySQL_0.7-3.tar.gz ## does not work Stephen C. Bond __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] digits in round()
Hi Folks, Compare print(1234567890,digits=4) # [1] 1.235e+09 print(1234567890,digits=5) # [1] 1234567890 Granted that digits: a non-null value for 'digits' specifies the minimum number of significant digits to be printed in values. how does R decide to switch from the 1.235e+09 (rounded to 4 digits, i.e. the minumum, in e notation) to 1234567890 (the complete raw notation, 10 digits) when 'digits' goes from 4 to 5? Thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 31-Mar-09 Time: 13:59:37 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two monitors
Hello, I work with Windows XP and do what you are hoping to do. Instead of using the built in script dialogue editor I use TINN-R. I can drag either this editor or the R Console to different monitors. I often have to make sure that the TINN-R editor panel is not maximized as that will hide any graphics windows that I generate. Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 Daniel Viar dan.v...@gmail.c omTo Sent by: Veerappa Chetty r-help-boun...@r- chett...@gmail.com project.orgcc r-help@r-project.org Subject 03/30/2009 06:18 Re: [R] two monitors PM EST Try Edit -- Gui Preferences -- SDI and see if that works. Dan Viar Chesapeake, VA On Mon, Mar 30, 2009 at 5:55 PM, Veerappa Chetty chett...@gmail.com wrote: Hi, I have set up two monitors. I am using windows XP. I would like to keep one window- command line in one monitor and the script and graphs in the second monitor. How do I set it up? It works for word documents simply by dragging the document. It does not work if I drag and drop the scripts window. Is R not compatible for this? Thanks. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Language Bloggers and Web Sites Owners
Ajay ohri ohri2007 at gmail.com writes: Apologies in advance for non bloggers for the spam on the slightly off topic. This is an invitation to all R language bloggers to help spread the world at a forum where leading authors come together. Since the author has a notorious history of self-advertising, I cannot avoid the feeling that he is mainly promoting himself. http://markmail.org/message/idereianfwx2x222 Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Factor Analysis Output from R and SAS
As it was already pointed out by others, you used different methods (principal components in SAS vs. factor analysis in R). When you use the same method (+ varimax rotation) in both programs, there may still be a *small* difference: this comes from (possibly) different stopping criteria. In R, the default stopping criterion in varimax is eps = 1e-5; I've once set it to 1e-12 to make the results *almost* identical with the output of another program (Statistica). Kenn On Tue, Mar 31, 2009 at 3:17 PM, John Fox j...@mcmaster.ca wrote: Dear TY, Considering that you used different methods -- maximum-likelihood factor analysis in R and principal components analysis in SAS -- the results are quite similar (although the three rotated factors/components come out in different orders). I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tae-Young Heo Sent: March-31-09 7:07 AM To: r-help@r-project.org Subject: [R] Factor Analysis Output from R and SAS Dear Users, I ran factor analysis using R and SAS. However, I had different outputs from R and SAS. Why they provide different outputs? Especially, the factor loadings are different. I did real dataset(n=264), however, I had an extremely different from R and SAS. Why this things happened? Which software is correct on? Thanks in advance, - TY #R code with example data # A little demonstration, v2 is just v1 with noise, # and same for v4 vs. v3 and v6 vs. v5 # Last four cases are there to add noise # and introduce a positive manifold (g factor) v1 - c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 - c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 - c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 - c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 - c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 - c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 - cbind(v1,v2,v3,v4,v5,v6) cor(m1) # v1v2v3v4v5v6 #v1 1.000 0.9393083 0.5128866 0.4320310 0.4664948 0.4086076 #v2 0.9393083 1.000 0.4124441 0.4084281 0.4363925 0.4326113 #v3 0.5128866 0.4124441 1.000 0.8770750 0.5128866 0.4320310 #v4 0.4320310 0.4084281 0.8770750 1.000 0.4320310 0.4323259 #v5 0.4664948 0.4363925 0.5128866 0.4320310 1.000 0.9473451 #v6 0.4086076 0.4326113 0.4320310 0.4323259 0.9473451 1.000 factanal(m1, factors=3) # varimax is the default # Output from R #Call: #factanal(x = m1, factors = 3) #Uniquenesses: # v1v2v3v4v5v6 #0.005 0.101 0.005 0.224 0.084 0.005 #Loadings: # Factor1 Factor2 Factor3 #v1 0.944 0.182 0.267 #v2 0.905 0.235 0.159 #v3 0.236 0.210 0.946 #v4 0.180 0.242 0.828 #v5 0.242 0.881 0.286 #v6 0.193 0.959 0.196 # Factor1 Factor2 Factor3 #SS loadings 1.893 1.886 1.797 #Proportion Var 0.316 0.314 0.300 #Cumulative Var 0.316 0.630 0.929 #The degrees of freedom for the model is 0 and the fit was 0.4755 /* SAS code with example data*/ data fact; input v1-v6; datalines; 1 1 3 3 1 1 1 2 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 2 1 1 3 4 1 1 1 1 3 3 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 1 1 1 4 4 5 5 6 6 5 6 4 6 4 5 6 5 6 4 5 4 ; run; proc factor data=fact rotate=varimax method=p nfactors=3; var v1-v6; run; /* Output from SAS*/ The FACTOR Procedure Initial Factor Method: Principal Components Prior Communality Estimates: ONE Eigenvalues of the Correlation Matrix: Total = 6 Average = 1 EigenvalueDifference ProportionCumulative 13.696030772.62291629 0.61600.6160 21.073114480.07234039 0.17890.7949 31.000774090.83977061 0.16680.9617 40.161003480.12004232 0.02680.9885 50.040961160.01284515 0.00680.9953 60.02811601 0.00471. 3 factors will be retained by the NFACTOR criterion. Factor Pattern Factor1 Factor2 Factor3 v1 0.79880 0.54995
Re: [R] Jarque-Bera test and Ljung-Box test for multivariate time series
John, Tsay has code for multivariate Ljung-Box test statistic on http://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2009/ -Hannu On Tue, Mar 31, 2009 at 1:47 PM, John Seppänen john.seppane...@gmail.comwrote: Hi! I know that there is function in fBasics package for univariate Jarque-Bera test and a funtion for univariate Ljung-Box test in stats package. But I am wondering if there is a function somewhere to do the tests for multivariate time series? Thanks, John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] digits in round()
On 3/31/2009 8:59 AM, (Ted Harding) wrote: Hi Folks, Compare print(1234567890,digits=4) # [1] 1.235e+09 print(1234567890,digits=5) # [1] 1234567890 If printing in scientific notation takes up as much space or more than printing in regular notation, then regular notation will be used. In this case the 5 digit scientific notation output of 1.2346e+09 takes 10 characters, so the 10 character simple format is used instead. The reason for this rule is that regular notation gives more information about the number. If you had wanted to use 10 chars but be less expressive you would have used an explicit format. Duncan Murdoch Granted that digits: a non-null value for 'digits' specifies the minimum number of significant digits to be printed in values. how does R decide to switch from the 1.235e+09 (rounded to 4 digits, i.e. the minumum, in e notation) to 1234567890 (the complete raw notation, 10 digits) when 'digits' goes from 4 to 5? Thanks, Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 31-Mar-09 Time: 13:59:37 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] digits in round()
TH == Ted Harding ted.hard...@manchester.ac.uk on Tue, 31 Mar 2009 13:59:41 +0100 (BST) writes: TH Hi Folks, TH Compare TH print(1234567890,digits=4) TH # [1] 1.235e+09 TH print(1234567890,digits=5) TH # [1] 1234567890 TH Granted that TH digits: a non-null value for 'digits' specifies the minimum TH number of significant digits to be printed in values. TH how does R decide to switch from the 1.235e+09 (rounded to TH 4 digits, i.e. the minumum, in e notation) to 1234567890 (the TH complete raw notation, 10 digits) when 'digits' goes from 4 to 5? that's easy (well, as I'm one of the co-implementors ...) : One of the design ideas has been to use e-notation only when it's shorter (under the constraints given by 'digits'), i.e., 1.2346e+09 is not shorter (but has less information) than 1234567890 hence the latter is chosen. There are quite a few cases, and constraints (*) that apply simultaneously, such that sometimes the default numeric formatting may seem peculiar, but I hope that in the mean time we have squished all real bugs here. *) such as platform (in)dependency; S - back-compatibility, .. Best regards, Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RMySQL compile
Jeff, Thank you so much for responding. I am ready to do a lot of tweaking. From your message it looks like you are asking me to provide assignments on the same line as R CMD but precede the command. I am using bash and the usual thing would be to export those variables and then run R CMD. I tried that and configure ignores the variables. If you know where is the actual makefile then I could try to finish this without using R CMD. calling ./configure directly works ( R CMD INSTALL is the problem and I do not know how to look into that) Stephen C. Bond On Mar 31, 2009, jeff.hor...@vanderbilt.edu wrote: Try this: PKG_CPPFLAGS=-I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include-I/usr/lib/gtk-2.0/include -I/usr/local/include PKG_LIBS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib -lmysqlclient R CMD INSTALL RMySQL I had to refresh my memory from the inst/INSTALL file on how to do this. You might have to tweak it a bit, and also please send the full output of the command next time. Best, Jeff sten...@go.com wrote: I am trying to install RMySQL on OpenSolaris and need to pass some options to configure. Tried the 3 recommended ways of doing it and nothing works, configure cannot find the headers and the libs. I ran configure manually and that worked fine ./configure CC=cc CFLAGS=-dalign -KPIC -xlic_lib=sunperf LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib CPPFLAGS=-I/usr/local/lib/R/include -I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --with-mysql-inc=/usr/mysql/include/mysql --with-mysql-lib=/usr/mysql/lib/mysql checking mysql.h usability... yes checking mysql.h presence... yes checking for mysql.h... yes configure: creating ./config.status config.status: creating src/Makevars but then there is no makefile. Pls advise how to run make manually or help with the syntax: I tried with quotes after the second = and the first = and neither worked RCMDINSTALL--configure-args=CC=cc --configure-args=CFLAGS=-dalign -KPIC -xlic_lib=sunperf --configure-args=LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib --configure-args=CPPFLAGS=-I/usr/local/lib/R/include -I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --configure-args=--with-mysql-inc=/usr/mysql/include/mysql --configure-args=--with-mysql-lib=/usr/mysql/lib/mysql RMySQL_0.7-3.tar.gz ## does not work Stephen C. Bond __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Language Bloggers and Web Sites Owners
Hm, this feels reminiscent of the Wellsphere free blog content scam: http://neurocritic.blogspot.com/2009/02/wealthcentral.html -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tinyurl.com/mikes-public-calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] labeling panels in lattice plots
I am using windows XP with R 2.8.1 I am generating a lattice plot of annual rain patterns using the following function: xyplot(rain.stats$min+ rain.stats$max + rain.stats$ave ~ rain.stats$month |rain.stats$year, lty = 1, data = rain.stats, type = c(l,l, l), col = c(red, blue, green), distribute.type = TRUE, main = Annual Monthly Minimum, Average and Maximum PPT) Each panel is labels with rain.stats$year instead of the actual value referenced by this variable. the data.frame I'm using has the following form (year values range from 1965 to 2000 and month from 1 to 12). dim(rain.stats) 432 6 rain.stats[1:10,] year month X2minmax ave 1 1965 1 1 0. 1.9196 0.3650112 2 1966 1 1 2.1483 4.9615 3.5247034 3 1967 1 1 0.4038 3.9145 1.7133045 4 1968 1 1 0.2033 3.2119 1.1844769 5 1969 1 1 1.2533 5.6226 2.9505545 6 1970 1 1 0.9142 3.8861 2.6248453 7 1971 1 1 0.1191 1.6109 0.6570289 8 1972 1 1 0.2309 2.9380 0.9259674 9 1973 1 1 0.9471 3.6342 1.9019848 10 1974 1 1 0.1739 9.0225 1.0672980 The plot illustrates exactly what I'm after with the exception of the panel labels. I'm following an example in the Lattice Book by Deepayan Sarkar (which I find very informative - thanks), but I'm not getting the results as per the example. Can anyone offer a solution? Thanks in advance. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help about: anova and population no normal
Dear R-Helpers, Parametric statistics are statistics where the population is assumed to fit any parametrized distributions (most typically the normal distribution). My problem is: 1) if my polulation is no normal 2) if the sample data of all replications and treatments were well fitted from the Weibull distribution (shape and scale parameters). Can be The shape and scale parameters compared between treatments by using the canonical analysis of the variance ANOVA? Many thanks for your help with these questions. Maurizio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Upgrade through the R interface?
Why can we not update R through a update.version() command from within R? This may be my ignorance about how software distribution works, but I was interested. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling panels in lattice plots
would you mind creating a dummy data.frame or maybe dput() a smaller subset of the data frame? thanks Stephen Sefick On Tue, Mar 31, 2009 at 9:28 AM, steve_fried...@nps.gov wrote: I am using windows XP with R 2.8.1 I am generating a lattice plot of annual rain patterns using the following function: xyplot(rain.stats$min+ rain.stats$max + rain.stats$ave ~ rain.stats$month |rain.stats$year, lty = 1, data = rain.stats, type = c(l,l, l), col = c(red, blue, green), distribute.type = TRUE, main = Annual Monthly Minimum, Average and Maximum PPT) Each panel is labels with rain.stats$year instead of the actual value referenced by this variable. the data.frame I'm using has the following form (year values range from 1965 to 2000 and month from 1 to 12). dim(rain.stats) 432 6 rain.stats[1:10,] year month X2 min max ave 1 1965 1 1 0. 1.9196 0.3650112 2 1966 1 1 2.1483 4.9615 3.5247034 3 1967 1 1 0.4038 3.9145 1.7133045 4 1968 1 1 0.2033 3.2119 1.1844769 5 1969 1 1 1.2533 5.6226 2.9505545 6 1970 1 1 0.9142 3.8861 2.6248453 7 1971 1 1 0.1191 1.6109 0.6570289 8 1972 1 1 0.2309 2.9380 0.9259674 9 1973 1 1 0.9471 3.6342 1.9019848 10 1974 1 1 0.1739 9.0225 1.0672980 The plot illustrates exactly what I'm after with the exception of the panel labels. I'm following an example in the Lattice Book by Deepayan Sarkar (which I find very informative - thanks), but I'm not getting the results as per the example. Can anyone offer a solution? Thanks in advance. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling panels in lattice plots
Try converting year to a factor xyplot(min + max + ave ~ month | factor(year), data = rain.stats, ...) Also, notice the inclusion of the data argument. HTH, --sundar On Tue, Mar 31, 2009 at 6:28 AM, steve_fried...@nps.gov wrote: I am using windows XP with R 2.8.1 I am generating a lattice plot of annual rain patterns using the following function: xyplot(rain.stats$min+ rain.stats$max + rain.stats$ave ~ rain.stats$month |rain.stats$year, lty = 1, data = rain.stats, type = c(l,l, l), col = c(red, blue, green), distribute.type = TRUE, main = Annual Monthly Minimum, Average and Maximum PPT) Each panel is labels with rain.stats$year instead of the actual value referenced by this variable. the data.frame I'm using has the following form (year values range from 1965 to 2000 and month from 1 to 12). dim(rain.stats) 432 6 rain.stats[1:10,] year month X2 min max ave 1 1965 1 1 0. 1.9196 0.3650112 2 1966 1 1 2.1483 4.9615 3.5247034 3 1967 1 1 0.4038 3.9145 1.7133045 4 1968 1 1 0.2033 3.2119 1.1844769 5 1969 1 1 1.2533 5.6226 2.9505545 6 1970 1 1 0.9142 3.8861 2.6248453 7 1971 1 1 0.1191 1.6109 0.6570289 8 1972 1 1 0.2309 2.9380 0.9259674 9 1973 1 1 0.9471 3.6342 1.9019848 10 1974 1 1 0.1739 9.0225 1.0672980 The plot illustrates exactly what I'm after with the exception of the panel labels. I'm following an example in the Lattice Book by Deepayan Sarkar (which I find very informative - thanks), but I'm not getting the results as per the example. Can anyone offer a solution? Thanks in advance. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Upgrade through the R interface?
On 3/31/2009 9:37 AM, stephen sefick wrote: Why can we not update R through a update.version() command from within R? This may be my ignorance about how software distribution works, but I was interested. Because nobody has contributed such a function. There are a few tricky issues in writing it: generally packages need updating as well if the X or Y in version X.Y.Z changes, and new updates for some may not be available. As well, on some platforms, files can't be replaced while in use; e.g. on Windows, you'd probably need to shut down R before it could be replaced. So I think it could be done on Windows and probably on other platforms too, but it would take a fair bit of work to implement. You just need to find someone who has spare time on their hands to do it (or do it yourself, or hire someone, ) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] labeling panels in lattice plots
Sundar, Your suggestion to convert year to a factor worked like a charm. Thank you very much. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 Sundar Dorai-Raj sdorai...@gmail. com To steve_fried...@nps.gov 03/31/2009 06:50 cc AM MSTr-help@r-project.org Subject Re: [R] labeling panels in lattice plots Try converting year to a factor xyplot(min + max + ave ~ month | factor(year), data = rain.stats, ...) Also, notice the inclusion of the data argument. HTH, --sundar On Tue, Mar 31, 2009 at 6:28 AM, steve_fried...@nps.gov wrote: I am using windows XP with R 2.8.1 I am generating a lattice plot of annual rain patterns using the following function: xyplot(rain.stats$min+ rain.stats$max + rain.stats$ave ~ rain.stats$month |rain.stats$year, lty = 1, data = rain.stats, type = c(l,l, l), col = c(red, blue, green), distribute.type = TRUE, main = Annual Monthly Minimum, Average and Maximum PPT) Each panel is labels with rain.stats$year instead of the actual value referenced by this variable. the data.frame I'm using has the following form (year values range from 1965 to 2000 and month from 1 to 12). dim(rain.stats) 432 6 rain.stats[1:10,] year month X2 min max ave 1 1965 1 1 0. 1.9196 0.3650112 2 1966 1 1 2.1483 4.9615 3.5247034 3 1967 1 1 0.4038 3.9145 1.7133045 4 1968 1 1 0.2033 3.2119 1.1844769 5 1969 1 1 1.2533 5.6226 2.9505545 6 1970 1 1 0.9142 3.8861 2.6248453 7 1971 1 1 0.1191 1.6109 0.6570289 8 1972 1 1 0.2309 2.9380 0.9259674 9 1973 1 1 0.9471 3.6342 1.9019848 10 1974 1 1 0.1739 9.0225 1.0672980 The plot illustrates exactly what I'm after with the exception of the panel labels. I'm following an example in the Lattice Book by Deepayan Sarkar (which I find very informative - thanks), but I'm not getting the results as per the example. Can anyone offer a solution? Thanks in advance. Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] target of assignment expands to non-language object
I'm running the following code numbers - 1:50 for (i in 1:50) assign(paste(model,numbers[i]),i)-(lm(temp$Overall.Scaled.Score~temp$raw.score)) where I want R to create 50 different models-1:50, but get the following error message target of assignment expands to non-language object. I've tried it with paste(model,numbers[i]))-(lm(temp$Overall.Scaled.Score~temp$raw.score) and get the same error. Does anyone know what the problem is or whether there's a better way to get at what I'm trying to do? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Upgrade through the R interface?
I was just curious. For a couple of times a year building from the sources doesn't make this a super high priority for me to write such a function (assuming I have the skills to do this anyway) as the core team makes it quite easy to just download whatever I need. Thanks for all of the help, Stephen Sefick On Tue, Mar 31, 2009 at 9:58 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 3/31/2009 9:37 AM, stephen sefick wrote: Why can we not update R through a update.version() command from within R? This may be my ignorance about how software distribution works, but I was interested. Because nobody has contributed such a function. There are a few tricky issues in writing it: generally packages need updating as well if the X or Y in version X.Y.Z changes, and new updates for some may not be available. As well, on some platforms, files can't be replaced while in use; e.g. on Windows, you'd probably need to shut down R before it could be replaced. So I think it could be done on Windows and probably on other platforms too, but it would take a fair bit of work to implement. You just need to find someone who has spare time on their hands to do it (or do it yourself, or hire someone, ) Duncan Murdoch -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate natural cubic spline in R?
Hello: If B-splines will suffice, there are many capabilities in R for that. My favorite is the 'fda' package, but 'splines' and other packages are also good. The splinefun function in the base package returns a function to compute spline interpolations optionally using a natural spline. However, that is an interpolation spline and therefore does no smoothing. To find other options for natural splines, I suggest you try the CRAN packages splines, mboost, pspline, Design, and mgcv. I found them using the RSiteSearch packages available from R-Forge via 'install.packages(RSiteSearch, repos=http://r-forge.r-project.org;)', which also identified the siggenes package (which is not on CRAN). I don't know if any of these actually use natural splines, but this gives you a reasonably short list to consider. Hope this helps. Spencer Graves p.s. The following are the commands I used with the RSiteSearch package: library(RSiteSearch) natSpl - RSiteSearch.function('natural spline') str(natSpl) summary(natSpl) natSpl[1:23, c(1, 4, 5, 7)] minben wrote: Suppose I have two var x and y,now I want to fits a natural cubic spline in x to y,at the same time create new var containing the smoothed values of y. How can I get it? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Upgrade through the R interface?
Hi. Em Terça 31 Março 2009, stephen sefick escreveu: I was just curious. I use a bash script [http://asaguiar.med.br/modules.php?name=Downloadsd_op=getitlid=41] that checks for availability of upgrades and, if it is the case, downloads, compiles and install the newest R version. It could be run from within R. The exit values of interest are 100 (uptodate) and 0 (successful install). All other values are errors codes that correspond to the steps the script performs: system checks (1), download (2), decompression (3), configure (4), compilation (5), install (6). The dowloadable version (url above) needs some minor configuration changes in variables. Best wishes. Alexandre -- Alexandre Santos Aguiar, MD, SCT -- website: http://spsconsultoria.com/ Phone: +55-11-3717-4866 (SP) Phone: +55-21-3717-4866 (RJ) Voicemail: +55-11-2157-6891 (SP) Fax: +55-11-2501-1972 (SP) - New fax number! Please, update records. -- signature.asc Description: This is a digitally signed message part. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CV and GCV for finding smoothness parameter
I received an assignment that I have to do in R, but I'm absolutely not very good at it. The task is the following: http://www.nabble.com/file/p22804957/question8.jpg To do this, we also get the following pieces of code (not in correct order): http://www.nabble.com/file/p22804957/hints.jpg I'm terrible at this and I'm completely stuck. The model I chose can be found in here: myknots6 = c(20,24,34) p.spline8 = spm(accel ~ f(times,basis=trunc.poly,degree=2,knots=myknots6)) Can someone please help me with this task? I'm kind of desperate. Thank you! -- View this message in context: http://www.nabble.com/CV-and-GCV-for-finding-smoothness-parameter-tp22804957p22804957.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with mathematical expression and loop
Hi to all I use a loop to plot 9 different histograms of 9 different transformations of one dataset (x). I want to label the histograms with the mathematical expression of each transformation (e.g. x^3). For that I've prepared a vector with the labeling names for expression. trans.expr - c(x^3, x^2, x, frac(1,x), frac(1,x^2), frac(1,x^3), sqrt(x), log(x), frac(1,sqrt(x))) for(i in 1:9){ hist(x[i], main=expression(trans.expr[i])) } But if I want to pass the names to expression, it always prints trans.expr[i] instead of the mathematical expressions. I also tried to use noquote to remove the quotes but it didn't work. Does anyone knows a solution to that problem? Any help is appreciated. Denis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] HELP WITH SEM LIBRARY AND WITH THE MODEL'S SPECIFICATION
Dear John I want to thank you so much for the help. I've solved my problem following your instructions. The matrix S of the cov was singular because i had few complete observation. I have included 2 wrongs item, because (in the majority of cases) when one is inputed, the other one is NA, so i have only fews complete observations... Thank you so much again, for this help and for the great job about SEM( ) that you have wrote and shared on the web. My best regards, Costantino Milanese, always the young researcher but with less problems! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] portable R editor
Several messages last week debated about a portable R with Tinn-R. I made such an app just a few weeks ago. It's called R-TinnR-portables and is available here: http://otan.ecoledelapaix.org/spip.php?article102 Simply unzip the file downloadable under the name R-2.8.1TinnR-portables. You'll have R with a bunch of packages and Tinn-R. It runs from a USB drive and network drive (if the network drive is shared, you should disable tooltip in Tinn-T). What is original about this is that I wrote a full bash script (runs on GNU/Linux with wine) to create the zip archive for MS Windows. The advantage are: - you can customise your script. If you want to change something to your portable R, juste change the appropriate line, run your script and wait a little while. - you can build it on GNU/Linux (I tested the result on Windows 2000, XP and Vista).. Here are some small extracts of the script: # set up your mirror: mirroir=http://cran.cict.fr; # just change this when a new stable R version comes out: dernierR=R-2.8.1 # you may add or remove basic R/Rgui components here: wine $dernierR-win32.exe /DIR=''$pathWIN'' /$interface /COMPONENTS=main, html, html/help, manuals, manuals/basic, manuals/technical, manuals/refman, tcl, Rd, trans # you may add the packages you want here (instead of ...): install.packages(pkgs=c(abind, aplpack, Cairo, ...), repos='$mirroir', dependencies=c(Depends, Imports), destdir=c:/RTinnRPortables'$aujourdhui'/temp, clean=F) Some comments in the script are in French, just ask me if you are interested, I'll translate them. Regards, Mayeul -- Dr. Mayeul KAUFFMANN Head of Research department Programme manager, UNESCO Network Governance and peace Ecole de la paix (School of Peace) 7 rue Tres-Cloitres 38000 GRENOBLE FRANCE Phone: + 33 4 76 63 81 41 Fax : + 33 4 76 63 81 42 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RMySQL compile
sten...@go.com wrote on 03/31/2009 08:11 AM: Jeff, Thank you so much for responding. I am ready to do a lot of tweaking. From your message it looks like you are asking me to provide assignments on the same line as R CMD but precede the command. I am using bash and the usual thing would be to export those variables and then run R CMD. I tried that and configure ignores the variables. If you know where is the actual makefile then I could try to finish this without using R CMD. calling ./configure directly works ( R CMD INSTALL is the problem and I do not know how to look into that) bash is perfectly capable of running commands preceded with shell variables. Show the output, please. Otherwise I'm of no help. Best, Jeff Stephen C. Bond On Mar 31, 2009, *jeff.hor...@vanderbilt.edu* wrote: Try this: PKG_CPPFLAGS=-I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include-I/usr/lib/gtk-2.0/include -I/usr/local/include PKG_LIBS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib -lmysqlclient R CMD INSTALL RMySQL I had to refresh my memory from the inst/INSTALL file on how to do this. You might have to tweak it a bit, and also please send the full output of the command next time. Best, Jeff sten...@go.com wrote: I am trying to install RMySQL on OpenSolaris and need to pass some options to configure. Tried the 3 recommended ways of doing it and nothing works, configure cannot find the headers and the libs. I ran configure manually and that worked fine ./configureCC=ccCFLAGS=-dalign-KPIC -xlic_lib=sunperf LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib CPPFLAGS=-I/usr/local/lib/R/include -I/usr/mysql/5.0/include/mysql -I/opt/csw/include-I/usr/sfw/include -I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --with-mysql-inc=/usr/mysql/include/mysql --with-mysql-lib=/usr/mysql/lib/mysql checking mysql.h usability... yes checking mysql.h presence... yes checking for mysql.h... yes configure: creating ./config.status config.status: creating src/Makevars but then there is no makefile. Pls advise how to run make manually or help with the syntax: I tried with quotes after the second = and the first = and neither worked R CMD INSTALL --configure-args=CC=cc --configure-args=CFLAGS=-dalign -KPIC -xlic_lib=sunperf --configure-args=LDFLAGS=-L/usr/sfw/lib -L/usr/lib -L/usr/local/lib -L/opt/csw/lib --configure-args=CPPFLAGS=-I/usr/local/lib/R/include -I/usr/mysql/5.0/include/mysql -I/opt/csw/include -I/usr/sfw/include -I/usr/X11/include -I/usr/lib/gtk-2.0/include -I/usr/local/include --configure-args=--with-mysql-inc=/usr/mysql/include/mysql --configure-args=--with-mysql-lib=/usr/mysql/lib/mysql RMySQL_0.7-3.tar.gz ## does not work Stephen C. Bond __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://biostat.mc.vanderbilt.edu/JeffreyHorner -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Connecting C# to R via rscproxy.dll does not return all results
Hi there, I am using http://www.nabble.com/Using-R.dll-in-.NET-IPC-td13265477.html this solution to hook a C# Application to R via rscproxy.dll. So far it all works fine, except for the fact that whenever a line in the result vector contains more than 1 return parameter (e.g. ttest´s confidence interval from x to y) only the first value is returned (e.g x instead of x, y) How can I make it return all values? Thanks, Stan -- View this message in context: http://www.nabble.com/Connecting-C--to-R-via-rscproxy.dll-does-not-return-all-results-tp22804983p22804983.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help about: anova and population no normal
Those with more formal statistical backgrounds may provide better advice, but in my own informal training I've come to wonder why parametric stats persist in the face of modern computing power. As I understand it, Fisher developed ANOVA as low-computation method of approximating the Randomization Test (a.k.a. exhaustive permutation test). Where computation power has grown exponentially since Fisher's time, these days it is feasible to compute the full R-Test in many cases, and for those cases where the full R-Test is not feasible, non-exhaustive permutation variants usually satisfy. Indeed, it has been shown (http://brm.psychonomic-journals.org/content/37/3/426.short) that the R-Test is more powerful than the F-Test in the face of skewed distributions. My advice would thus be to abandon parametrics and simply code a randomization test variant of the ANOVA you want. Mike On Tue, Mar 31, 2009 at 10:29 AM, Sarti Maurizio sart...@irea.cnr.it wrote: Dear R-Helpers, Parametric statistics are statistics where the population is assumed to fit any parametrized distributions (most typically the normal distribution). My problem is: 1) if my polulation is no normal 2) if the sample data of all replications and treatments were well fitted from the Weibull distribution (shape and scale parameters). Can be The shape and scale parameters compared between treatments by using the canonical analysis of the variance ANOVA? Many thanks for your help with these questions. Maurizio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tinyurl.com/mikes-public-calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with mathematical expression and loop
On 3/31/2009 9:15 AM, Denis Aydin wrote: Hi to all I use a loop to plot 9 different histograms of 9 different transformations of one dataset (x). I want to label the histograms with the mathematical expression of each transformation (e.g. x^3). For that I've prepared a vector with the labeling names for expression. trans.expr - c(x^3, x^2, x, frac(1,x), frac(1,x^2), frac(1,x^3), sqrt(x), log(x), frac(1,sqrt(x))) for(i in 1:9){ hist(x[i], main=expression(trans.expr[i])) } But if I want to pass the names to expression, it always prints trans.expr[i] instead of the mathematical expressions. Don't use a character vector, use expressions from the beginning: trans.expr - expression(x^3, x^2, x, frac(1,x), frac(1,x^2), frac(1,x^3), sqrt(x), log(x), frac(1,sqrt(x))) for (i in 1:9) hist(x[i], main=trans.expr[i]) If you really need to use strings, then you need parse() to convert them to expressions. Duncan Murdoch I also tried to use noquote to remove the quotes but it didn't work. Does anyone knows a solution to that problem? Any help is appreciated. Denis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] naming vectors/ matrices in R
emj83 stp08emj at shef.ac.uk writes: I would like to create a series of vectors in a loop and name them with letters. I know the command letters gives me the 26 letters of the alphabet. For example, I have a dataframe, called A, with 6 columns. B-length(A) C-letters(1:B) [1] a b c d e f I would like to extract the first letter a, and put the first column of dataframe A in a vector called a C-e[1] [1] a but when I type e[1]=A[,1] Warning message: In e[1] =A[, 1] : number of items to replace is not a multiple of replacement length This is really difficult to understand. Try to make the example so that is can be pasted in R. For example, where is your dataframe A? A = data.frame(a=1:10,b=1:10) e = A[,1] e Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scope of variables in R
On Tue, Mar 31, 2009 at 7:10 AM, mau...@alice.it wrote: I need to allocate (using C nomenclature) a set of global variables, some integer scalars and some double vectors. ... My question is: how can I have R interpreter allocate globalvariables visible and accessible by all the functions in the same file ? You don't need to explicitly allocate variables in R. Assigning to them will create them. If you want to modify a global variable within a function, you need to use the - assignment operator instead of the - assignment operator. In effect, the - assignment operator *always* refers to a local variable, and creates one if one does not exist yet. I do not know how to limit the visibility of a variable to functions in the same file. On the other hand, you can limit the visibility of a variable to a group of functions quite straightforwardly: local({ global1 - 3 # allocated within the local scope with - global2 - 4 fun1 - function(...) ... global1 ... # lexical scoping; refers to global1 # must assign fun1 with - so it is created in the global scope }) But I suspect you don't need this level of complexity. All that being said, programming with global variables makes certain classes of bug much more likely -s [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] target of assignment expands to non-language object
On Tue, Mar 31, 2009 at 10:05 AM, Alina Sheyman alina...@gmail.com wrote: I'm running the following code numbers - 1:50 for (i in 1:50) assign(paste(model,numbers[i]),i)-(lm(temp$Overall.Scaled.Score~temp$raw.score)) a) What is the purpose of numbers? Why not write paste(model,i) b) Why assign( ... ) - ... ? Don't you just want assign(paste(model,i),lm(temp$Overall.Scaledxxx)) c) Why are you assigning to variables named `model 1` etc. instead of making a list of all the models? e.g. models - sapply( 1:50, function(i) ... ) -s where I want R to create 50 different models-1:50, but get the following error message target of assignment expands to non-language object. I've tried it with paste(model,numbers[i]))-(lm(temp$Overall.Scaled.Score~temp$raw.score) and get the same error. Does anyone know what the problem is or whether there's a better way to get at what I'm trying to do? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nonparametric analysis of repeated measurements dat a with sm library
Alphonse Monkamg amonkamg at yahoo.fr writes: Does anybody know how to get more evaluation points in performing Nonparametric analysis of repeated measurements data with sm library. Try ... paramter ngrid: ngrid the number of divisions of the above interval to be considered. Default: ngrid=20. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help about: anova and population no normal
Oh, and to answer your question more directly, the randomization test permits testing hypotheses using any metric, so scale shape are definitely testable. Typically one is interested in means, so on each iteration of the test loop one computes the group/condition means. However, it's simple to instead compute, say, the best fit weibull to each condition and simultaneously test shift, shape, and scale. On Tue, Mar 31, 2009 at 12:18 PM, Mike Lawrence mike.lawre...@dal.ca wrote: Those with more formal statistical backgrounds may provide better advice, but in my own informal training I've come to wonder why parametric stats persist in the face of modern computing power. As I understand it, Fisher developed ANOVA as low-computation method of approximating the Randomization Test (a.k.a. exhaustive permutation test). Where computation power has grown exponentially since Fisher's time, these days it is feasible to compute the full R-Test in many cases, and for those cases where the full R-Test is not feasible, non-exhaustive permutation variants usually satisfy. Indeed, it has been shown (http://brm.psychonomic-journals.org/content/37/3/426.short) that the R-Test is more powerful than the F-Test in the face of skewed distributions. My advice would thus be to abandon parametrics and simply code a randomization test variant of the ANOVA you want. Mike On Tue, Mar 31, 2009 at 10:29 AM, Sarti Maurizio sart...@irea.cnr.it wrote: Dear R-Helpers, Parametric statistics are statistics where the population is assumed to fit any parametrized distributions (most typically the normal distribution). My problem is: 1) if my polulation is no normal 2) if the sample data of all replications and treatments were well fitted from the Weibull distribution (shape and scale parameters). Can be The shape and scale parameters compared between treatments by using the canonical analysis of the variance ANOVA? Many thanks for your help with these questions. Maurizio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tinyurl.com/mikes-public-calendar ~ Certainty is folly... I think. ~ -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tinyurl.com/mikes-public-calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'for Loop'
Hello, I'm trying to create a for loop for a data set, I have a list of results in this data set and I want to take the 1st two add them together and divide by the mean of the 1st to, then do the same for the 3rd and 4th values in the list and so on and each time return a value for the calculation on each pair. Any help would be appreciated. Thanks, Al [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Deriving Samples from specific, not implemented PDF for a QQ-Plot
Dear All, this is my first post to the R-help, so please don't be too strict. My problem concerns a QQ-Plot: I want to show how well empirical samples match with a theoretical distribution. The theoretical distribution has got several parameters, but I made it to fit via ML. Anyway, the theoretical function gives me the density for a given data point x. As far as I'm aware, the qqplot (generic) function in R does only take data samples as Input. How can I derive samples from the pdf? Am I right in the way I see the problem? Or How can I modify the qqplot function, (or rebuild for myself) to get it going? I'm sure, this is very likely just a misunderstanding problem from myself, but anybody who can shed further light on this is very welcome. Best regards Arndt Zimmermann [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'for Loop'
Al, Is there any ID index for the pairs? For example, if the first pair can be labeled a, and second pair labeled b etc., then you can add an index column or you may already have such a column in your list. Then run aggregate(your.data.column, by=index.column, FUN=mean). Or you can just add an extra index column anyway rep(1:number of the rows/2, each=2). Hope this helps. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 On Tue, Mar 31, 2009 at 10:40 AM, Alan O'Loughlin olo...@wyeth.com wrote: Hello, I'm trying to create a for loop for a data set, I have a list of results in this data set and I want to take the 1st two add them together and divide by the mean of the 1st to, then do the same for the 3rd and 4th values in the list and so on and each time return a value for the calculation on each pair. Any help would be appreciated. Thanks, Al [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3d cloud plot with point size reflecting variable value
R User R User ruser2008 at googlemail.com writes: I'm using the cloud function to plot the iris data as per the document: http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/fichiers/_gallery.pdf I'd like to change the point size to reflect a fourth variable, as done here http://www.cis.hut.fi/projects/somtoolbox/download/pics2/shotvs2_origdata.png Does anybody know how to do this? There doesn't seem to be an option in cloud() My first idea was to add cex = iris$PetalLength, which failed, taking the first value of cex only. In panel.3dscatter I found the line cex - rep(cex, length.out = n) Which looks like cex is not vectored. So my approach would be to make a copy of panel.3dscatter and do the correct cex replacement there. I might be wrong, however, Deepayan has the last say. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Factor Analysis Output from R and SAS
At 8:17 AM -0400 3/31/09, John Fox wrote: Dear TY, Considering that you used different methods -- maximum-likelihood factor analysis in R and principal components analysis in SAS -- the results are quite similar (although the three rotated factors/components come out in different orders). I hope this helps, John As John pointed out, PCA is not the same as FA. Unfortunately, SAS labeled the PCA as a factor analysis, when it is not. And, when one does a principal components and extracts just the first three components (as you did), the unrotated solution is identical: package(psych) pc3 - principal(x,3,rotate=none) print(pc3,digits=5,cut=0) V PC1 PC2 PC3 V1 1 0.79880 0.549948 -0.17614 V2 2 0.77036 0.561712 -0.24862 V3 3 0.79475 -0.076853 0.54982 V4 4 0.75757 -0.087363 0.59785 V5 5 0.80878 -0.456096 -0.33437 V6 6 0.1 -0.483310 -0.36933 PC1 PC2 PC3 SS loadings3.69603 1.07311 1.00077 Proportion Var 0.61601 0.17885 0.16680 Cumulative Var 0.61601 0.79486 0.96165 Test of the hypothesis that 3 factors are sufficient. The degrees of freedom for the model is 0 and the fit was 1.57483 The number of observations was 18 with Chi Square = 19.16046 with prob NA When you then rotate these components using Varimax, the solutions differ at the fourth decimal place pc3 - principal(x,3) print(pc3,cut=0,digits=5) V PC1 PC2 PC3 V1 1 0.19991 0.93168 0.25210 V2 2 0.21193 0.94606 0.17562 V3 3 0.23805 0.23479 0.90997 V4 4 0.19920 0.19084 0.92891 V5 5 0.93057 0.5 0.24208 V6 6 0.94738 0.19422 0.19896 PC1 PC2 PC3 SS loadings1.94470 1.94172 1.88350 Proportion Var 0.32412 0.32362 0.31392 Cumulative Var 0.32412 0.64774 0.96165 Bill -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tae-Young Heo Sent: March-31-09 7:07 AM To: r-help@r-project.org Subject: [R] Factor Analysis Output from R and SAS Dear Users, I ran factor analysis using R and SAS. However, I had different outputs from R and SAS. Why they provide different outputs? Especially, the factor loadings are different. I did real dataset(n=264), however, I had an extremely different from R and SAS. Why this things happened? Which software is correct on? Thanks in advance, - TY #R code with example data # A little demonstration, v2 is just v1 with noise, # and same for v4 vs. v3 and v6 vs. v5 # Last four cases are there to add noise # and introduce a positive manifold (g factor) v1 - c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 - c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 - c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 - c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 - c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 - c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 - cbind(v1,v2,v3,v4,v5,v6) cor(m1) # v1v2v3v4v5v6 #v1 1.000 0.9393083 0.5128866 0.4320310 0.4664948 0.4086076 #v2 0.9393083 1.000 0.4124441 0.4084281 0.4363925 0.4326113 #v3 0.5128866 0.4124441 1.000 0.8770750 0.5128866 0.4320310 #v4 0.4320310 0.4084281 0.8770750 1.000 0.4320310 0.4323259 #v5 0.4664948 0.4363925 0.5128866 0.4320310 1.000 0.9473451 #v6 0.4086076 0.4326113 0.4320310 0.4323259 0.9473451 1.000 factanal(m1, factors=3) # varimax is the default # Output from R #Call: #factanal(x = m1, factors = 3) #Uniquenesses: # v1v2v3v4v5v6 #0.005 0.101 0.005 0.224 0.084 0.005 #Loadings: # Factor1 Factor2 Factor3 #v1 0.944 0.182 0.267 #v2 0.905 0.235 0.159 #v3 0.236 0.210 0.946 #v4 0.180 0.242 0.828 #v5 0.242 0.881 0.286 #v6 0.193 0.959 0.196 # Factor1 Factor2 Factor3 #SS loadings 1.893 1.886 1.797 #Proportion Var 0.316 0.314 0.300 #Cumulative Var 0.316 0.630 0.929 #The degrees of freedom for the model is 0 and the fit was 0.4755 /* SAS code with example data*/ data fact; input v1-v6; datalines; 1 1 3 3 1 1 1 2 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 2 1 1 3 4 1 1 1 1 3 3 3 3 1 1 1 1 3 4 1 1 1 1 3 3 1 2 1 1 3 3 1 1 1 2 3 3 1 1 1 1 4 4 5 5 6 6 5 6 4 6 4 5 6 5 6 4 5 4 ; run; proc factor data=fact rotate=varimax method=p nfactors=3; var v1-v6; run; /* Output from SAS*/ The FACTOR Procedure Initial Factor Method: Principal Components Prior Communality Estimates: ONE Eigenvalues of the Correlation Matrix: Total = 6 Average = 1 EigenvalueDifference ProportionCumulative
[R] Using apply to get group means
Hi all, I'm trying to improve my R skills and make my programming more efficient and succinct. I can solve the following question, but wonder if there's a better way to do it: I'm trying to calculate mean by several variables and then put this back into the original data set as a new variable. For example, if I were measuring weight, I might want to have each individual's weight, and also the group mean by, say, race, sex, and geographic region. The following code works: x1-rep(c(A,B,C),3) x2-c(rep(1,3),rep(2,3),1,2,1) x3-c(1,2,3,4,5,6,2,6,4) x-as.data.frame(cbind(x1,x2,x3)) x3.mean-rep(0,nrow(x)) for (i in 1:nrow(x)){ + x3.mean[i]-mean(as.numeric(x[,3][x[,1]==x[,1][i]x[,2]==x[,2][i]])) + } cbind(x,x3.mean) x1 x2 x3 x3.mean 1 A 1 1 1.5 2 B 1 2 2.0 3 C 1 3 3.5 4 A 2 4 4.0 5 B 2 5 5.5 6 C 2 6 6.0 7 A 1 2 1.5 8 B 2 6 5.5 9 C 1 4 3.5 However, I'd love to be able to do this with apply rather than a for-loop. Or is there a built-in function? Any suggestions? Also, any way to avoid the hassles with having to convert to a data frame and then again to numeric when one variable is character? Cheers, Alan Cohen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reshape: 'melt' numerous objects
Dear R Users, I'm trying to use the reshape package to 'melt' my gridded data into column format. I've done this before on individual files, but this time I'm trying to do it on a directory of files (with variable file names) - therefore I have to also use the 'assign' command. I have come up against a couple of problems however and am therefore seeking advice... assign(paste(Fekete_table_temp, index$year[i], index$month[i], sep='')$Latitude,rownames(Fekete_198601)) # Using the row names of a given file Error in paste(Fekete_table_temp, index$year[i], index$month[i], sep = )$Latitude : $ operator is invalid for atomic vectors To get round this, I did: assign(paste(Fekete_table_temp, index$year[i], index$month[i], sep='')[Latitude],rownames(Fekete_198601)) And for the actual loop in which the files are melted, I tried: for (i in 1:120) { Fekete_table_temp - get(paste(Fekete_, index$year[i], index$month[i], sep='')) Fekete_table_long - melt(Fekete_table_temp, id.var=Latitude, na.rm=TRUE) assign(paste(Fekete_long_, index$year[i], index$month[i], sep=''), Fekete_table_long) names(paste(Fekete_long_, index$year[i], index$month[i], sep=''), c(Latitude, Longitude, paste(Obs,index$year[i], index$month[i], sep='')) } However, this results in: Error: id variables not found in data: Latitude ...despite me having (supposedly) told it where 'Latitude' is, in 'Fekete_table_temp'. What have I done wrong here?! And more importantly, how do I put it right?! Many thanks for any help, Steve _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] USING MULTILEVEL PACKAGE AND WABA FUNCTION
Dear friends, this time I have a problem with using waba function. Firstly, I'll explain you my situation. In the survey a gruop of supervisors judge the dipendents of a company. One supervisor reported on more than one subordinate. Thus, I need to show that lack of independence is not a problem, and a reviewer told me to use WABA. The question is, how? In which way i can build my X and Y? I've understand that i need a variable group (supervisor), but i didn't understand how i can prove that judgement are indipendent from the supervisor. Another specification: supervisors reply to 12 items about each worker, and i have more than 15 supervisors, and ones of them judges only few workers, and others ones judges a very big quantity of workers. The reviewer also told me that another approach is use multilevel modeling (HLM), but i really don't know how i can do it. Hoping to have so many replies earlier, i wish you the best. Costantino Milanese [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bug in col2rgb?
col2rgb(#0079, TRUE) [,1] red 0 green0 blue 0 alpha 121 col2rgb(#0080, TRUE) [,1] red255 green 255 blue 255 alpha0 col2rgb(#0081, TRUE) [,1] red 0 green0 blue 0 alpha 129 Any ideas? Thanks, Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using apply to get group means
Not exactly the output you asked for, but perhaps you can consider, library(doBy) summaryBy(x3~x2+x1,data=x,FUN=mean) x2 x1 x3.mean 1 1 A 1.5 2 1 B 2.0 3 1 C 3.5 4 2 A 4.0 5 2 B 5.5 6 2 C 6.0 the plyr package also provides similar functionality, as do the ?by, ? ave, and ?tapply base functions. HTH, baptiste On 31 Mar 2009, at 17:09, Alan Cohen wrote: Hi all, I'm trying to improve my R skills and make my programming more efficient and succinct. I can solve the following question, but wonder if there's a better way to do it: I'm trying to calculate mean by several variables and then put this back into the original data set as a new variable. For example, if I were measuring weight, I might want to have each individual's weight, and also the group mean by, say, race, sex, and geographic region. The following code works: x1-rep(c(A,B,C),3) x2-c(rep(1,3),rep(2,3),1,2,1) x3-c(1,2,3,4,5,6,2,6,4) x-as.data.frame(cbind(x1,x2,x3)) x3.mean-rep(0,nrow(x)) for (i in 1:nrow(x)){ + x3.mean[i]-mean(as.numeric(x[,3][x[,1]==x[,1][i]x[,2]==x[,2] [i]])) + } cbind(x,x3.mean) x1 x2 x3 x3.mean 1 A 1 1 1.5 2 B 1 2 2.0 3 C 1 3 3.5 4 A 2 4 4.0 5 B 2 5 5.5 6 C 2 6 6.0 7 A 1 2 1.5 8 B 2 6 5.5 9 C 1 4 3.5 However, I'd love to be able to do this with apply rather than a for-loop. Or is there a built-in function? Any suggestions? Also, any way to avoid the hassles with having to convert to a data frame and then again to numeric when one variable is character? Cheers, Alan Cohen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using apply to get group means
On Tue, Mar 31, 2009 at 11:31 AM, baptiste auguie ba...@exeter.ac.uk wrote: Not exactly the output you asked for, but perhaps you can consider, library(doBy) summaryBy(x3~x2+x1,data=x,FUN=mean) x2 x1 x3.mean 1 1 A 1.5 2 1 B 2.0 3 1 C 3.5 4 2 A 4.0 5 2 B 5.5 6 2 C 6.0 the plyr package also provides similar functionality, as do the ?by, ?ave, and ?tapply base functions. In plyr it would look like: x1 - rep(c(A, B, C), 3) x2 - c(rep(1, 3), rep(2, 3), 1, 2, 1) x3 - c(1, 2, 3, 4, 5, 6, 2, 6, 4) df - data.frame(x1, x2, x3) ddply(df, .(x1, x2), transform, x3.mean = mean(x3)) Note how I created the data frame - only use cbind if you want a matrix (i.e. all the columns have the same type) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape: 'melt' numerous objects
On Tue, Mar 31, 2009 at 11:12 AM, Steve Murray smurray...@hotmail.com wrote: Dear R Users, I'm trying to use the reshape package to 'melt' my gridded data into column format. I've done this before on individual files, but this time I'm trying to do it on a directory of files (with variable file names) - therefore I have to also use the 'assign' command. I have come up against a couple of problems however and am therefore seeking advice... I'd _strongly_ recommend you don't use assign. Instead put everything in a list: paths - dir(mydir, \\.csv$, full.names = TRUE) names(paths) - basename(paths) data - lapply(paths, read.csv) molten - lapply(data, melt, id = Latitude, na.rm=TRUE) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using apply to get group means
A different solution (using aggregate for the table of means and merge for adding it to the dataframe): x1-rep(c(A,B,C),3) x2-c(rep(1,3),rep(2,3),1,2,1) x3-c(1,2,3,4,5,6,2,6,4) x-data.frame(x1,x2,x3) #here using data.frame the x1 variable is directly converted to factor x3means - aggregate(x$x3, by=list(x$x1), FUN=mean) merge(x, x3means, by.x=x1, by.y=Group.1) Ciao, domenico Alan Cohen wrote: Hi all, I'm trying to improve my R skills and make my programming more efficient and succinct. I can solve the following question, but wonder if there's a better way to do it: I'm trying to calculate mean by several variables and then put this back into the original data set as a new variable. For example, if I were measuring weight, I might want to have each individual's weight, and also the group mean by, say, race, sex, and geographic region. The following code works: x1-rep(c(A,B,C),3) x2-c(rep(1,3),rep(2,3),1,2,1) x3-c(1,2,3,4,5,6,2,6,4) x-as.data.frame(cbind(x1,x2,x3)) x3.mean-rep(0,nrow(x)) for (i in 1:nrow(x)){ + x3.mean[i]-mean(as.numeric(x[,3][x[,1]==x[,1][i]x[,2]==x[,2][i]])) + } cbind(x,x3.mean) x1 x2 x3 x3.mean 1 A 1 1 1.5 2 B 1 2 2.0 3 C 1 3 3.5 4 A 2 4 4.0 5 B 2 5 5.5 6 C 2 6 6.0 7 A 1 2 1.5 8 B 2 6 5.5 9 C 1 4 3.5 However, I'd love to be able to do this with apply rather than a for-loop. Or is there a built-in function? Any suggestions? Also, any way to avoid the hassles with having to convert to a data frame and then again to numeric when one variable is character? Cheers, Alan Cohen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'for Loop'
Al, Say, your data file is 'test', execute the following in sequence, aggregate(test[1],test[2],mean)-inter names(inter)[2]='mean' merge(test,inter,all=T)-inter2 inter2$RSV=inter2$Result/inter2$mean The column 'RSV' in inter2 should be what you want. Jun On Tue, Mar 31, 2009 at 11:11 AM, Alan O'Loughlin olo...@wyeth.com wrote: Thanks for replying, Actually I was trying to give a simple example of calculations just to see the programming part of it. I'm actuually calculating the RSD% the 2 numbers are replica standard devation results... Here is an example of my data set. Result Index 1 0.290117 2 0.292817 3 0.291318 4 0.289318 5 0.3526 9 6 0.3316 9 7 0.349210 8 0.346710 9 0.338511 10 0.334111 11 0.344912 12 0.340612 13 0.369013 14 0.332713 15 0.332414 16 0.324514 17 0.324515 18 0.322915 19 0.333116 20 0.320816 Kind Regards, Al Jun Shen jun.shen...@gmail.com 31-Mar-09 17:08 Al, Is there any ID index for the pairs? For example, if the first pair can be labeled a, and second pair labeled b etc., then you can add an index column or you may already have such a column in your list. Then run aggregate(your.data.column, by=index.column, FUN=mean). Or you can just add an extra index column anyway rep(1:number of the rows/2, each=2). Hope this helps. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 On Tue, Mar 31, 2009 at 10:40 AM, Alan O'Loughlin olo...@wyeth.comwrote: Hello, I'm trying to create a for loop for a data set, I have a list of results in this data set and I want to take the 1st two add them together and divide by the mean of the 1st to, then do the same for the 3rd and 4th values in the list and so on and each time return a value for the calculation on each pair. Any help would be appreciated. Thanks, Al [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in col2rgb?
On 3/31/2009 12:29 PM, hadley wickham wrote: col2rgb(#0079, TRUE) [,1] red 0 green0 blue 0 alpha 121 col2rgb(#0080, TRUE) [,1] red255 green 255 blue 255 alpha0 col2rgb(#0081, TRUE) [,1] red 0 green0 blue 0 alpha 129 Any ideas? The #0080 string converts into the hex integer 0x8000, which, by an unfortunate coincidence, is the NA_integer value. Since NA_integer becomes the background colour, you get white instead of black with alpha=0x80. This can probably be fixed (if you have a string, there's a different way to know you have an NA). Want to work out a patch? The file to look at is src/main/colors.c. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.