[R] Splitting a vector into equal groups
Hi All, I have vector of length 52, say, x=sample(30,52,replace=T). I want to sort x and split into five *nearly equal groups*. Note that the observations are repeated in x so in case of a tie I want both the observations to fall in same group. This seems a very common task to do, but still I couldn't find an R function to do this. Any help would be highly appreciated. Regards Utkarsh [[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] Splitting a vector into equal groups
lattice:::equal.count may be what you want. 2009/5/4 utkarshsinghal utkarsh.sing...@global-analytics.com: Hi All, I have vector of length 52, say, x=sample(30,52,replace=T). I want to sort x and split into five *nearly equal groups*. Note that the observations are repeated in x so in case of a tie I want both the observations to fall in same group. This seems a very common task to do, but still I couldn't find an R function to do this. Any help would be highly appreciated. Regards Utkarsh [[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. -- HUANG Ronggui, Wincent PhD Candidate Dept of Public and Social Administration City University of Hong Kong Home page: http://asrr.r-forge.r-project.org/rghuang.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Splitting a vector into equal groups
check functions cut() and quantile(), and cut2() from package Hmisc; maybe the following is close to what you want: x - sample(30, 52, replace = TRUE) k - 5 # how many groups qs - quantile(x, seq(0, 1, length.out = k + 1)) y - cut(x, round(qs), include.lowest = TRUE) y table(y) I hope it helps. Best, Dimitris utkarshsinghal wrote: Hi All, I have vector of length 52, say, x=sample(30,52,replace=T). I want to sort x and split into five *nearly equal groups*. Note that the observations are repeated in x so in case of a tie I want both the observations to fall in same group. This seems a very common task to do, but still I couldn't find an R function to do this. Any help would be highly appreciated. Regards Utkarsh [[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. -- 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] Splitting a vector into equal groups
G'day Utkarsh, On Mon, 04 May 2009 11:51:21 +0530 utkarshsinghal utkarsh.sing...@global-analytics.com wrote: I have vector of length 52, say, x=sample(30,52,replace=T). I want to sort x and split into five *nearly equal groups*. What do you mean by *nearly equal groups*? The size of the groups should be nearly equal? The sum of the elements of the groups should be nearly equal? Note that the observations are repeated in x so in case of a tie I want both the observations to fall in same group. Then it becomes even more important to define what you mean with nearly equal groups. As a start, you may consider: R set.seed(1) R x=sample(30,52,replace=T) R xrle - rle(sort(x)) R xrle Run Length Encoding lengths: int [1:25] 2 1 2 2 3 1 1 1 5 1 ... values : int [1:25] 1 2 4 6 7 8 9 11 12 13 ... R cumsum(xrle$lengths) [1] 2 3 5 7 10 11 12 13 18 19 24 25 26 28 29 32 35 38 [19] 43 45 46 48 49 51 52 and use this to determine our cut-offs. E.g., should the first group have 10, 11 or 12 elements in this case? The information in xrle should enable you to construct your five groups once you have decided on a grouping. HTH. Cheers, Berwin === Full address = Berwin A TurlachTel.: +65 6516 4416 (secr) Dept of Statistics and Applied Probability+65 6516 6650 (self) Faculty of Science FAX : +65 6872 3919 National University of Singapore 6 Science Drive 2, Blk S16, Level 7 e-mail: sta...@nus.edu.sg Singapore 117546http://www.stat.nus.edu.sg/~statba __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] QUADRATIC TREND FOR LINK FUNCTIONS ON NON-STATIONARY GEV
Hi All, I am a newcomer to R. Could anyone explain me how to define link functions for either mu/sigma to allow for quadratic trends in the same, when fitting non-stationary GEV distributions? Thanks -- View this message in context: http://www.nabble.com/QUADRATIC-TREND-FOR-LINK-FUNCTIONS-ON-NON-STATIONARY-GEV-tp23360751p23360751.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] Question of Quantile Regression for Longitudinal Data
Dear R user, I am trying to estimate a quantile regression using panel data. I am trying to use the model that is described in Dr. Koenker's article. So I use the code the that is posted in the following link: http://www.econ.uiuc.edu/~roger/research/panel/rq.fit.panel.R I use plm package to estimate OLS estimators. Then I ploted the figure with Quantile estimators and OLS estimators But the line of Quantile estimators was not cross the line of OLS estimators. I don't know why. OLS estimator is 0.00108194 Quantile estimators with 9 quantiles(0.1 to 0.9) as follow: 0.0002071648 , 0.0002071899 , 0.0002149157 , 0.0002242560 , 0.0002254730 0.0002404203 0.000232909 0.0002511185 0.0003015694 Thanks I really would appreciate some suggestions. Best Helen Chen -- View this message in context: http://www.nabble.com/Question-of-%22Quantile-Regression-for-Longitudinal-Data%22-tp23363232p23363232.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] normality test for large a large dataset ?
Hello, Do you know a R implemented normality test like the shapiro test but more suitable for large data set ? Thanks, _ Découvrez toutes les possibilités de communication avec vos proches [[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] Division ?
TH == Ted Harding ted.hard...@manchester.ac.uk on Sun, 03 May 2009 10:11:04 +0100 (BST) writes: TH On 02-May-09 17:34:15, bogdanno wrote: It seems division with numbers bigger than 10 000 000 doesn't work 2000/21 [1] 952381 /23 [1] 2415459 Thank you TH I think you are confusing what is displayed with what is TH computed: TH 2000/21 # [1] 952381 print(2000/21,17) # [1] TH 952380.9523809524 TH /23 # [1] 2415459 print(/23,17) # [1] TH 2415458.913043478 TH (2000/21)*21 # [1] 2e+07 TH print((2000/21)*21,17) # [1] 2e+07 TH (/23)*23 # [1] TH print((/23)*23,17) # [1] TH Your numbers bigger than 10 000 000 corresponds to the TH default display of results to 7 significant figures. TH If (as in the above print() statements) you increase TH this, you get more reasonable-looking results. Yes, indeed. If Bogdanno thinks he wants to always see all digits, he should use something like options(digits= 20) in his R startup setting, e.g. in his Rprofile, see ?Startup. Note however: Quite a few experienced R users rather do *REDUCE* the default number of digits printed, rather than enlarge them. (I don't) Martin Maechler, ETH Zurich TH TH E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk TH Fax-to-email: +44 (0)870 094 0861 Date: 03-May-09 Time: TH 10:11:02 -- XFMail TH -- __ R-help@r-project.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] quadratic programming
Devo risolvere un problema di minimo vincolato con vincoli di uguaglianza e un altro con vincoli di uguaglianza e disuguaglianza. Cosa posso utilizzare? [[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] Surface for R outside of R
Hi all, i am new here and this is my first posting. My coding experience in R ist okay, but I have a problem which is related to another aspect of R. I am searching for a surface which execute my commands in R via a click on a button OUTSIDE of R. Concrete: I will write some programs in R and want to execute this files outside of R, so I don't want to start R eyery time if i want an analysis. The best case were a surface of e.g. 8 Buttons, each click leads to start a specific R file. My outputs are JPEG or CSV, so I don`t need the output inside of R. Could anyone can give me some recommendations, what could be a solution (e. g. Java)? Is such a solution possible? Thank you very much, Jens. -- View this message in context: http://www.nabble.com/Surface-for-R-outside-of-R-tp23364631p23364631.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] Need to clean a table, and compute mean and SD
Hi For a school project I have a file with 120 columns and ~2000 lines. This file contains timestamps of spike detected in 60 channels, and the time elapsed between the last spike. I need to clean too high values. About 98% of values are between 0 and 2000 and 2% are between 2000 and 20'000. I want to get rid of theses values. Please could you help me? Regards Thom -- View this message in context: http://www.nabble.com/Need-to-clean-a-table%2C-and-compute-mean-and-SD-tp23364460p23364460.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] About the Transfer Function Model(ARIMAX)
Dear ALL, I would appreciate if someone help me by letting me know the code of above model in R.I would request you to please let me know how i could make arimax model in auto.arima. Regards Ramanath [[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] How to skip rest of code
How about: x - F if (x) { print(true) } else { print(false) } Bart mli-2 wrote: Dear R users, Suppose I have 2 R script files: 'test1.R' and 'test2.R' and one R file 'main.R' which sources each of them. I wonder if there is a way to skip rest of code in 'test1.R' once a condition is met but still continue to run rest of script from the 'main'R' file. A simple example is shown below. I hope only 'message1' and 'message3' can be shown up without using if(...) else statement for skipped part in 'test1.R'. #main.R: source(test1.R) source(test2.R) === #test1.R # In this example the goal is to skip executing the line of print(message2). # without using if() else statement. x - TRUE if (x) { print(message1) q() # want to skip rest of code in test1.R ONLY } # lots of lines can start from here. print(message2) === #test2.R print(message3) Thank you. Ming-chung Li [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/How-to-skip-rest-of-code-tp23320816p23365295.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] wrong if-else syntax
What is wrong in the following nested if-else statements: if (Condition_1) { # begin IF_1 statement_1 statement_2 statement_3 if (Condition_2) { # begin IF_2 a- a +1 } # end IF_2 statement_4 statement_5 statement_6 statement_7 if (Condition_3) {# begin IF_2 statement_8 } else { # ELSE_2 statement_9 statement_10 } # end IF_2 } else { # ELSE_1 statement_11 } # end IF_1 It looks like R interpret does not like the above syntax. In fact in my script I have the following instructions: if (DonohoAplhaON){ tms - xx[,sampamp] #EXTRACT SIGNAL AMPLITUDE tmsLen - length(tms) J - ilogb(tmsLen, base=2) if (logb(tmsLen, base=2)%%2 0) { J - J + 1 } rm(xx) rawtms - tms X - PreProcessor(tms,tmsLen,J) BestWavList - FindBestWavelet (X,tmsLen,J,Step1NumHighScalesOFF) if (!is.null(BestWavList)) { #COMPUTE SIGNAL DONOHO-ALPHA features.mat[ns,alpha]- CalcDonohoAlpha(rawtms,BestWavList$No,J,tmsLen,Step3NumHighScalesOFF,Step3AllCoefON) } else { cat(\n\n Could not compute Best Wavelet Basis for Signal: ,fln, Skip current signal! \n\n) next } } else { features.mat[ns,alpha] - NA } It keeps printing out an error referred to the second } else { as if it could not realize that the inner if-statement has been closed: if(!is.null(BestWavList)) { #COMPUTE SIGNAL DONOHO-ALPHA + features.mat[ns,alpha]- CalcDonohoAlpha(rawtms,BestWavList$No,J,tmsLen,Step3NumHighScalesOFF,Step3AllCoefON) + }else { + cat(\n\n Could not compute Best Wavelet Basis for Signal: ,fln, Skip current signal! \n\n) + next + } }else { Error: unexpected '}' in } features.mat[ns,alpha] - NA } Error: unexpected '}' in } Thank you for clarifying my doubts 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.
Re: [R] quadratic programming
Hi, The CRAN Task View on Optimization may help: http://stat.ethz.ch/CRAN/web/views/Optimization.html HTH, Stephan barbara.r...@uniroma1.it schrieb: Devo risolvere un problema di minimo vincolato con vincoli di uguaglianza e un altro con vincoli di uguaglianza e disuguaglianza. Cosa posso utilizzare? [[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] Odp: Need to clean a table, and compute mean and SD
Hi r-help-boun...@r-project.org napsal dne 04.05.2009 09:53:19: Hi For a school project I have a file with 120 columns and ~2000 lines. This file contains timestamps of spike detected in 60 channels, and the time elapsed between the last spike. I need to clean too high values. About 98% of values are between 0 and 2000 and 2% are between 2000 and 20'000. I want to get rid of theses values. Please could you help me? Decide your threshold value. Let say it is 2000. Then it depends how do you want to get rid of the data. e.g. mat[mat2000]-NA shall put NA values instead all items which were bigger than 2000. Regards Petr Regards Thom -- View this message in context: http://www.nabble.com/Need-to-clean-a-table%2C- and-compute-mean-and-SD-tp23364460p23364460.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] odbcConnectAccess function
You can use R CMD BATCH if I'm correctly. How about define a query through your routine, process the results of this query through R, write this output in a new table, or a textfile, and load this with your subroutine. Bart Felipe Carrillo wrote: Steve: I am already using it importing data from Access to R but was wondering if it can be used the other way around, creating a subroutine in an access module and using the RODBC functions from there. --- On Thu, 4/30/09, steve_fried...@nps.gov steve_fried...@nps.gov wrote: From: steve_fried...@nps.gov steve_fried...@nps.gov Subject: Re: [R] odbcConnectAccess function To: mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch, r-help-boun...@r-project.org Date: Thursday, April 30, 2009, 7:38 AM Feilipe, You should look at the RODBC package It works great ! 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 Felipe Carrillo mazatlanmex...@y ahoo.com To Sent by: r-h...@stat.math.ethz.ch r-help-boun...@r- cc project.org Subject [R] odbcConnectAccess function 04/30/2009 07:17 AM MST Please respond to mazatlanmex...@ya hoo.com HI: Is it possible to use the RODBC package within MS Access. I have been using from R but was just wondering if it could be used along with R(D)COM. Something like this: Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim myApp As StatConnector Set myApp = New StatConnector myApp.GetErrorText myApp.Init R myApp.EvaluateNoReturn library(RODBC) myApp.EvaluateNoReturn myDB - odbcConnectAccess(CurrentDb) 'query the database and save it as R object 'a' myApp.EvaluateNoReturn a - sqlQuery(CurrentDb, Paste(select * From Sample)) myApp.EvaluateNoReturn plot(a) Thanks in advance Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/odbcConnectAccess-function-tp23317361p23365104.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] Randomized-complete blocks design and R
Hi, I am new in R.I am trying to analysis of variance for Randomized-complete blocks design. I have 4 treatments and 3 replication, Without intraction.then .I is going to use LSD test or Duncan test for comparison between average values of treatments. I want to know, is there any significant change between treatment and between weeks? Because I did experiment for 8 weeks. I am not familiar with R very well. Dose anybody has this Code? Please help me. Kind regards, Alisa [[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] clear screen?
On 03/05/2009 6:50 PM, Charles Annis, P.E. wrote: I’ve been using this routine for several years. I’m sorry, I don’t remember where I got it. It works as it should, viz. it blanks the R console. But it requires package rcom and now that requires rscproxy. cls - function () { require(rcom) wsh - comCreateObject(Wscript.Shell) comInvoke(wsh, SendKeys, \f) invisible(wsh) } cls() Loading required package: rcom Loading required package: rscproxy This seems like overkill to me just to blank the R console, especially since I am trying to diminish the number of necessary packages to support my home-brew package. So, is there an easier way to blank the R console in Windows? Ctrl-L will do it. If you want to put it in a function, I don't think so. An item that has been on my wish list for a long time is to rewrite the menu system in the Windows gui so that all items can be invoked from R code. It's been sitting there in the section entitled I wish someone else would do this. It would not be hard, but it would be a lot of tedious work. Duncan Murdoch sessionInfo() R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] rcom_2.1-1 rscproxy_1.2-0 survival_2.35-3 RColorBrewer_1.0-2 RODBC_1.2-5 myhomebrew loaded via a namespace (and not attached): [1] tools_2.8.1 Charles Annis, P.E. charles.an...@statisticalengineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] wrong if-else syntax
On 04/05/2009 5:08 AM, mau...@alice.it wrote: What is wrong in the following nested if-else statements: if (Condition_1) { # begin IF_1 statement_1 statement_2 statement_3 if (Condition_2) { # begin IF_2 a- a +1 } # end IF_2 statement_4 statement_5 statement_6 statement_7 if (Condition_3) {# begin IF_2 statement_8 } else { # ELSE_2 statement_9 statement_10 } # end IF_2 } else { # ELSE_1 statement_11 } # end IF_1 It looks like R interpret does not like the above syntax. In fact in my script I have the following instructions: if (DonohoAplhaON){ tms - xx[,sampamp] #EXTRACT SIGNAL AMPLITUDE tmsLen - length(tms) J - ilogb(tmsLen, base=2) if (logb(tmsLen, base=2)%%2 0) { J - J + 1 } rm(xx) rawtms - tms X - PreProcessor(tms,tmsLen,J) BestWavList - FindBestWavelet (X,tmsLen,J,Step1NumHighScalesOFF) if (!is.null(BestWavList)) { #COMPUTE SIGNAL DONOHO-ALPHA features.mat[ns,alpha]- CalcDonohoAlpha(rawtms,BestWavList$No,J,tmsLen,Step3NumHighScalesOFF,Step3AllCoefON) } else { cat(\n\n Could not compute Best Wavelet Basis for Signal: ,fln, Skip current signal! \n\n) next } } else { features.mat[ns,alpha] - NA } It keeps printing out an error referred to the second } else { as if it could not realize that the inner if-statement has been closed: I just tried the full block above, and it was fine. if(!is.null(BestWavList)) { #COMPUTE SIGNAL DONOHO-ALPHA Notice the prompt here is , not +. The problem occurred earlier: R thinks this is a new statement, not part of the if (DonohoAplhaON) { block as you intended. + features.mat[ns,alpha]- CalcDonohoAlpha(rawtms,BestWavList$No,J,tmsLen,Step3NumHighScalesOFF,Step3AllCoefON) + }else { + cat(\n\n Could not compute Best Wavelet Basis for Signal: ,fln, Skip current signal! \n\n) + next + } This finishes the statement, so the else doesn't make sense. }else { The spacing here doesn't match what you showed above. Are you sure you're pasting the right file? You'll get better error handling using source() than cut and paste. source() will stop at the first error; cut and paste just keeps going. Duncan Murdoch Error: unexpected '}' in } features.mat[ns,alpha] - NA } Error: unexpected '}' in } Thank you for clarifying my doubts 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-help@r-project.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] Creating a variable which is the sum of equal rows in a dataframe
Hi everyone: I need to count the number of banks of each firm in my data. The firm is identified by the fiscal number. The banks of each firm appears like this: Firm Banks 500600700 Citybank 500600700 CGD 500600700 BES 500600800 Citybank 500600800 Bank1 500600900 CGD I want to obtain the following dataframe: Firmnumberofbanks 500600700 3 500600800 2 500600900 1 This is a question of counting the times each firm appears, but I dont know which function do this. If anyone could help me I appreciate. Thank you in advance for the help you could give me, Cecilia Carmo (Portugal) __ R-help@r-project.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] Surface for R outside of R
On 04/05/2009 4:12 AM, koj wrote: Hi all, i am new here and this is my first posting. My coding experience in R ist okay, but I have a problem which is related to another aspect of R. I am searching for a surface which execute my commands in R via a click on a button OUTSIDE of R. Concrete: I will write some programs in R and want to execute this files outside of R, so I don't want to start R eyery time if i want an analysis. The best case were a surface of e.g. 8 Buttons, each click leads to start a specific R file. My outputs are JPEG or CSV, so I don`t need the output inside of R. Could anyone can give me some recommendations, what could be a solution (e. g. Java)? Is such a solution possible? There are many solutions. Java (through JRI in rJava) may be the most portable one; there are others that are specific to particular operating systems. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Caret package: coeffcients for regression
Dear All, I am using Caretpackage for SVM regression and elastic net regression . I can get the final fiited vs observed values. How can I get the coefficients? Any ideas? Thanks Alex [[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] Creating a variable which is the sum of equal rows in a dataframe
Try this, # d - read.table(pipe(pbpaste), head=T) # read your data table(d) # library(reshape) cast(as.data.frame(table(d)), .~Firm, fun=sum) HTH, baptiste On 4 May 2009, at 13:19, Cecilia Carmo wrote: Hi everyone: I need to count the number of banks of each firm in my data. The firm is identified by the fiscal number. The banks of each firm appears like this: Firm Banks 500600700 Citybank 500600700 CGD 500600700 BES 500600800 Citybank 500600800 Bank1 500600900 CGD … I want to obtain the following dataframe: Firmnumberofbanks 500600700 3 500600800 2 500600900 1 … This is a question of counting the times each firm appears, but I don’t know which function do this. If anyone could help me I appreciate. Thank you in advance for the help you could give me, Cecilia Carmo (Portugal) __ R-help@r-project.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.
[R] levelplot question
Hi there, I have a question concerning the behaviour of the colouring with levelplot. (I hope, I manage to explain) If I give the parameters at and col.regions like this: at - c(1,2,3,4,5,6) col.regions - c(blue,blue,blue,yellow,yellow,yellow) Which color would have the value 3.5? I would have expected yellow, no? In my more complex example I wanted to create a heatmap (like yellow to red) up to a fixed threshold. All values above should get another color (like blue). Automatically, I generated both vectors like this: at -c(vectorOfLowerValues, myThreshold, vectorOfHigherValues) col.regions - c(vectorOfHeatmapColors, lastHeatmapColor, vectorOfColorblue) But I get some values above the threshold which are not blue... Can anybody explain me why? (I've checked the length of both vectors and it's parts - this is correct - so 'myThreshold' would get 'lastHeatmapColor' by the same vector position) I'm very confused... Antje __ R-help@r-project.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] Odp: Creating a variable which is the sum of equal rows in a dataframe
Hi r-help-boun...@r-project.org napsal dne 04.05.2009 13:19:15: Hi everyone: I need to count the number of banks of each firm in my data. The firm is identified by the fiscal number. The banks of each firm appears like this: Firm Banks 500600700 Citybank 500600700 CGD 500600700 BES 500600800 Citybank 500600800 Bank1 500600900 CGD … I want to obtain the following dataframe: Firmnumberofbanks 500600700 3 500600800 2 500600900 1 … E.g. as.data.frame(rowSums(table(test))) Regards Petr This is a question of counting the times each firm appears, but I don’t know which function do this. If anyone could help me I appreciate. Thank you in advance for the help you could give me, Cecilia Carmo (Portugal) __ R-help@r-project.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] Creating a variable which is the sum of equal rows in a dataframe
Hi Cecilia, You can use table for this: #Generate a dataframe dat.df - data.frame(Firm = sample(c(500600700,500600800,500600800),6,replace=TRUE),Banks=sample(c(Citybank,CGD,DES,Bank1),6,replace=TRUE) ) #Get the counts in a table format with(dat.df, table(Firm,Banks)) Banks FirmBank1 CGD Citybank DES 500600700 0 01 0 500600800 2 11 1 #Or, if you prefer the data.frame format, you can reshape it. as.data.frame(with(dat.df, table(Firm,Banks))) FirmBanks Freq 1 500600700Bank10 2 500600800Bank12 3 500600700 CGD0 4 500600800 CGD1 5 500600700 Citybank1 6 500600800 Citybank1 7 500600700 DES0 8 500600800 DES1 Hope this helps. /Fredrik On Mon, May 4, 2009 at 1:19 PM, Cecilia Carmo cecilia.ca...@ua.pt wrote: Hi everyone: I need to count the number of banks of each firm in my data. The firm is identified by the fiscal number. The banks of each firm appears like this: Firm Banks 500600700 Citybank 500600700 CGD 500600700 BES 500600800 Citybank 500600800 Bank1 500600900 CGD … I want to obtain the following dataframe: Firm numberofbanks 500600700 3 500600800 2 500600900 1 … This is a question of counting the times each firm appears, but I don’t know which function do this. If anyone could help me I appreciate. Thank you in advance for the help you could give me, Cecilia Carmo (Portugal) __ R-help@r-project.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. -- Life is like a trumpet - if you don't put anything into it, you don't get anything out of 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.
Re: [R] clear screen?
On Mon, May 4, 2009 at 6:50 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 03/05/2009 6:50 PM, Charles Annis, P.E. wrote: I’ve been using this routine for several years. I’m sorry, I don’t remember where I got it. It works as it should, viz. it blanks the R console. But it requires package rcom and now that requires rscproxy. cls - function () { require(rcom) wsh - comCreateObject(Wscript.Shell) comInvoke(wsh, SendKeys, \f) invisible(wsh) } cls() Loading required package: rcom Loading required package: rscproxy This seems like overkill to me just to blank the R console, especially since I am trying to diminish the number of necessary packages to support my home-brew package. So, is there an easier way to blank the R console in Windows? Ctrl-L will do it. If you want to put it in a function, I don't think so. An item that has been on my wish list for a long time is to rewrite the menu system in the Windows gui so that all items can be invoked from R code. It's been sitting there in the section entitled I wish someone else would do this. It would not be hard, but it would be a lot of tedious work. Note that the same technique used to clear the screen could be used for this as well. For example, this causes the FAQ to appear by sending the appropriate set of characters to active the menu: sendKeys - function (x) { require(RDCOMClient) wsh - COMCreate(Wscript.Shell) wsh$SendKeys(x) invisible(wsh) } faq - function() sendKeys(%HF\n) faq() Might have to add some Sys.sleep calls to slow it down but so far it seems to work for me. __ R-help@r-project.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] Creating a variable which is the sum of equal rows in a dataframe
Try aggregate. First we read the data into DF and then apply aggregate: Lines - Firm Banks + 500600700 Citybank + 500600700 CGD + 500600700 BES + 500600800 Citybank + 500600800 Bank1 + 500600900 CGD # DF - read.table(myfile.dat, header = TRUE) DF - read.table(textConnection(Lines), header = TRUE) aggregate(DF[Banks], DF[Firm], length) Firm Banks 1 500600700 3 2 500600800 2 3 500600900 1 On Mon, May 4, 2009 at 7:19 AM, Cecilia Carmo cecilia.ca...@ua.pt wrote: Hi everyone: I need to count the number of banks of each firm in my data. The firm is identified by the fiscal number. The banks of each firm appears like this: Firm Banks 500600700 Citybank 500600700 CGD 500600700 BES 500600800 Citybank 500600800 Bank1 500600900 CGD … I want to obtain the following dataframe: Firm numberofbanks 500600700 3 500600800 2 500600900 1 … This is a question of counting the times each firm appears, but I don’t know which function do this. If anyone could help me I appreciate. Thank you in advance for the help you could give me, Cecilia Carmo (Portugal) __ R-help@r-project.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] About the Transfer Function Model(ARIMAX)
pages 43-54 of: http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf ... is an article by Uwe Ligges on accesssing source code. On Apr 2, 2009, at 4:20 AM, Ramanath Roy wrote: Dear ALL, I would appreciate if someone help me by letting me know the code of above model in R.I would request you to please let me know how i could make arimax model in auto.arima. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to remove ( ) ? when using write.csv(chron.object)
Hello all, I don' like to have ( ) around my datetime, when send the csv file to somebody. How to remove it? library(chron) mydate - c(2009-05-03,2009-06-07) mytime - c(10:30:00,10:20:00) mydatetime - chron(dates=mydate,times=mytime,format=c(y-m-d,h:m:s)) write.csv(mydatetime) ,x 1,(09-05-03 10:30:00) 2,(09-06-07 10:20:00) thanks! Jeff [[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] levelplot question
@Dieter: You implicitly expect round(). Your question implies that you may also susceptible to the problem of R FAQ 7.31, Why doesn't R think these numbers are equal? No, I guess, you misunderstood my question. These vectors (at and col.regions) are given to levelplot together with some data which should be visualized. I don't know how exactly levelplot works (I was asking for help to understand it) but somehow it creates something like bins from at and uses col.regions to display all datavalues within the same bin with the according color. I'd like to know, which color to expect from levelplot for a certain datavalue (3.5) Did I explain it somehow clear now? Antje __ R-help@r-project.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] Surface for R outside of R
want an analysis. The best case were a surface of e.g. 8 Buttons, each click leads to start a specific R file. My outputs are JPEG or CSV, so I don`t need the output inside of R. Could anyone can give me some recommendations, what could be a solution (e. g. Java)? Is such a solution possible? What about batch scripts which would be called by your GUI? (maybe you could even skip the gui...) (see ?Rscript (unix alike) or Windows FAQ, 2.12) -- Regards, Hans-Peter __ R-help@r-project.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 remove ( ) ? when using write.csv(chron.object)
Try: write.csv(format(mydatetime, enclosed = c(, ))) ,x 1,09-05-03 10:30:00 2,09-06-07 10:20:00 On Mon, May 4, 2009 at 10:34 AM, Qianfeng Li qflic...@yahoo.com wrote: Hello all, I don' like to have ( ) around my datetime, when send the csv file to somebody. How to remove it? library(chron) mydate - c(2009-05-03,2009-06-07) mytime - c(10:30:00,10:20:00) mydatetime - chron(dates=mydate,times=mytime,format=c(y-m-d,h:m:s)) write.csv(mydatetime) ,x 1,(09-05-03 10:30:00) 2,(09-06-07 10:20:00) thanks! Jeff [[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] Support Vector Machines
On May 4, 2009, at 8:52 AM, excalibur wrote: This question is still unanswered. Unanswered questions are often those which do not comply with the guidelines in the Posting Guide. Many people have gotten tired of either making up examples or of writing Read the Posting Guide, so they just ignore them. Someone can explain me how use the svm function to make density estimation ? If you post an executable bit of code that shows how you are doing those operations, then I suspect someone will answer. excalibur wrote: Hi, i try to use function svm of package e1071 to estimate a density. But if my data are X=(X1,...,Xn) and m-svm(X) some values of m$SV are less than 0. I don't see how i can get the estimation of the density with this function. Thanks for your help. Rémi David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Caret package: coeffcients for regression
Alex, I am using Caretpackage for SVM regression and elastic net regression . I can get the final fiited vs observed values. How can I get the coefficients? Any ideas? You didn't say what version of caret and R you are using, what kernel or what type of coefficients. If you tune a model using train: fit - train(x, y, enet) then fit$finalModel contains an enet object with the final parameters. You can use coef() or any other appropriate function on this object. In the case of the elastic net, see ?predict.enet, specifically the type argument to get the regression coefficients. If you need to get to the final tuning parameters for the model, you can access them via x$finalModel$tuneValue. There are a few exceptions to this: models using S4 classes won't allow adding new objects. For SVMs, you haven't said what kernel type you used. caret uses kernel methods from kernlab (for no other reason that I like the package). The only package that I know gives the *regression* coefficients for linear kernels is svmpath (there could be others). If you want the SV coefficients (typically denoted by alpha), kernlab has a slot called coef that you can use. You should really provide more information for your questions to be answered well. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reversing axis label order
Dear R Users, I am executing the following command to produce a line graph: matplot(aggregate_1986[,1], aggregate_1986[,2:3], type=l, col=2:3) On the x-axis I have values of Latitude (in column 1) ranging from -60 to +80 (left to right on the x-axis). However, I wish to have these values shown in reverse on the x-axis, going from +80 to -60 (ie. North to South in terms of Latitude). I have tried doing this by altering the command as follows: matplot(-aggregate_1986[,1], aggregate_1986[,2:3], type=l, col=2:3) ...but this produces the inverse sign of the latitude values along the axis - ie. it goes from -80 to +60. How do I reverse the display of the axis labels correctly and of course, maintain the associated data values correctly? Many thanks, Steve __ R-help@r-project.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] mosaic plot with two factors and one continous variable
Hello, my dataset is already aggregated: I have two categorical variables, say continent and country and one non-negative metric variable population. Now I would like to produce a mosaic plot which uses population to determine how large each area of the plot is. In other words, I fail to find out - how to use the mosaic function of the vcd package without using table, - or I do not know how to convert my dataset into a table (as.table fails) As an example, here a simple dataset: Continent; Country; Population Europe; France; 65 Europe; Germany; 80 Africa; Algeria; 32 Can you help me to get started? Kind regards, Karsten. [[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] can install.packages() copy utility files to the public_html directory ?
Dear fellow R-users, I am about to publish an HTML utility package to CRAN that expands on the R2HTML package and includes a few goodies such as sorted tables, easy automation of framed HTML reporting, etc. However, some of the resulting dynamic HTML pages need to access JavaScript code that should sit in a specific subdirectory of public_html. My more general question is hence, (i) how do I include the directory containing the JavaScript code in my R package and (ii) is it possible to copy this directory to the user's public_html path during installation ? Thanks! Markus [[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] Dynamic visualisation of R data using Adobe FLEX
Hi Yihui, In trying to make FLEX and R talk, I have decided to approach it by using the Rserver JRclient as the middle tier in a three tier approach. Tier 1: FLEX Visualisation Tier 2: JRclient (http://rosuda.org/Rserve/example.shtml) Tier 3: Rserver I have yet to begin working on this front, but would like to know what you think about this approach. I understand FLEX and JAVA communicate seamlessly and a JAVA client to communicate with Rserver seems to seal the deal for making FLEX and R talk to each other. Thanks Harsh Singhal On Sat, May 2, 2009 at 12:37 PM, Yihui Xie xieyi...@gmail.com wrote: Hi Harsh, If your project is so specific on the regression model, my suggestion is to use tcl/tk or Gtk2 interface instead of FLEX, because your requirement on interaction is simple (e.g. you don't need to drag-and-drop points). I think the example 'run.cor2.examp()' in 'TeachingDemos' package can give you enough inspiration. Or if you want to do the job (to change the slope) automatically, you may want to see the example in the 'animation' package: ## install.packages(animation) library(animation) # default animation in R: with slope changing least.squares() # animation in an HTML page oopt = ani.options(ani.height = 450, ani.width = 600, outdir = tempdir(), nmax = 50, title = Demonstration of Least Squares, description = We want to find an estimate for the slope in 50 candidate slopes, so we just compute the RSS one by one. ) ani.start() par(mar = c(4, 4, 0.5, 0.1), mgp = c(2, 0.5, 0), tcl = -0.3) least.squares() ani.stop() ani.options(oopt) ## P. S. I'm quite interested in interactive visualization using R and Flash (you may also want to know Flare and SWF Tools!), so please let me know if there's any progress in your project. 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 Thu, Apr 30, 2009 at 2:54 AM, Harsh singhal...@gmail.com wrote: Hi useRs, I had posted about Adobe FLEX talking to R for rich visualisation. Reply from Jeffery Horner contained links to the revolution-computing.com webpage which had information pertaining to the Bay Users R group Meetup on Web Dashboards with R. I have a very specific project that I need to implement. I wish to use the graphics capabilities provided by Adobe FLEX to visualise outputs from R. For example: I would like to fit a regression model to a dataset in R and provide a FLEX interface wherein, a user may manipulate a slider which would increase or decrease a parameter estimate (between the confidence intervals of the estimate) of a variable to see the effect on the predicted values. I necessarily have to use FLEX for the interface. In trying to make sense of how to go about this task, I have speculated on the following technologies: 1) Using RSOAP which requires a Python client. I am not sure how I can implement this in Flex. 2) Using RSOAP provided by the Biocep project. This is a java implementation and maybe this would suit my requirements. 3) The StatDataML package in R provides the creation of xml files of R objects. Maybe I can use these XML files as encapsulators of R object data and pass it on to FLEX. 4) Since R has interfaces that connect to most SQL database servers, I can convert results of lm objects (summary(lmobject)) to data frames and push them into the SQL database. FLEX can then read the table and extract the relevant fields for output. I am aware that I not a computer programmer which is why I may not be making a whole lot of sense in describing the above scenarios, but I am trying to gain as much information and programming skills to 'decipher' the secret behind using FLEX and R. I have looked at Jeffery Horner's BBPLOT project (http://data.vanderbilt.edu/rapache/bbplot) and honestly I'm amazed. Replicating this with a FLEX interface is the closest I can get in describing my requirements. Any information/technical sources/tutorials etc in this regard will be much appreciated. Thank you for your time. Regards Harsh Singhal Decision Systems Mu Sigma Inc. Chicago, IL __ R-help@r-project.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] can install.packages() copy utility files to the public_html directory ?
2009/5/4 Uwe Ligges lig...@statistik.tu-dortmund.de: Markus Loecher wrote: Dear fellow R-users, I am about to publish an HTML utility package to CRAN that expands on the R2HTML package and includes a few goodies such as sorted tables, easy automation of framed HTML reporting, etc. However, some of the resulting dynamic HTML pages need to access JavaScript code that should sit in a specific subdirectory of public_html. My more general question is hence, (i) how do I include the directory containing the JavaScript code in my R package and Yes, in directory ./inst/JavaScript for example that is copied to ./JavaScript during installation of the package. (ii) is it possible to copy this directory to the user's public_html path during installation ? Yes, if it is a source package (not for a binary package), BUT you should not write such code that copyies files to a directory different than the package's directory in the library that it is installed to. Things that install files to suprising locations are sometimes considered to be some kind of malware. Also not all uses of R2HTML would be for use with a web server at all. Also you can't assume the directory is public_html even if it is on a server. __ R-help@r-project.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] normality test for large a large dataset ?
Martial Sankar wrote: Do you know a R implemented normality test like the shapiro test but more suitable for large data set ? Try installing the nortest package. -- View this message in context: http://www.nabble.com/normality-test-for-large-a-large-dataset---tp23364526p23366862.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] levelplot question
Antje niederlein-rstat at yahoo.de writes: I have a question concerning the behaviour of the colouring with levelplot. If I give the parameters at and col.regions like this: at - c(1,2,3,4,5,6) col.regions - c(blue,blue,blue,yellow,yellow,yellow) Which color would have the value 3.5? I would have expected yellow, no? You implicitly expect round(). [1] blue col.regions[3.5] [1] blue col.regions[round(3.5)] [1] yellow Your question implies that you may also susceptible to the problem of R FAQ 7.31, Why doesn't R think these numbers are equal? 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] Need to clean a table, and compute mean and SD
Thom_249 wrote: Hi For a school project I have a file with 120 columns and ~2000 lines. This file contains timestamps of spike detected in 60 channels, and the time elapsed between the last spike. I need to clean too high values. About 98% of values are between 0 and 2000 and 2% are between 2000 and 20'000. I want to get rid of theses values. Please could you help me? Regards Thom Hi, If you are dealing with a data frame, you can simply use the index function like this, my.data.frame[my.data.frame2000] = NA This way, all values in your data.frame that are greater than 2000 will be transformed into NAs. However, this kind of substitution wouldn't be recommended if your goal is to fit a regression model to the data. Missing data can sometimes be informative, hence the importance to be careful when doing such substitutions. -- *Luc Villandré* __ R-help@r-project.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] Reversing axis label order
Dear Steve, I'm not sure I properly understood the question. Try x- aggregate_1986 # just a shortcut n- dim(x)[[1]] matplot(x[n:1,1], x[n:1,2:3], type=l, col=2:3) is that what you needed? Patrizio 2009/5/4 Steve Murray smurray...@hotmail.com: Dear R Users, I am executing the following command to produce a line graph: matplot(aggregate_1986[,1], aggregate_1986[,2:3], type=l, col=2:3) On the x-axis I have values of Latitude (in column 1) ranging from -60 to +80 (left to right on the x-axis). However, I wish to have these values shown in reverse on the x-axis, going from +80 to -60 (ie. North to South in terms of Latitude). I have tried doing this by altering the command as follows: matplot(-aggregate_1986[,1], aggregate_1986[,2:3], type=l, col=2:3) ...but this produces the inverse sign of the latitude values along the axis - ie. it goes from -80 to +60. How do I reverse the display of the axis labels correctly and of course, maintain the associated data values correctly? Many thanks, Steve __ R-help@r-project.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. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frede...@unimore.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.
Re: [R] mosaic plot with two factors and one continous variable
On Mon, 4 May 2009, Karsten Weinert wrote: Hello, my dataset is already aggregated: I have two categorical variables, say continent and country and one non-negative metric variable population. Now I would like to produce a mosaic plot which uses population to determine how large each area of the plot is. In other words, I fail to find out - how to use the mosaic function of the vcd package without using table, - or I do not know how to convert my dataset into a table (as.table fails) As an example, here a simple dataset: Continent; Country; Population Europe; France; 65 Europe; Germany; 80 Africa; Algeria; 32 Can you help me to get started? You can create the tables by xtabs(Population ~ Continent, data = mydata) etc. which can then be visualized using mosaic() in the usual way. hth, Z Kind regards, Karsten. [[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] Support Vector Machines
This question is still unanswered. Someone can explain me how use the svm function to make density estimation ? Thanks ... excalibur wrote: Hi, i try to use function svm of package e1071 to estimate a density. But if my data are X=(X1,...,Xn) and m-svm(X) some values of m$SV are less than 0. I don't see how i can get the estimation of the density with this function. Thanks for your help. Rémi -- View this message in context: http://www.nabble.com/Support-Vector-Machines-tp19069442p23366761.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] Zelig, oprobit error
Hello, I'm getting an error message when I use the ordered probit model oprobit in the zelig function. Using the same form as in the help file, we get an error message. It produces coefficients, but no standard errors. See results below. Any hints? Thanks! o.probit - zelig(as.factor(checks.change) ~ Oda + Oil + sh_neg + sh_pos + checks1, model=oprobit, data=data.all) summary(o.probit) Error in svd(X) : infinite or missing values in 'x' o.probit$coefficients OdaOil sh_neg sh_poschecks1 2.858e-02 1.978e-07 -1.961e-02 4.810e-02 8.492e-02 __ R-help@r-project.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] Handling Error Thrown After source(...), read.table(...), and readLines(...)
Finally, I'm getting to a point in working with R where I would like to start to add some smart and custom error handling. Specifically, I would like to add custom error handling to my code for source(...), read.table(...), and readLines(...) For example, right now I have the following: postprocesspath-c(C:/) postprocess_scriptname-c(Bob.R) fullpostpocessingpath-paste(postprocesspath, postprocess_scriptname, sep=) source(fullpostpocessingpath) Error in file(file, r, encoding = encoding) : cannot open the connection In addition: Warning message: In file(file, r, encoding = encoding) : cannot open file 'C:/Bob.R': No such file or directory Instead of the error shown above, I would just like to simply have the last line cannot open file 'C:/Bob.R': No such file or directory Or, add my own statement to the above, e.g. ## ## [[elided Yahoo spam]] ## ## I would like to do something similar for read.table(...) and readLines(...). Is such a thing possible? Thanks again. __ R-help@r-project.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] normality test for large a large dataset ?
See: http://finzi.psych.upenn.edu/R/Rhelp08/archive/136160.html But the issue really comes down to the fact that the questions: exactly normal?, and normal enough? are 2 very different questions (with the difference becoming greater with increased sample size) and while the first is the easier to answer, the second is generally the more useful one. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Martial Sankar Sent: Monday, May 04, 2009 1:49 AM To: rhelp Subject: [R] normality test for large a large dataset ? Hello, Do you know a R implemented normality test like the shapiro test but more suitable for large data set ? Thanks, _ Découvrez toutes les possibilités de communication avec vos proches [[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] Cox Proportional Odds Model
Is there a function, like coxph for the proportional hazard model, for fitting a discrete-time proportional odds model? -- View this message in context: http://www.nabble.com/Cox-Proportional-Odds-Model-tp23373426p23373426.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] Code of the max() function
Dear All, Where can one find the code of the max() function? Is that written in C? Thanks in advance, Paul __ R-help@r-project.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_if command_new column
Hi everyone, Do you know how to apply a If command to a vector in a data.frame, creating a new column? Example: If one species has 1 value in the Abundance column then it is Solitary. If the abundance is higher than 1, is School. I did: aggregationFunction -function(x){ (if (x1) a- 'School' else a- 'Solitary') return (a) } Then: Aggregation - lapply (df$Number, aggregationFunction ) Then: df - data.frame (df, Aggregation) And I got this error: Error in data.frame(df, Aggregation) : arguments imply differing number of rows: 2576, 1 Can you help me doing this function to a vector? Ive tried to find this question and the answer online but I couldn't. I tried also only with if but it is only for 1 length and the error was: the condition has length 1 and only the first element will be used This question seemed easy in the beginning but I was not successful. Thanks a lot for helping me. Barbara -- Bárbara H. Costa Marine Biologist Researcher SCIAENA - Marine Sciences and Cooperation www.sciaena.org bco...@ispa.pt barbarahco...@gmail.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.
[R] Java-R
Dear R user We would be interested to talk with someone, living in Milan (Italy) area, with good experience in Java-R based applications development. We can provide good R skills but we are poor java programmers Can anyone help? Thanks in advance for any help -- Andrea Spano' Quantide s.r.l. andrea.sp...@quantide.com Il messaggio trasmesso può contenere informazioni di carattere confidenziale rivolte esclusivamente al destinatario. Ne è vietato l'uso, l diffusione, la distribuzione o la riproduzione da parte di altre persone e/o entità diverse da quelle specificate. Nel caso aveste ricevuto questo messaggio per errore siete pregati di segnalarlo immediatamente al mittente e cancellare quanto ricevuto. This electronic mail transmission may contain confidential information addressed only to the person (s) named. Any use, distribution, copyng or disclosure by any other person and/or entities other than the intended recipient is prohibited. If you received this transmission in error, please inform the sender immediately and delete the material. __ R-help@r-project.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] Hierarchical Diagram of Networks in sna or otherwise?
Nearly. The algorithm turns up slightly different graphs each time (and set.seed doesn't seem to make it consistent) and periodically chokes. But better than what I had. Hrm. I don't know much about the algorithm graphviz uses for dot. Do you have a reference on hand? If it's simple, I'd be willing to take a whack at it. Gábor Csárdi-2 wrote: Jarrett, the 'igraph' package has a layout called layout.reingold.tilford that is designed for trees, there is a slight chance that it is good enough for you. Best, Gabor On Wed, Apr 29, 2009 at 10:11 PM, jebyrnes byr...@msi.ucsb.edu wrote: I've been using sna to work with some networks, and am trying to visualize them easily. My networks are hierarchical (food webs). All of the layout engines I've tried with gplot don't seem to plot hierarchical networks, as one would using dot from graphviz. While I could do all of this by outputting to dotfiles and running it through graphviz, the graphics I get from R are much cleaner, and more easily integrated into my analyses. Is there any good way to diagram a hierarchical network in R, either with the sna library or otherwise? It strikes me that at least the Netindices package can calculate trophic levels. Could this be used for node placement? -Jarrett -- View this message in context: http://www.nabble.com/Hierarchical-Diagram-of-Networks-in-sna-or-otherwise--tp23301819p23301819.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. -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Hierarchical-Diagram-of-Networks-in-sna-or-otherwise--tp23301819p23374024.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] help_if command_new column
You should be looking at the ifelse function. Ihe if and else constructs are not appropriate for recoding because they do not return vectors. Much easier than all that folderol would be: df$Aggregation - ifelse( df$Number1, School, Solitary) On May 4, 2009, at 12:31 PM, barbara horta e costa wrote: Hi everyone, Do you know how to apply a If command to a vector in a data.frame, creating a new column? Example: If one species has 1 value in the Abundance column then it is Solitary. If the abundance is higher than 1, is School. I did: aggregationFunction -function(x){ (if (x1) a- 'School' else a- 'Solitary') return (a) } Then: Aggregation - lapply (df$Number, aggregationFunction ) Then: df - data.frame (df, Aggregation) And I got this error: Error in data.frame(df, Aggregation) : arguments imply differing number of rows: 2576, 1 Can you help me doing this function to a vector? Ive tried to find this question and the answer online but I couldn't. I tried also only with if but it is only for 1 length and the error was: the condition has length 1 and only the first element will be used This question seemed easy in the beginning but I was not successful. Thanks a lot for helping me. Barbara -- Bárbara H. Costa Marine Biologist Researcher SCIAENA - Marine Sciences and Cooperation www.sciaena.org bco...@ispa.pt barbarahco...@gmail.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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Surface for R outside of R
Hi Koj, I just completed a Windows application using the batch approach and it works very well. In our case, we used VBA for Excel to call different batch files that execute R code, but you can do the same from any platform. Here is a simple step-by-step example on how to make the batch files work (in Windows): 1. Write your R code and save it the directory where you want your results. Here is a very simple example using a file called normal.r. This code takes 100 random samples from a standard normal and writes the results to a file called data.txt write(rnorm(100),data.txt) q(save=no, runLast = F) 2. Make sure that the console finds the path to R without changing your path environment variable. The easiest way to do this is to download the batchfiles that Gabor Grothendieck has kindly provided in this site http://code.google.com/p/batchfiles/ and put one or all of the files in the same directory where your batch and R files will reside. The only file I have needed so far in different WinXP and Vista machines was Rcmd.bat but you may need to use others. 3. Open a text editor and create a file with a .bat or .cmd extension. Here is an example of a file called TestBatch.CMD that runs the code in normal.r @ECHO OFF title Random number generation ECHO Taking 100 random samples from a N(0,1) Rcmd BATCH --slave normal.r Log.txt ECHO Analysis done. See the file data.txt for results PING 1.1.1.1 -n 1 -w 1000 NUL @ECHO OFF The main line here is Rcmd BATCH --slave normal.r Log.txt which tells the console to run your R code, and to write outputs printed in the console (i.e. errors) to the Log.txt file. The PING argument adds a short lag before the console closes, so the user can see what is echoed in the console. The other lines should be pretty self-explanatory. 4. Execute the TestBatch.CMD file (by hand or via your GUI) and watch the results. You should now see two new files (data.txt and Log.txt) in the same directory as the batch file. I hope this helps. Let me know if you have any other questions. Regards, Francisco Francisco J. Zagmutt Vose Consulting 2891 20th Street Boulder, CO, 80304 USA www.voseconsulting.com Hans-Peter Suter wrote: want an analysis. The best case were a surface of e.g. 8 Buttons, each click leads to start a specific R file. My outputs are JPEG or CSV, so I don`t need the output inside of R. Could anyone can give me some recommendations, what could be a solution (e. g. Java)? Is such a solution possible? What about batch scripts which would be called by your GUI? (maybe you could even skip the gui...) (see ?Rscript (unix alike) or Windows FAQ, 2.12) -- Regards, Hans-Peter __ R-help@r-project.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] Nelson-Aalen estimator of cumulative hazard
Hi, I figure out the reason for the difference. There are ties in failure times in the data set. Consequently, it matters which method is used to handle ties in coxph. The default is efron. If I use method=breslow, there is no difference between the 2 different ways of computing the Nelson-Aalen estimte. require(foreign) gb - read.dta(GB.dta) # Green Byar data; N = 483 # Method 1 (note the use of Breslow estimator) fit1 - coxph( Surv(time, status==Cancer | status==CVD | status==Other) ~ 1, method=breslow, data=gb) h1 - basehaz(fit1) # Method 2 fit2 - survfit(Surv(time, status==Cancer | status==CVD | status==Other) ~ 1, data=gb) jump - fit2$n.event 0 h2 - cumsum(fit2$n.event[jump]/fit2$n.risk[jump]) min(abs(h1$hazard - h2)) [1] 1.387779e-17 Best, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Varadhan Sent: Monday, May 04, 2009 12:33 AM To: r-help@r-project.org Subject: [R] Nelson-Aalen estimator of cumulative hazard Hi, I am computing the Nelson-Aalen (NA) estimate of baseline cumulative hazard in two different ways using the survival package. I am expecting that they should be identical. However, they are not. Their difference is a monotonically increasing with time. This difference is probably not large to make any impact in the application, but is annoyingly non-trivial for me to just ignore it. This is a competing risks problem, with the Green Byar (1980) data set (the STATA data set is attached). Can anyone explain to me the reason for the discrepancy? require(foreign) gb - read.dta(GB.dta) # Green Byar data; N = 483 # Method 1 fit1 - coxph( Surv(time, status==Cancer | status==CVD | status==Other) ~ 1, data=gb) h1 - basehaz(fit1) # Method 2 fit2 - survfit(Surv(time, status==Cancer | status==CVD | status==Other) ~ 1, data=gb) jump - fit2$n.event 0 h2 - cumsum(fit2$n.event[jump]/fit2$n.risk[jump]) plot(h1$time, h1$hazard - h2) Thank you, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu __ R-help@r-project.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] Producing a legend successfullly
Dear all, I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using: legend(80,1150, c(Simulation, Observation, lty=1:2, col=2:3) How do I go about displaying a red solid line next to 'Simulation' and a green dashed line next to 'Observation' (and if necessary, remove the numbers that are currently displayed)? Many thanks for any help offered, Steve __ R-help@r-project.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] ellipsis problem
Hi, I'm confused about the use of ellipsis in function arguments. I'm trying to write a wrapper for plot to automate the combination of plot() and points() calls for a data.frame. Some arguments seem to get passed through to the inner plot, while others cause an error: Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in As a minimal example: tmp - data.frame(Y = sample(1:10, 40, replace = TRUE), X = sample(1:10, 40, replace = TRUE)) myplot - function(x, ...) { plot(Y ~ X, data = x, ...) } myplot(tmp) ## works fine myplot(tmp, tcl = 1) ## works fine myplot(tmp, tcl = -0.1) Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in myplot(tmp, mgp = c(3, 0.5, 0)) Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in plot(Y ~ X, data = tmp, mgp = c(3, 0.5, 0)) ## works plot(Y ~ X, data = tmp, tcl = -0.1) ## works What am I doing wrong? Thanks, Tyler R version 2.8.1 (2008-12-22) Debian Testing -- What is wanted is not the will to believe, but the will to find out, which is the exact opposite. --Bertrand Russell __ R-help@r-project.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] Code of the max() function
On May 4, 2009, at 2:06 PM, Paul Smith wrote: Dear All, Where can one find the code of the max() function? Is that written in C? pages 43-54 of: http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf ... is an article by Uwe Ligges on accesssing source code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] frontier 0.99 is NOT backward compatible
Dear current (and future) users of the frontier package, We are approaching the first stable version (1.0) of the frontier package, which provides tools for microeconomic Stochastic Frontier Analysis (SFA). I have uploaded a kind of beta release (version 0.99) of this package to CRAN. The most important differences to version 0.9 affect the user interface. I have modified the package so that it is (hopefully) simpler to use and the functions are more similar to other R functions. Unfortunately, these changes make the new version NOT backward compatible. The most significant changes are reported below. A full ChangeLog is available in the log messages of the SVN repository on R-Forge [1]. Feedback about this package is highly appreciated. Please report any bugs, suggestions, feature requests, comments, and questions in the forums and trackers on R-Forge [1]. [1] http://r-forge.r-project.org/projects/frontier/ Best regards, Arne CHANGES IN VERSION 0.99-0 * corrected and considerably improved documentation of function fontier * changed order of arguments of function frontier * removed arguments crossSectionName and timePeriodName from function frontier: in case of cross-section data, these variables (information) are not needed, and in case of panel data, the information on the panel structure has to be added to the data set by the function plm.data of the plm package * argument modelType of function frontier must be ECF or EEF now * replaced argument funtionType of function frontier by argument ineffDecrease * renamed argument eta of function frontier as timeEffect * split argument mu of function frontier into truncNorm and zIntercept * increased default value of argument maxit of function frontier to 1000 * renamed argument step1 of function frontier as searchStep * renamed argument tol2 of function frontier as searchTol * replaced argument indic of function frontier by searchScale * renamed argument gridno of function frontier as gridSize * renamed argument igrid2 of function frontier as gridDouble * renamed argument iprint of function frontier as printIter * removed arguments qxNames and quadHalf from function frontier, because quadratic or translog frontiers can be estimated with function frontierQuad now * added logLik method for objects of class frontier * added function frontierQuad for estimating quadratic and translog frontiers * added function frontierTranslogRay for estimating stochastic ray translog frontier functions * added the generic function efficiencies and corresponding methods for default objects and objects of class frontier * added elas method for objects of class frontierQuad * function frontier() and frontierQuad() return the (matched) call now * the matrix of efficiency estimates returned by frontier has row names (cross section units) and possibly column names (time period) now -- Arne Henningsen http://www.arne-henningsen.name/ ___ 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] rotate texts
Hi all, I'm hoping to add texts into a plot. I'm using text() to do it. I wonder if the text() allow me to make the text vertically printed? Thanks in advance for help, phoebe [[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] Hierarchical Diagram of Networks in sna or otherwise?
Jarrett, At 11:31 AM -0700 5/4/09, jebyrnes wrote: Nearly. The algorithm turns up slightly different graphs each time (and set.seed doesn't seem to make it consistent) and periodically chokes. But better than what I had. Hrm. I don't know much about the algorithm graphviz uses for dot. Do you have a reference on hand? If it's simple, I'd be willing to take a whack at it. Gábor Csárdi-2 wrote: Jarrett, the 'igraph' package has a layout called layout.reingold.tilford that is designed for trees, there is a slight chance that it is good enough for you. Best, Gabor On Wed, Apr 29, 2009 at 10:11 PM, jebyrnes byr...@msi.ucsb.edu wrote: I've been using sna to work with some networks, and am trying to visualize them easily. My networks are hierarchical (food webs). All of the layout engines I've tried with gplot don't seem to plot hierarchical networks, as one would using dot from graphviz. While I could do all of this by outputting to dotfiles and running it through graphviz, the graphics I get from R are much cleaner, and more easily integrated into my analyses. Is there any good way to diagram a hierarchical network in R, either with the sna library or otherwise? It strikes me that at least the Netindices package can calculate trophic levels. Could this be used for node placement? -Jarrett If you like the dot output from graphviz you can get that using Rgraphviz from bioconductor. Although somewhat difficult to install, once installed it works beautifully. Bill -- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Attend ISSID/ARP:2009 http://issid.org/issid.2009/ __ R-help@r-project.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] Surface for R outside of R
Also see Rscript.bat in the same batchfiles distribution. It automatically finds Rscript.exe by looking in the registry in the same way that Rcmd.bat finds Rcmd.exe. On Mon, May 4, 2009 at 2:43 PM, Francisco J. Zagmutt gerifalt...@hotmail.com wrote: Hi Koj, I just completed a Windows application using the batch approach and it works very well. In our case, we used VBA for Excel to call different batch files that execute R code, but you can do the same from any platform. Here is a simple step-by-step example on how to make the batch files work (in Windows): 1. Write your R code and save it the directory where you want your results. Here is a very simple example using a file called normal.r. This code takes 100 random samples from a standard normal and writes the results to a file called data.txt write(rnorm(100),data.txt) q(save=no, runLast = F) 2. Make sure that the console finds the path to R without changing your path environment variable. The easiest way to do this is to download the batchfiles that Gabor Grothendieck has kindly provided in this site http://code.google.com/p/batchfiles/ and put one or all of the files in the same directory where your batch and R files will reside. The only file I have needed so far in different WinXP and Vista machines was Rcmd.bat but you may need to use others. 3. Open a text editor and create a file with a .bat or .cmd extension. Here is an example of a file called TestBatch.CMD that runs the code in normal.r @ECHO OFF title Random number generation ECHO Taking 100 random samples from a N(0,1) Rcmd BATCH --slave normal.r Log.txt ECHO Analysis done. See the file data.txt for results PING 1.1.1.1 -n 1 -w 1000 NUL @ECHO OFF The main line here is Rcmd BATCH --slave normal.r Log.txt which tells the console to run your R code, and to write outputs printed in the console (i.e. errors) to the Log.txt file. The PING argument adds a short lag before the console closes, so the user can see what is echoed in the console. The other lines should be pretty self-explanatory. 4. Execute the TestBatch.CMD file (by hand or via your GUI) and watch the results. You should now see two new files (data.txt and Log.txt) in the same directory as the batch file. I hope this helps. Let me know if you have any other questions. Regards, Francisco Francisco J. Zagmutt Vose Consulting 2891 20th Street Boulder, CO, 80304 USA www.voseconsulting.com Hans-Peter Suter wrote: want an analysis. The best case were a surface of e.g. 8 Buttons, each click leads to start a specific R file. My outputs are JPEG or CSV, so I don`t need the output inside of R. Could anyone can give me some recommendations, what could be a solution (e. g. Java)? Is such a solution possible? What about batch scripts which would be called by your GUI? (maybe you could even skip the gui...) (see ?Rscript (unix alike) or Windows FAQ, 2.12) -- Regards, Hans-Peter __ R-help@r-project.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] Producing a legend successfullly
Steve Murray smurray...@hotmail.com wrote I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using: legend(80,1150, c(Simulation, Observation, lty=1:2, col=2:3) You've got mismatched parentheses here, with two ( and only one ). I suspect you added one at the end, making r look at lty= and col = as part of the legend text. You want legend(80,1150, c(Simulation, Observation), lty=1:2, col=2:3) HTH Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT 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] Producing a legend successfullly
This works for me: plot(1:10, 1:10) legend(topleft, c(Simulation, Observation), lty=1:2, col=2:3) Try that; if it does work, then we need more information about exactly what you're doing, because there's a problem not contained in just that single line of code (which has a problem of its own!). Sarah On Mon, May 4, 2009 at 2:46 PM, Steve Murray smurray...@hotmail.com wrote: Dear all, I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using: legend(80,1150, c(Simulation, Observation, lty=1:2, col=2:3) How do I go about displaying a red solid line next to 'Simulation' and a green dashed line next to 'Observation' (and if necessary, remove the numbers that are currently displayed)? -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.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] Producing a legend successfullly
Dear Steve, Try this: x-rnorm(100) y-rnorm(100) + 2*x plot(x,y) legend('topleft', c(Simulation, Observation), lty=1:2, col=2:3) abline(x,y,col=3,lty=2) (you forgot a ) in your code :( ) HTH, Jorge On Mon, May 4, 2009 at 2:46 PM, Steve Murray smurray...@hotmail.com wrote: Dear all, I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using: legend(80,1150, c(Simulation, Observation, lty=1:2, col=2:3) How do I go about displaying a red solid line next to 'Simulation' and a green dashed line next to 'Observation' (and if necessary, remove the numbers that are currently displayed)? Many thanks for any help offered, Steve __ R-help@r-project.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] ellipsis problem
On 5/4/2009 2:55 PM, tyler wrote: Hi, I'm confused about the use of ellipsis in function arguments. I'm trying to write a wrapper for plot to automate the combination of plot() and points() calls for a data.frame. Some arguments seem to get passed through to the inner plot, while others cause an error: This looks like another manifestation of the following bug: o The ... argument was not handled properly when ... was found in the enclosure of the current function, rather than in the function header itself. (This caused integrate() to fail in certain cases.) which has recently been fixed in R-patched. I haven't traced through it, but I do see the same error as you in 2.9.0, but not in 2.9.0 patched. Duncan Murdoch Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in As a minimal example: tmp - data.frame(Y = sample(1:10, 40, replace = TRUE), X = sample(1:10, 40, replace = TRUE)) myplot - function(x, ...) { plot(Y ~ X, data = x, ...) } myplot(tmp) ## works fine myplot(tmp, tcl = 1) ## works fine myplot(tmp, tcl = -0.1) Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in myplot(tmp, mgp = c(3, 0.5, 0)) Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in plot(Y ~ X, data = tmp, mgp = c(3, 0.5, 0)) ## works plot(Y ~ X, data = tmp, tcl = -0.1) ## works What am I doing wrong? I think the only thing you are doing wrong is not keeping up to date with the latest patches. Duncan Murdoch Thanks, Tyler R version 2.8.1 (2008-12-22) Debian Testing __ R-help@r-project.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] Code of the max() function
On Mon, May 4, 2009 at 7:47 PM, David Winsemius dwinsem...@comcast.net wrote: Where can one find the code of the max() function? Is that written in C? pages 43-54 of: http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf ... is an article by Uwe Ligges on accesssing source code. Thanks, David. That is it! Paul __ R-help@r-project.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] Producing a legend successfullly
your code is missing a closing bracket for the text labels, legend(1,4, c(Simulation, Observation), lty=1:2, col=2:3) baptiste On 4 May 2009, at 20:46, Steve Murray wrote: Dear all, I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using: legend(80,1150, c(Simulation, Observation, lty=1:2, col=2:3) How do I go about displaying a red solid line next to 'Simulation' and a green dashed line next to 'Observation' (and if necessary, remove the numbers that are currently displayed)? Many thanks for any help offered, Steve __ R-help@r-project.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] rotate texts
On May 4, 2009, at 3:04 PM, phoebe kong wrote: Hi all, I'm hoping to add texts into a plot. I'm using text() to do it. I wonder if the text() allow me to make the text vertically printed? This worked in a plot I hapened to have lying around: text(1,1,test, srt=90) David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Calculating relative ratios in a data frame..
I have a data-set that is structured as follows: spwgn v.realtime v.cputime v.tcputime v.idletime v.nswtch 9 0 11 28.61300 28.6128.6039 0.0e+00 407 1563 0 12 15.20270 30.3828.5981 9.80523e-01 483 3128 0 14 12.50930 50.0028.6053 1.07877e+01 489 4682 0 16 12.10260 72.5528.6193 2.20203e+01 488 6241 0 18 12.11510 96.8028.6448 3.41126e+01 494 121 0101 28.61530 28.6028.6056 0.0e+00 1996 1684 0102 14.33530 28.6628.6003 2.96437e-02 1908 3241 01047.27129 29.0528.6002 2.31302e-01 2110 4801 01064.91522 29.4228.6002 4.25931e-01 2134 6367 01083.79337 30.2528.6032 8.42412e-01 2245 [And a lot of other variables, and sp also changes] Now, I want to divide each of the v.* variables for every (sp, wg, n) combination by the values in the row defined by (sp, wg, 1), thus giving a relative change to the case n==1 for the same combination of sp and wg. I have written the following function, but I'm wondering whether there's an easier/more efficient way.. Perhaps by organizing the data structure differently, and if so -- how? speedup.1 - function(df) { groups - split(df, df[,c(sp,wg)]) ret - list() for(g in groups) { ref - g[1,] for(v in 4:15) # sp,wg,n are factors, so / doesn't work.. g[[v]] - ref[[v]] / g[[v]] ret - rbind(ret, g) } ret } __ R-help@r-project.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] sm.density.compare
I've been using the sm.denstiy.compare function and would like to know some specifics: a) What kind of bootstrap sampling is used, with or without replacement? b) A p-value is returned after running the following script (for example): library(sm) y - rnorm(100) g - rep(1:2, rep(50,2)) sm.density.compare(y, g, model=equal) to what statistic does this p-value correspond? c) Also, in the help file this description appears for Value of sm.density.compareomparison of univariate density estimates When model is set to none, nothing is returned. When model is set to equal, a list containing the smoothing parameter and the p-value of the test is returned. When band takes the value TRUE, and there are only two groups to compare, the list contains in addition the upper and lower end-points of the reference band for equality. however, the mentioned list is not returned when I run the analysis... only the p-value is returned. Am I doing something wrong? Any help is appreciated. Thank you, Claudia [[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] to the person who asked about dividing by the base row
to whomever that was. i deleted your email but I think below does what you want. as always, there's probably some improvement that could be done. whether it's  minor or major, i'm not sure ? also, 3 things:  A)there are some Inf's in the output because of division by zero but I wasn't sure how you wanted to handle that. B) it also assumes that an n=1 always exists and you should probably have some error checking in there for when it doesn't. C) When i tried to condense it to below, I got an error that division is only valid for equal sized data frames and I'm not sure why so maybe someone can say something about that ? temp - lapply(split(DF,list(DF$sp,DF$wg)), function(.df) {    .df[(.df$n!=1),c(3,4,5,6,7)]- .df[(.df$n != 1),c(3,4,5,6,7)]/.df[(.df$n == 1),c(3,4,5,6,7)]    .df }) # WORKING CODE #===  DF - read.table(textConnection(sp wg n v.realtime v.cputime v.tcputime v.idletime v.nswtch 9 0 1 1 28.61300 28.61 28.6039 0.0e+00 407 1563 0 1 2 15.20270 30.38 28.5981 9.80523e-01 483 3128 0 1 4 12.50930 50.00 28.6053 1.07877e+01 489 4682 0 1 6 12.10260 72.55 28.6193 2.20203e+01 488 6241 0 1 8 12.11510 96.80 28.6448 3.41126e+01 494 121 0 10 1 28.61530 28.60 28.6056 0.0e+00 1996 1684 0 10 2 14.33530 28.66 28.6003 2.96437e-02 1908 3241 0 10 4 7.27129 29.05 28.6002 2.31302e-01 2110 4801 0 10 6 4.91522 29.42 28.6002 4.25931e-01 2134 6367 0 10 8 3.79337 30.25 28.6032 8.42412e-01 2245),header=TRUE) print(DF) temp - lapply(split(DF,list(DF$sp,DF$wg)), function(.df) {   Â.df$v.realtime[.df$n != 1] - .df$v.realtime[.df$n != 1]/.df$v.realtime[.df$n == 1]   Â.df$v.cputime[.df$n != 1] - .df$v.cputime[.df$n != 1]/.df$v.cputime[.df$n == 1]   Â.df$v.tcputime[.df$n != 1] - .df$v.tcputime[.df$n != 1]/.df$v.tcputime[.df$n == 1]   Â.df$v.idletime[.df$n != 1] - .df$v.idletime[.df$n != 1]/.df$v.idletime[.df$n == 1]    .df$v.nswtch[.df$n!= 1] - .df$v.nswtch[.df$n != 1]/.df$v.nswtch[.df$n == 1]    .df }) result - do.call(rbind,temp) rownames(result) - NULL print(result) __ R-help@r-project.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] Calculating relative ratios in a data frame..
Here is a way -- you are dividing by zero in the scaling: x sp wg n v.realtime v.cputime v.tcputime v.idletime v.nswtch 9 0 1 1 28.61300 28.6128.6039 0.000 407 1563 0 1 2 15.20270 30.3828.5981 0.9805230 483 3128 0 1 4 12.50930 50.0028.6053 10.7877000 489 4682 0 1 6 12.10260 72.5528.6193 22.0203000 488 6241 0 1 8 12.11510 96.8028.6448 34.1126000 494 121 0 10 1 28.61530 28.6028.6056 0.000 1996 1684 0 10 2 14.33530 28.6628.6003 0.0296437 1908 3241 0 10 47.27129 29.0528.6002 0.2313020 2110 4801 0 10 64.91522 29.4228.6002 0.4259310 2134 6367 0 10 83.79337 30.2528.6032 0.8424120 2245 x.s - split(x, x[,1:2]) x.result - do.call(rbind, lapply(x.s, function(.sec){ + # create matrix of data to scale + .mat - as.matrix(.sec[, -(1:3)]) + # need to transpose due to recycle of arguments + .mat - t(t(.mat) / .mat[1,]) + .sec[, -(1:3)] - as.data.frame(.mat) + .sec + })) x.result sp wg n v.realtime v.cputime v.tcputime v.idletime v.nswtch 0.1.9 0 1 1 1.000 1.00 1.000NaN 1.000 0.1.1563 0 1 2 0.5313214 1.061866 0.9997972Inf 1.1867322 0.1.3128 0 1 4 0.4371894 1.747641 1.489Inf 1.2014742 0.1.4682 0 1 6 0.4229756 2.535827 1.0005384Inf 1.1990172 0.1.6241 0 1 8 0.4234124 3.383432 1.0014299Inf 1.2137592 0.10.121 0 10 1 1.000 1.00 1.000NaN 1.000 0.10.1684 0 10 2 0.5009663 1.002098 0.9998147Inf 0.9559118 0.10.3241 0 10 4 0.2541050 1.015734 0.9998112Inf 1.0571142 0.10.4801 0 10 6 0.1717689 1.028671 0.9998112Inf 1.0691383 0.10.6367 0 10 8 0.1325644 1.057692 0.161Inf 1.1247495 On Mon, May 4, 2009 at 3:41 PM, Zeljko Vrba zv...@ifi.uio.no wrote: I have a data-set that is structured as follows: spwgn v.realtime v.cputime v.tcputime v.idletime v.nswtch 9 0 11 28.61300 28.6128.6039 0.0e+00 407 1563 0 12 15.20270 30.3828.5981 9.80523e-01 483 3128 0 14 12.50930 50.0028.6053 1.07877e+01 489 4682 0 16 12.10260 72.5528.6193 2.20203e+01 488 6241 0 18 12.11510 96.8028.6448 3.41126e+01 494 121 0101 28.61530 28.6028.6056 0.0e+00 1996 1684 0102 14.33530 28.6628.6003 2.96437e-02 1908 3241 01047.27129 29.0528.6002 2.31302e-01 2110 4801 01064.91522 29.4228.6002 4.25931e-01 2134 6367 01083.79337 30.2528.6032 8.42412e-01 2245 [And a lot of other variables, and sp also changes] Now, I want to divide each of the v.* variables for every (sp, wg, n) combination by the values in the row defined by (sp, wg, 1), thus giving a relative change to the case n==1 for the same combination of sp and wg. I have written the following function, but I'm wondering whether there's an easier/more efficient way.. Perhaps by organizing the data structure differently, and if so -- how? speedup.1 - function(df) { groups - split(df, df[,c(sp,wg)]) ret - list() for(g in groups) { ref - g[1,] for(v in 4:15) # sp,wg,n are factors, so / doesn't work.. g[[v]] - ref[[v]] / g[[v]] ret - rbind(ret, g) } ret } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can install.packages() copy utility files to the public_html directory ?
Markus Loecher wrote: Dear fellow R-users, I am about to publish an HTML utility package to CRAN that expands on the R2HTML package and includes a few goodies such as sorted tables, easy automation of framed HTML reporting, etc. However, some of the resulting dynamic HTML pages need to access JavaScript code that should sit in a specific subdirectory of public_html. My more general question is hence, (i) how do I include the directory containing the JavaScript code in my R package and Yes, in directory ./inst/JavaScript for example that is copied to ./JavaScript during installation of the package. (ii) is it possible to copy this directory to the user's public_html path during installation ? Yes, if it is a source package (not for a binary package), BUT you should not write such code that copyies files to a directory different than the package's directory in the library that it is installed to. Things that install files to suprising locations are sometimes considered to be some kind of malware. Uwe Ligges Thanks! Markus [[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] ellipse
Dear all, I'm using the ellipse package and I would like to verify if the confidence region that I build with this package can be equivalent to an Union Intersection Test. I used different value for the t-statistic but I can not find the right equivalence. Does someone know how to choose the right value? Thanks a lot. Antonio -- Antonio Lucadamo, Dipartimento di Scienze Economiche e Metodi Quantitativi Università del Piemonte Orientale A. Avogadro via Perrone, 18 - 28100 Novara fax: +39 0321 375305 phone:+39 0321 375338 mobile phone: +39 3385973881 skype contact: antonio.lucadamo __ R-help@r-project.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] A variation on the bar plot
Hi all, I cannot think of the technical name of this plot, but I want to create a plot with the data below that looks like two back-to-back horizontal bar plots. Ideally, there would be a vertical line in the center of the plot at zero, and on the right hand side would be 4 bars representing the values for 2007, and on the left side of the vertical line would be the corresponding values for 2005. Even though values would be on the left side of the zero line, it doesn't mean they are negative, I just want to compare changes in time. data 2005 2007 11.42 11.76 11.93 11.97 4.06 4.53 4.29 4.47 Hope this is clear, Thanks in advance. dxc13 -- View this message in context: http://www.nabble.com/A-variation-on-the-bar-plot-tp23374466p23374466.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] Optim function in the loop
Thanks for the reply. optim(initpar,Linn,NULL,method=BFGS,hessian=TRUE,control=list(trace=1,REPORT=1,maxit=300)) The optim is to minimize the negative likelihood function which is performed in function Linn, Every time the code stops right after optim, for example, the output looks like: iter 16 value 42.818394 iter 16 value 42.818394 final value 42.818394 converged It seems from the code that the loop should continue to run, at least calculate u values... but it does not... Thank you. Hi all, I wrote the following lines of codes try to do some iterations to find the global optimal values, but the function does not execute properly. Every time codes stop after one iteration right after executing the optim() function. Does anyone could have me to take a look? Thanks. if (count0){ k=k+0.05; mu0=c(83+k,0,0) Sigma0= diag(0.4,3) initpar=c(.1+10*k,10*k,10*k,10*k) # initial parameters for Phi[1,1], the 2 Q’s and R est=optim(initpar,Linn,NULL,method=BFGS,hessian=TRUE,control=list(trace=1,REPORT=1,maxit=300)) stderr=sqrt(diag(solve(est$hessian))) estimate=est$par u=cbind(estimate,stderr) if (u[1]0 u[2]0 u[3]0 u[4]0){ print(mu0=);print(mu0); print(initpar=);print(initpar) #break } else {count=-1; } } -- View this message in context: http://www.nabble.com/Optim-function-in-the-loop-tp23352044p23374525.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] FOURIER INTEGRALS IN R
Hi, I am wondering whether there exist any function in R (any package) that calculates Fourier Integrals. Particularly, I am interested for estimation of a Cosine Fourier integral... I would be much obliged if you could help me on this.. Thanks. Andreas -- __ R-help@r-project.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] A variation on the bar plot
Check out the back to back histogram here: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=136 On Mon, May 4, 2009 at 2:58 PM, dxc13 dx...@health.state.ny.us wrote: Hi all, I cannot think of the technical name of this plot, but I want to create a plot with the data below that looks like two back-to-back horizontal bar plots. Ideally, there would be a vertical line in the center of the plot at zero, and on the right hand side would be 4 bars representing the values for 2007, and on the left side of the vertical line would be the corresponding values for 2005. Even though values would be on the left side of the zero line, it doesn't mean they are negative, I just want to compare changes in time. data 2005 2007 11.42 11.76 11.93 11.97 4.06 4.53 4.29 4.47 Hope this is clear, Thanks in advance. dxc13 -- View this message in context: http://www.nabble.com/A-variation-on-the-bar-plot-tp23374466p23374466.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] questions about function arima0
Hi, I work on order estimation for autoregressive processes and after some inconsistencies cropped up I implemented the AIC criterion myself. Its results do not match the implementation in R and there are a few things I can not understand even after reading the source code of R. I used the function called arima0 (with empty ma coeficient vector), and I do not understand how some of the results are calculated: 1. resid If we denote the estimated order of a time series by k, how does the function calculate the first k elements of the residual vector? The rest of the elements match my version, but the first k are not calculated in my implementation. Calculating them requires some kind of assumption, but after trying a few possible ones (like using zero in place of the missing elements ot the average of the time series) none of them seem to yield the same results as I get from arima0. 2. loglik The loglikelihood at it's maximum should be a funcion of the estimated residual variance if the residuals are assumed to be normally distributed: -2*loglik = n*log(sigma2)+n*log(2*pi)+n The $loglik and $sigma2 variables from arima0 do not satisfy that equation. In my implementation I calculated the residual vector the same way, but leaving the first k elements, then calculating sigma2 by sum(resid^2)/(n-k), and at the end I got the loglikelihood through the equation above. If I compare the Akaike information criteria I get from my implementation to the one of R's, I get quite different results. I performed 100 simulations with time series of length 1000 and the ratio of correct order selection was different (lower with my implementation than with R's). Can you help me to find out what causes the difference? Best regards, Beata Darabos __ R-help@r-project.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] A variation on the bar plot
It's sometimes called a pyramid plot. The plotrix package has one. See ?pyramid.plot dxc13 dx...@health.state.ny.us 05/04/09 7:58 PM Hi all, I cannot think of the technical name of this plot, but I want to create a plot with the data below that looks like two back-to-back horizontal bar plots. Ideally, there would be a vertical line in the center of the plot at zero, and on the right hand side would be 4 bars representing the values for 2007, and on the left side of the vertical line would be the corresponding values for 2005. Even though values would be on the left side of the zero line, it doesn't mean they are negative, I just want to compare changes in time. data 2005 2007 11.42 11.76 11.93 11.97 4.06 4.53 4.29 4.47 Hope this is clear, Thanks in advance. dxc13 -- View this message in context: http://www.nabble.com/A-variation-on-the-bar-plot-tp23374466p23374466.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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.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] ellipsis problem
Duncan Murdoch murd...@stats.uwo.ca writes: On 5/4/2009 2:55 PM, tyler wrote: This looks like another manifestation of the following bug: [...] which has recently been fixed in R-patched. I haven't traced through it, but I do see the same error as you in 2.9.0, but not in 2.9.0 patched. Ok, thanks. I've updated to 2.9.0, but we don't have the patched version packaged for Debian yet. I can work around the problem until we do. Cheers, Tyler -- Philosophy of science is about as useful to scientists as ornithology is to birds. --Richard Feynman __ R-help@r-project.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] S4 slot of type connection [Sec=Unclassified]
I am having trouble declaring a slot of type connection or file in which to store a file connection. I get a warning message when class definition is loaded: In .completeClassSlots(ClassDef, where) : undefined slot classes in definition of Element: datafileConn(class file) Can anyone suggest what type I should be using for the slot. Type connection produces similar warnings plus error messages. Troy Robertson Database and Computing Support Provider Southern Ocean Ecosystems, ERM/Fish Australian Antarctic Division Channel Highway, Kingston 7050 PH: 03 62323571 troy.robert...@aad.gov.au ___ Australian Antarctic Division - Commonwealth of Australia IMPORTANT: This transmission is intended for the addressee only. If you are not the intended recipient, you are notified that use or dissemination of this communication is strictly prohibited by Commonwealth law. If you have received this transmission in error, please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and DELETE the message. Visit our web site at http://www.antarctica.gov.au/ ___ [[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] FOURIER INTEGRALS IN R
integrate offers some one-dimensional algorithms, but you need to start with a smooth function to get it to converge properly. With a cosine integral, there may be certain routines that offer better value for money: the Clenshaw-Curtis integration, or perhaps the FFT. You would have to recast your problem by doing some sort of substitution. Perhaps post some latex code to show the exact type of integral you are wanting to calculate. Regards, On May 5, 6:32 am, Achilleas Achilleos ma...@bristol.ac.uk wrote: Hi, I am wondering whether there exist any function in R (any package) that calculates Fourier Integrals. Particularly, I am interested for estimation of a Cosine Fourier integral... I would be much obliged if you could help me on this.. Thanks. Andreas -- __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Way to handle variable length and numbers of columns using read.table(...)
I've got read.table to successfully read in my table of three columns. Most of the time I will have a set number of rows, but sometime that will be variable and sometimes there will be only be two variables in one row, e.g. Time Loc1 Loc2 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Is there any way to have read.table handle (1) a variable number of rows, and (2) sometime there are only two variables as shown in Time = 3 above? Just curious about how to handle this, and if read.table is the right way to go about or if I should read in all the data and then try to parse it out best I can. Thanks again. R.version _ platform i386-apple-darwin8.11.1 arch i386 os darwin8.11.1 system i386, darwin8.11.1 status major 2 minor 8.0 year 2008 month 10 day20 svn rev46754 language R version.string R version 2.8.0 (2008-10-20) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Way to handle variable length and numbers of columns using read.table(...)
Well if you read in your data, you get: x - read.table('clipboard', header=TRUE, fill=TRUE) Warning message: In read.table(clipboard, header = TRUE, fill = TRUE) : incomplete final line found by readTableHeader on 'clipboard' x Time Loc1 Loc2 1122.33 44.55 2266.77 88.99 33 222.33344.55NA 4466.77 88.99 str(x) 'data.frame': 4 obs. of 3 variables: $ Time: int 1 2 3 4 $ Loc1: Factor w/ 3 levels 22.33,222.33344.55,..: 1 3 2 3 $ Loc2: num 44.5 89 NA 89 As you can see the variable that has two decimal points is read in as a character and cause the whole column to be converted to a factor. It appears that you have some fixed length fields that are overflowing. Now you could read in the data and use regualr expressions and parse the data; you just have to match on the first part have two decimal place and then extract the rest. THe question is, is this the only problems you have in the data? If so, parsing it is not hard. On Mon, May 4, 2009 at 10:20 PM, Jason Rupert jasonkrup...@yahoo.comwrote: I've got read.table to successfully read in my table of three columns. Most of the time I will have a set number of rows, but sometime that will be variable and sometimes there will be only be two variables in one row, e.g. Time Loc1 Loc2 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Is there any way to have read.table handle (1) a variable number of rows, and (2) sometime there are only two variables as shown in Time = 3 above? Just curious about how to handle this, and if read.table is the right way to go about or if I should read in all the data and then try to parse it out best I can. Thanks again. R.version _ platform i386-apple-darwin8.11.1 arch i386 os darwin8.11.1 system i386, darwin8.11.1 status major 2 minor 8.0 year 2008 month 10 day20 svn rev46754 language R version.string R version 2.8.0 (2008-10-20) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Way to handle variable length and numbers of columns using read.table(...)
Its not clear exactly what the rules are for this but if we assume that numbers always end in a decimal plus two digits then using stapply from the gsubfn package: Lines - Time Loc1 Loc2 + 1 22.33 44.55 + 2 66.77 88.99 + 3 222.33344.55 + 4 66.77 88.99 library(gsubfn) L - readLines(textConnection(Lines)) strapply(L[-1], [0-9]*[.][0-9][0-9], as.numeric, simplify = rbind) [,1] [,2] [1,] 22.33 44.55 [2,] 66.77 88.99 [3,] 222.33 344.55 [4,] 66.77 88.99 See http://gsubfn.googlecode.com and for regular expressions see ?regex On Mon, May 4, 2009 at 10:20 PM, Jason Rupert jasonkrup...@yahoo.com wrote: I've got read.table to successfully read in my table of three columns. Most of the time I will have a set number of rows, but sometime that will be variable and sometimes there will be only be two variables in one row, e.g. Time Loc1 Loc2 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Is there any way to have read.table handle (1) a variable number of rows, and (2) sometime there are only two variables as shown in Time = 3 above? Just curious about how to handle this, and if read.table is the right way to go about or if I should read in all the data and then try to parse it out best I can. Thanks again. R.version _ platform i386-apple-darwin8.11.1 arch i386 os darwin8.11.1 system i386, darwin8.11.1 status major 2 minor 8.0 year 2008 month 10 day 20 svn rev 46754 language R version.string R version 2.8.0 (2008-10-20) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.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] Way to handle variable length and numbers of columns using read.table(...)
Jim, You guessed it. There are other problems with the data. Here is a closer representation of the data: Total time and location are listed below. Time Loc1 Loc2 --- 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Avg. Loc1 = 77.88 Avg. Loc2 = 55.66 Final Time = 4 Right now I am using nrows in order to only read Time 1-4 skip to skip over the unusable header info, e.g. read.table(read.table('clipboard', header=FALSE, fill=TRUE, skip=5, nrows=4) Unfortunately, sometimes the number of Time rows varies, so I need to also account for that. Maybe I need to look into what Gabor suggested as well, i.e. library(gsubfn) Thanks again for any feedback and advice on this one, as the data I receive is out of my control, but I am working with the go get them to fix it as well. --- On Mon, 5/4/09, jim holtman jholt...@gmail.com wrote: From: jim holtman jholt...@gmail.com Subject: Re: [R] Way to handle variable length and numbers of columns using read.table(...) To: jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Monday, May 4, 2009, 9:47 PM Well if you read in your data, you get: x - read.table('clipboard', header=TRUE, fill=TRUE) Warning message: In read.table(clipboard, header = TRUE, fill = TRUE) : incomplete final line found by readTableHeader on 'clipboard' x Time Loc1 Loc2 1122.33 44.55 2266.77 88.99 33 222.33344.55NA 4466.77 88.99 str(x) 'data.frame': 4 obs. of 3 variables: $ Time: int 1 2 3 4 $ Loc1: Factor w/ 3 levels 22.33,222.33344.55,..: 1 3 2 3 $ Loc2: num 44.5 89 NA 89 As you can see the variable that has two decimal points is read in as a character and cause the whole column to be converted to a factor. It appears that you have some fixed length fields that are overflowing. Now you could read in the data and use regular expressions and parse the data; you just have to match on the first part have two decimal place and then extract the rest. THe question is, is this the only problems you have in the data? If so, parsing it is not hard. On Mon, May 4, 2009 at 10:20 PM, Jason Rupert jasonkrup...@yahoo.comwrote: I've got read.table to successfully read in my table of three columns. Most of the time I will have a set number of rows, but sometime that will be variable and sometimes there will be only be two variables in one row, e.g. Time Loc1 Loc2 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Is there any way to have read.table handle (1) a variable number of rows, and (2) sometime there are only two variables as shown in Time = 3 above? Just curious about how to handle this, and if read.table is the right way to go about or if I should read in all the data and then try to parse it out best I can. Thanks again. R.version _ platform i386-apple-darwin8.11.1 arch i386 os darwin8.11.1 system i386, darwin8.11.1 status major 2 minor 8.0 year 2008 month 10 day20 svn rev46754 language R version.string R version 2.8.0 (2008-10-20) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.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] Way to handle variable length and numbers of columns using read.table(...)
The last line should be as follows (as the previous post missed the time column). The regular expression says either start from beginning (^) and look for a string of digits, [0-9]+, or look for digits [0-9]*, a dot [.] and two more digits [0-9][0-9]. Each time strapply finds such a match as.numeric is applied to it. Thus line of input results in a numeric vector and then we simplify those vectors by rbind'ing them together. strapply(L[-1], ^[0-9]+|[0-9]*[.][0-9][0-9], as.numeric, simplify = rbind) [,1] [,2] [,3] [1,]1 22.33 44.55 [2,]2 66.77 88.99 [3,]3 222.33 344.55 [4,]4 66.77 88.99 On Mon, May 4, 2009 at 11:04 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Its not clear exactly what the rules are for this but if we assume that numbers always end in a decimal plus two digits then using stapply from the gsubfn package: Lines - Time Loc1 Loc2 + 1 22.33 44.55 + 2 66.77 88.99 + 3 222.33344.55 + 4 66.77 88.99 library(gsubfn) L - readLines(textConnection(Lines)) strapply(L[-1], [0-9]*[.][0-9][0-9], as.numeric, simplify = rbind) [,1] [,2] [1,] 22.33 44.55 [2,] 66.77 88.99 [3,] 222.33 344.55 [4,] 66.77 88.99 See http://gsubfn.googlecode.com and for regular expressions see ?regex On Mon, May 4, 2009 at 10:20 PM, Jason Rupert jasonkrup...@yahoo.com wrote: I've got read.table to successfully read in my table of three columns. Most of the time I will have a set number of rows, but sometime that will be variable and sometimes there will be only be two variables in one row, e.g. Time Loc1 Loc2 1 22.33 44.55 2 66.77 88.99 3 222.33344.55 4 66.77 88.99 Is there any way to have read.table handle (1) a variable number of rows, and (2) sometime there are only two variables as shown in Time = 3 above? Just curious about how to handle this, and if read.table is the right way to go about or if I should read in all the data and then try to parse it out best I can. Thanks again. R.version _ platform i386-apple-darwin8.11.1 arch i386 os darwin8.11.1 system i386, darwin8.11.1 status major 2 minor 8.0 year 2008 month 10 day 20 svn rev 46754 language R version.string R version 2.8.0 (2008-10-20) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.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] Calculating relative ratios in a data frame..
On Mon, May 04, 2009 at 04:44:37PM -0400, jim holtman wrote: Here is a way -- you are dividing by zero in the scaling: Thanks to both of you who answered. I know about division by zero, but I basically ignore rows having n==1 when plotting. __ R-help@r-project.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.