Re: [R] xeon processor and ATLAS
hui xie [EMAIL PROTECTED] writes: The reason why I would like to use ATLAS is that R FAQ said : The savings can be appreciable: on a 2.6GHz P4 and a 1000 x 1000 matrix svd took 16.2 sec with the standard BLAS and 7.8 sec with ATLAS. Because ATLAS is tuned to a particular chip we can't use it generally: the optimal routines for a P4 or an Athlon XP are quite different and neither will run at all on a PII. This seems to me an impressive gain to use the correct ATLAS instead of the default BLAS. I've been doing econometrics for nearly 20 years, and have not yet run across a situation that called for looking at a 1000 x 1000 matrix. I tend not to believe analyses with more than a dozen explanatory variables. But I suppose that you could run across a situation where a design matrix with hundreds of columns actually made sense. But does that really happen often enough that saving 8 seconds of computation time is worth going through the ATLAS hassle? -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
Are you using the latest version of fame? 1.05 and earlier had a bug in tisFromCsv that was fixed in 1.08. Below I show what I get with fame version 1.08. There is still a problem in that the frequency-figuring logic appears to think the frequency is bwsunday (biweekly with weeks ending on Sunday) rather than semimonthly, which would appear to be a better fit. That's why the 19860330 observation is getting filled in with NA's. Jeff Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm 15-Jan-86 673.25175645 65910 2842537485 31-Jan-86 677.00167350 54060 2712026940 14-Feb-86 680.25157985 37955 2542512530 28-Feb-86 691.75162775 49760 1603033730 14-Mar-86 706.50163495 54120 2799526125 31-Mar-86 709.75164120 54715 3039024325 + + + + + + boink - tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) boink $Price [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 NA 19860413 709.75 class: tis $Open.Int. [,1] 19860119 175645 19860202 167350 19860216 157985 19860302 162775 19860316 163495 19860330 NA 19860413 164120 class: tis $Comm.Long [,1] 19860119 65910 19860202 54060 19860216 37955 19860302 49760 19860316 54120 19860330NA 19860413 54715 class: tis $Comm.Short [,1] 19860119 28425 19860202 27120 19860216 25425 19860302 16030 19860316 27995 19860330NA 19860413 30390 class: tis $net.comm [,1] 19860119 37485 19860202 26940 19860216 12530 19860302 33730 19860316 26125 19860330NA 19860413 24325 class: tis Gabor Grothendieck [EMAIL PROTECTED] writes: On 26 Jul 2007 09:59:31 -0400, Jeffrey J. Hallman [EMAIL PROTECTED] wrote: zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff 1. What am I doing wrong here? I only get one data column. 2. I assume the regularized dates which do not exactly match the input ones are intended so as to make this a regularly spaced series. Is that right? 3. What is the cause of the warning message? 4. Why is a list returned with a single component containing the output? Thanks. library(fame) Lines - Date Price Open.Int. Comm.Long Comm.Short net.comm + 15-Jan-86 673.25175645 65910 2842537485 + 31-Jan-86 677.00167350 54060 2712026940 + 14-Feb-86 680.25157985 37955 2542512530 + 28-Feb-86 691.75162775 49760 1603033730 + 14-Mar-86 706.50163495 54120 2799526125 + 31-Mar-86 709.75164120 54715 3039024325 + tisFromCsv(textConnection(Lines), dateFormat = %d-%b-%y, dateCol = Date, sep = ) [[1]] [,1] 19860119 673.25 19860202 677.00 19860216 680.25 19860302 691.75 19860316 706.50 19860330 709.75 class: tis Warning message: number of items to replace is not a multiple of replacement length in: x[i] - value __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Dates
zoo is nice. 'tisFromCsv()' in the fame package is nicer. Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate.ts
Your troubles with 'aggregate' for a ts are one of the reasons I created the 'tis' and 'ti' classes in the fame package. If you do this: x1 - tis(1:24, start = c(2000, 10), freq = 12) x2 - tis(1:24, start = c(2000, 11), freq = 12) y1 - aggregate(x1, nfreq = 4) y2 - aggregate(x2, nfreq = 4) x1 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2000 1 2 3 2001 4 5 6 7 8 9 10 11 12 13 14 15 2002 16 17 18 19 20 21 22 23 24 class: tis x2 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2000 1 2 2001 3 4 5 6 7 8 9 10 11 12 13 14 2002 15 16 17 18 19 20 21 22 23 24 class: tis y1 Qtr1 Qtr2 Qtr3 Qtr4 2000 6 2001 15 24 33 42 2002 51 60 69 class: tis y2 Qtr1 Qtr2 Qtr3 Qtr4 2001 12 21 30 39 2002 48 57 66 class: tis Everything pretty much works as you would expect. One thing to notice is that, even using a 'tis' rather than a 'ts', aggregate will only sum up the monthly observations for a quarter if all three of the months are there. That's why y2 starts with 2001Q1, rather than 2000Q4. If you really want the 2000Q4 observation to be the sum of the first two x2 months, the convert() function in fame can handle that. convert(x2, tif = quarterly, observed = summed, ignore = T) Qtr1 Qtr2 Qtr3 Qtr4 20004.03 2001 12.00 21.00 30.00 39.00 2002 48.00 57.00 66.00 71.225806 class: tis Now back to ts. If you look deeper into what's happening here: y3 - aggregate(as.ts(x2), nf = 4) y3 Error in rep.int(, start.pad) : invalid number of copies in rep.int() Enter a frame number, or 0 to exit 1: print(c(6, 15, 24, 33, 42, 51, 60, 69)) 2: print.ts(c(6, 15, 24, 33, 42, 51, 60, 69)) 3: matrix(c(rep.int(, start.pad), format(x, ...), rep.int(, end.pad)), nc 4: as.vector(data) 5: rep.int(, start.pad) Selection: 0 unclass(y3) [1] 6 15 24 33 42 51 60 69 attr(,tsp) [1] 2000.833 2002.5834.000 what you see is that aggregate() did indeed create a quarterly series, but the quarters cover (Nov-Jan, Feb-Apr, May-Jul, Aug-Oct), not the usual (Jan-Mar, Apr-Jun, Jul-Sep, Oct-Dec). The author of the print.ts code evidently never even thought of this possibility. Not that I blame him. I work with monthly and quarterly data all the time, and the behavior of aggregate.ts() is so counter-intuitive that I wouldn't have imagined it either. Bottom line: use 'tis' series from the fame package, or 'zoo` stuff from Gabor's zoo package. As the author of the fame package, I hope you'll excuse me for asserting that the 'tis' class is easier to understand and use than the zoo stuff, which takes a more general approach. Some day Gabor or I or some other enterprising soul should try combining the best ideas from zoo and fame into a package that is better than either one. Jeff -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dates() is a great date function in R
Mr Natural [EMAIL PROTECTED] writes: Just save the spreadsheet as a csv file and use tisFromCsv() in the fame package. One of the arguments tisFromCsv() takes is a dateFormat, so you can tell it what format the date column is in. You can also tell it the name of the date column if it isn't some variation of DATE, Date, or date. tisFromCsv() looks at the dates coming in and automatically figures out what frequency the data are (quarterly, monthly, weekly, daily, etc.) and creates a univariate or multivariate (if the spreadsheet has more than one data column) 'tis' (Time Indexed Series) object. Jeff Proper calendar dates in R are great for plotting and calculating. However for the non-wonks among us, they can be very frustrating. I have recently discussed the pains that people in my lab have had with dates in R. Especially the frustration of bringing date data into R from Excel, which we have to do a lot. Please find below a simple analgesic for R date importation that I discovered over the last 1.5 days (Learning new stuff in R is calculated in 1/2 days). The functiondates()gives the simplest way to get calendar dates into R from Excel that I can find. But straight importation of Excel dates, via a csv or txt file, can be a a huge pain (I'll give details for anyone who cares to know). My pain killer is: Consider that you have Excel columns in month, day, year format. Note that R hates date data that does not lead with the year. a. Load the chron library by typing library(chron) in the console. You know that you need this library from information revealed by performing the query, ?dates()in the Console window. This gives the R documentation help file for this and related time, date functions. In the upper left of the documentation, one sees dates(chron). This tells you that you need the library chron. b. Change the format dates in Excel to format general, which gives 5 digit Julian dates. Import the csv file (I useread.csv() with the Julian dates and other data of interest. c. Now, change the Julian dates that came in with the csv file into calendar dates with thedates() function. Below is my code for performing this activity, concerning an R data file called ss, ss holds the Julian dates, illustrated below from the column MPdate, ss$MPdate[1:5] [1] 34252 34425 34547 34759 34773 The dates() function makes calendar dates from Julian dates, dmp-dates(ss$MPdate,origin=c(month = 1, day = 1, year = 1900)) dmp[1:5] [1] 10/12/93 04/03/94 08/03/94 03/03/95 03/17/95 I would appreciate the comments of more sophisticated programmers who can suggest streamlining or shortcutting this operation. regards, Don -- View this message in context: http://www.nabble.com/dates%28%29-is-a-great-date-function-in-R-tf4105322.html#a11675205 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] accessing list components with a variable
the_list[[comp]] David C. James [EMAIL PROTECTED] writes: Let's say I have a list called the_list consisting of three components: the_list$component_1 the_list$component_2 the_list$component_3 Now, I want to access it using a variable called comp. comp - component_1 I'm looking for some function that let's me do this: unknown_function(the_list, comp) Which should do the same thing as: the_list$component_1 Any ideas? I'd be open to other ways of doing this, too. I explored this way, but it didn't seem to get me anywhere: the_list$component_1 I possibly could have gotten further along if I knew how to do evaluation in R. Thanks, David __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Getting the last day of the month.
The TimeIndex class in the 'fame' package handles this kind of stuff with ease. library(fame) ym - 200212 z - lastDayOf(ti(100*ym + 1, tif = monthly)) z [1] 20021231 class: ti tifName(z) [1] daily a 'ti' object is a TimeIndex, and it has a tif (TimeIndexFrequency) embedded in it. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Construct time series objects from raw data stored in csv files
As Gabor said, ts series are not good for weekly data. That's why I created the tis (Time Indexed Series) class, in the 'fame' package. You don't need the Fame database to use them. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reasons to Use R
halldor bjornsson [EMAIL PROTECTED] writes: ... Now, R does not have everything we want. One thing missing is a decent R-DB2 connection, for windows the excellent RODBC works fine, but ODBC support on Linux is a hassle. A hassle? I use RODBC on Linux to read data from a mainframe DB2 database. I had to create the file .odbc.ini in my home directory with lines like this: [m1db2p] Driver = DB2 Servername = NameOfOurMainframe Database = fdrp UserName = NachoBizness TraceFile = /home/NachoBizness/.odbc.log and then to connect I do this: Sys.putenv(DB2INSTANCE = db2inst) myConnection - odbcConnect(dsn = m1db2p, uid = uid, pwd = pwd, case = toupper) with 'uid' and 'pwd' set to my mainframe uid and password. Now, I am not the sysadmin for our Linux machines, but I don't think they had to do much beyond the standard rpm installation to get this working. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how much performance penalty does this incur, scalar as a vector of one element?
The 64 bit version of VisualWorks Smalltalk has an immediate ShortDouble, which sacrifices two bits of exponent for a tag. It thus has the same precision as an IEEE double, but one fourth as much range. Overflows automatically get promoted to ordinary Double's, which are pointers to objects holding real IEEE doubles. Luke Tierney [EMAIL PROTECTED] writes: Systems that support integer scalars often represent them as immediate values within pointers by sacrificing one or two bits of precision in the integers, but that doesn't work for double precision floats except possibly on 64-bit systems. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to create daily / weekly ts object?
Look at the 'fame' package I recently put up. You don't need to have the FAME database installed to use it. Among other things, the package defines a class tis (Time Indexed Series) that can handle weekly time series. Wensui Liu [EMAIL PROTECTED] writes: Monthly and Quarterly ts obj. is easy to understand. But I couldn't find an example in R manual how to create daily or weekly ts object. Could you please shed some light on it? I really appreciate it. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] if else statement
?switch H. Paul Benton [EMAIL PROTECTED] writes: I'm doing some scripting and I've noticed that R doesn't seem to have an if (cond){ do }ifelse (cond) { do } else { do } type block. Is this correct or am I missing something. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hourly Time Series
The 'fame' package I submitted to CRAN can handle hourly, minutely, and secondly series. The first submission I made last night did not build correctly on a Linux machine without the FAME libraries, but the one I put up this morning has fixed that. It should be available soon, unless I missed another problem (entirely possible). -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] command for stopping and then hit return and continue (fwd)
[EMAIL PROTECTED] writes: -- Forwarded message -- is it possible to implement the same sort of thing when you aren't plotting. in other words, i am in a loop and each time through the loop i want to print a set of values, have it stop, then only have it continue when i hit return ? thanks. readline(Hit Return ) -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix multiplication using apply() or lappy() ?
Tim Hesterberg [EMAIL PROTECTED] writes: [EMAIL PROTECTED] asked: I am trying to divide the columns of a matrix by the first row in the matrix. Dividing columns of a matrix by a vector is a pretty fundamental operation, and the query resulted in a large number of suggestions: It is unsatisfactory when such a fundamental operation is done in so many different ways. * It makes it hard to read other people's code. * Some of these are very inefficient. But since you have no way to force people to use your new 'standard' operators, people can and will still use any of those myriad ways you decry to do the same thing. It's part of the price you pay for working with a flexible system. Besides, nothing will ever make it easy to read other people's code. :-) Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Packaging platform-specific functions
Never mind. I RFTM'ed more carefully and found that the 'R' directory can also have a 'unix' or 'windows' subdirectory. [EMAIL PROTECTED] wrote: jh I have a few functions, such as screenWidth() and screenHeight(), which jh I have been able to implement for a Unix/Linux environment, but not for jh Windows. (Does anyone know how to find the screen dimensions in jh Windows?) jh The Writing R Extensions manual tells me how to include jh platform-specific sections in documentation, and even how to have jh platform-specific help files. But it doesn't say anything about when or jh how to handle platform-specific code. In particular, how do package jh writers handle functions that make sense for one platform but not for jh another? I'd like to keep a single set of source code files and jh generate the Windows and Linux packages from it. jh Any suggestions? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dev.print and X11(canvas = black)
Prof Brian Ripley [EMAIL PROTECTED] wrote: On Mon, 1 Mar 2004 [EMAIL PROTECTED] wrote: In Splus, I often use graphics windows with a black background and white foreground. The S print.graph() function sends the current plot to my printer but with a white background and black foreground. I'd like to S (and S-PLUS) only has a few colour numbers, and you can change their interpretation on the screen graphics devices after plotting. R does plot in colours rather than numbers. be able to do something similar in R, but can't figure out how. I've tried various permutations of dev.copy() and dev.print(), but it seems that the foreground color is fixed when the original plot is drawn, and dev.copy always redraws it with that color. So even though I can get my postscript output with a white background, things that were drawn white on the dark background of my X11 device are still drawn white when dev.copy'd to a postscript device. Since the postscript has a white background, that means the white foreground stuff doesn't show up. Is there a way to handle this? Or do I just have to give up on ever using a dark canvas in X11() if I ever want to print the result? There are many ways to print the result, and re-running the plot commands after switching to a postscript() device is one of the best. This would work for you if you only ever use colour numbers and switch the palette (and par(fg)). Jim Lemon made essentially the same suggestion: run the code that created the plot twice, once with X11 as the active device, and again with postscript as the active device. The trouble with this is that is doesn't handle plots that the user has edited. I have some charts that users add things to interactively, using combinations of locator(), text(), mtext(), and arrows(). There's no nice way to know what a user has done to a plot before he attempts to print it. I know that R is internally maintaining a display list. Is there a way to access that without dropping into C? And what's in it, anyway? Jeff __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html