[R] Generating permutations that always include one specific element

2009-12-19 Thread Raymond Danner
Dear R community, I am trying to create a matrix of permutations of a vector: bands - c(AL, B, DB, DG, G, K, LB, LG, MG, O, P, PI, PK, PU, R, V, W, Y) Each permutation must be 4 characters long. permutations() from the gtools package does this easy enough: possible.combos - permutations(18, 4,

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-19 Thread Patrick Connolly
On Sat, 19-Dec-2009 at 09:24AM +1800, Peng Yu wrote: | On Sat, Dec 19, 2009 at 3:35 AM, Patrick Connolly | p_conno...@slingshot.co.nz wrote: | On Thu, 17-Dec-2009 at 03:13PM +1800, Peng Yu wrote: | | | Currently, I load the RData file then ls() and str(). But loading the file | | takes too

Re: [R] What is the fastest way to see what are in an RData file?

2009-12-19 Thread Henrik Bengtsson
library(R.oo); setMethodS3(ll, character, function(pathname, ..., force=FALSE) { require(R.cache) || throw(Package not loaded: R.cache); # Argument 'pathname': pathname - Arguments$getReadablePathname(pathname, mustExist=TRUE); # Check for cache results fi - file.info(pathname);

Re: [R] Hello all, How can I get corss-validation MSE of SVM in e1071?

2009-12-19 Thread bbslover
thank you for your help, caret package is so powerful , it can do many things. I now, need learn how to apply to my problems. Max Kuhn wrote: You can get this using the caret package. There are a few package vignettes that come with the package and a JSS article

Re: [R] Error when running Conditional Logit Model

2009-12-19 Thread Hien Nguyen
On 12/18/09 22:24, Charles C. Berry wrote: On Fri, 18 Dec 2009, Hien Nguyen wrote: Thanks a lot for answering my questions. I have tried to run the clogit for only 64 observations and 4 independent variables and the results are solved instantly. However, when I run the same command (with

[R] Help with arguments in .Script

2009-12-19 Thread Veronesi, Fabio
Dear R users, my problem, at the moment, is the following: I need to apply a script to a very big dataset, so I need first to subdivide the dataset into samples and then apply the script to every single sample. Now I tried to solve the problem with these linest: S1-data[data$sub==1,1:3]

Re: [R] ggplot2 / lattice

2009-12-19 Thread Felix Andrews
something like bwplot(val ~ g | G2, dta, pch = |, box.width = 1, par.settings = list(box.rectangle = list(col = darkred, fill = grey90), box.umbrella = list(col = darkred), strip.background = list(col = transparent))) For more on the Lattice style /

Re: [R] Time Series Rating Model

2009-12-19 Thread Ryusuke Kenji
Experts, I have try to do seperate and doing simulation on lm.dibp (bivpois). I edited some elements to fit my soccer scores model. The static model has completed, I try to biuld a weight function for dynamic model as refer to dixon coles(1997). existing weighted function in

Re: [R] model matrix with a spline

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 2:22 AM, David Hugh-Jones wrote: Hi all I want to get the design matrix for a model, evaluated at a single value. For example, if I pass in a data frame with a=2, b=2, y=3, and my model is y ~ a+b+a:b, then I would like to get the values 3, 2, 2, 4 out. I can do this

Re: [R] Generating permutations that always include one specific element

2009-12-19 Thread Stephan Kolassa
Hi Ray, First possibility: just select those combinations that contain AL: combos.with.AL - possible.combos[rowSums(possible.combos==AL)0,] Second possibility: create all 3-combos *without* AL: bands.without.AL - c(B, DB, DG, G, K, LB, LG, MG, O, P, PI, PK, PU, R, V, W, Y)

Re: [R] Generating permutations that always include one specific element

2009-12-19 Thread David Winsemius
On Dec 18, 2009, at 6:27 PM, Raymond Danner wrote: Dear R community, I am trying to create a matrix of permutations of a vector: bands - c(AL, B, DB, DG, G, K, LB, LG, MG, O, P, PI, PK, PU, R, V, W, Y) Each permutation must be 4 characters long. permutations() from the gtools package

Re: [R] Help with arguments in .Script

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 6:24 AM, Veronesi, Fabio wrote: Dear R users, my problem, at the moment, is the following: I need to apply a script to a very big dataset, so I need first to subdivide the dataset into samples and then apply the script to every single sample. Now I tried to solve the

[R] expand.grid game

2009-12-19 Thread baptiste auguie
Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their digits equal to 17? The brute-force answer could be: maxi - 9 # digits from 0 to 9 N - 5 # 8 is too large test - 17

[R] new version of glmnet

2009-12-19 Thread Trevor Hastie
glmnet _1.1-4 is on CRAN now. This version includes cross.validation functions to assist in picking a good value for lambda These functions are preliminary, in that they can only handle gaussian or logistic models for binary data. The complete range will appear in the future. For those

[R] New version of package mda

2009-12-19 Thread Trevor Hastie
mda 0.1-4 is on CRAN Many thanks to Friedrich Leisch, Kurt Hornik and Brian Ripley for their early work in porting the mda package into R, and to Kurt for maintaining the package. I have taken back mda and will maintain it from now on. The package fits flexible, penalized and mixture

[R] ggplot2 help.

2009-12-19 Thread Kim Jung Hwa
Hi All, I'm trying following code and would need help with: 1. Flexibility to move legend inside (top, right, left, etc...). Currently its overlaying with plot's border. 2. Reducing width/height and making it more compact, with small boxes. # Requires installing and loading ggplot2 package p -

[R] simple main effect.

2009-12-19 Thread Or Duek
Hi, I'm a bit new to R and I would like to know how can I compare simple main effects when using the aov function. I'm doing a mixed model ANOVA with two between subjects variables and one within. When I get an interaction of two of the variables I don't know how to check for simple main effect of

[R] Run time error when executing sqlQuery using the 64-bit version of R with 64-bit RODBC package in a Solaris 10 Sparc machine.

2009-12-19 Thread Alex Chelminsky
I have compiled and linked a 64 bit version of R (R 2.9.2) and the corresponding unix ODBC 64 bit package The red highlighted text below is the error I'm getting trying to when invoking a sqlQuery library(RODBC) channel - odbcConnect(OraLSH, user, password) sqlQuery(channel,select sysdate

Re: [R] How to print to file?

2009-12-19 Thread John Kane
?sink perhaps? --- On Sat, 12/19/09, Peng Yu pengyu...@gmail.com wrote: From: Peng Yu pengyu...@gmail.com Subject: [R] How to print to file? To: r-h...@stat.math.ethz.ch Received: Saturday, December 19, 2009, 7:12 AM I don't find a function to print a string to file. Would somebody let

[R] Inserting .png plots in MS Word.

2009-12-19 Thread Wenjie Lee
Hi R Users, I'm using following sample code to save png plots. png(file=sample.png, width=8, height=6) Then I copy or use insert pictures function to get the image into MS Word. After copying, if I try to stretch or re-size the image it starts getting distorted. Is there a way to standardized

Re: [R] expand.grid game

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their digits equal to 17? The brute-force answer could be: maxi -

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
2009/12/19 David Winsemius dwinsem...@comcast.net: On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the following: how many 8-digit numbers have the sum of their digits

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 1:28 PM, Wenjie Lee wrote: Hi R Users, I'm using following sample code to save png plots. png(file=sample.png, width=8, height=6) Then I copy or use insert pictures function to get the image into MS Word. After copying, if I try to stretch or re-size the image it

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread Duncan Murdoch
On 19/12/2009 1:28 PM, Wenjie Lee wrote: Hi R Users, I'm using following sample code to save png plots. png(file=sample.png, width=8, height=6) Then I copy or use insert pictures function to get the image into MS Word. After copying, if I try to stretch or re-size the image it starts getting

Re: [R] expand.grid game

2009-12-19 Thread hadley wickham
I hope I have missed a better way to do this in R. Otherwise, I believe what I'm after is some kind of C or C++ macro expansion, because the number of loops should not be hard coded. Why not generate the list of integers that sum to 17, and then mix with 0s as appropriate? Hadley --

Re: [R] arrow plots

2009-12-19 Thread Paul Murrell
Hi Deepayan Sarkar wrote: On Wed, Dec 9, 2009 at 10:08 AM, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI samuel.ca...@hanscom.af.mil wrote: Thanks, all, for the help. Much obliged. I realize now that I should have said that I am using lattice graphics. The par() command has not been helpful in

Re: [R] expand.grid game

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 1:36 PM, baptiste auguie wrote: 2009/12/19 David Winsemius dwinsem...@comcast.net: On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote: Dear list, In a little numbers game, I've hit a performance snag and I'm not sure how to code this in C. The game is the

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
Hi, Thanks for the link, I guess it's some kind of a classic game. I'm a bit surprised by your timing, my ugly eval(parse()) solution definitely took less than one hour with a machine not so different from yours, system.time( for (i in 1079:1179) if (sumdigits(i)==17) {idx-c(idx,i)})

Re: [R] expand.grid game

2009-12-19 Thread baptiste auguie
This problem does yield some interesting and unexpected distributions. Here is another, the number of positive cases as a function of number of digits (8 in the original question) and of test value (17). maxi - 9 N - 5 test - 17 foo - function(N=2, test=1){ sum(rowSums(do.call(expand.grid,

Re: [R] expand.grid game

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 2:28 PM, baptiste auguie wrote: Hi, Thanks for the link, I guess it's some kind of a classic game. I'm a bit surprised by your timing, my ugly eval(parse()) solution definitely took less than one hour with a machine not so different from yours, system.time( for (i in

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread Wenjie Lee
Thanks David and Duncan, pdf()/eps() are good options. Can you please tell which function produces .wmf images. I finally want to copy/insert these images into word file (.doc) and submit it to my adviser, and keep a possibility to re-size pictures. Is it possible to add these .pdf / .eps

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread Duncan Murdoch
On 19/12/2009 3:06 PM, Wenjie Lee wrote: Thanks David and Duncan, pdf()/eps() are good options. Can you please tell which function produces .wmf images. win.metafile() (on Windows only, I think) produces .wmf images. I finally want to copy/insert these images into word file (.doc) and

[R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Jonathan
Hi, A noobie question: I'm simply trying to run a conditional statement that evaluates if a substring is found within a larger string. I find that if it IS found, my function returns TRUE (great!), but if not, the condition does not evaluate to FALSE. ex): if( grep(hi, hop, fixed = TRUE) )

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread S Devriese
On 12/19/2009 09:06 PM, Wenjie Lee wrote: Thanks David and Duncan, pdf()/eps() are good options. Can you please tell which function produces .wmf images. I finally want to copy/insert these images into word file (.doc) and submit it to my adviser, and keep a possibility to re-size

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread jim holtman
try using 'grepl' if( grepl(hi, hop, fixed = TRUE) ){ + print('yes, your substring is in your string') + } else print('no, your substring is not in your string') [1] no, your substring is not in your string On Sat, Dec 19, 2009 at 3:47 PM, Jonathan jonsle...@gmail.com wrote: Hi, A

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Stephan Kolassa
Hi Jonathan, grep() returns a vector giving either the indices of the elements of 'x' that yielded a match or, if 'value' is 'TRUE', the matched elements of 'x' (quoting from the help page, see ?grep). So you probably want to test whether this vector is empty or not - in other words,

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread Gabor Grothendieck
You can: 1. Right click the graphic and choose copy metafile or save metafile. 2. Use savePlot after producing your plot. See ?savePlot 3. Use win.metafile(...); plot(...); dev.off() On Sat, Dec 19, 2009 at 1:28 PM, Wenjie Lee wenjieleemaill...@gmail.com wrote: Hi R Users, I'm using

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Jonathan
Thanks, Jim and Stephen! On Sat, Dec 19, 2009 at 3:57 PM, jim holtman jholt...@gmail.com wrote: try using 'grepl' if( grepl(hi, hop, fixed = TRUE) ){ + print('yes, your substring is in your string') + } else print('no, your substring is not in your string') [1] no, your substring

Re: [R] Inserting .png plots in MS Word.

2009-12-19 Thread Wenjie Lee
Thanks all for your reply, Wenjie On Sat, Dec 19, 2009 at 4:20 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: You can: 1. Right click the graphic and choose copy metafile or save metafile. 2. Use savePlot after producing your plot. See ?savePlot 3. Use win.metafile(...); plot(...);

[R] DROP and KEEP statements in R

2009-12-19 Thread sarjinder
What is equivalent to DROP or KEEP statements of SAS in R? -- This message was sent on behalf of sarjin...@yahoo.com at openSubscriber.com http://www.opensubscriber.com/messages/r-help@r-project.org/topic.html __ R-help@r-project.org mailing list

Re: [R] DROP and KEEP statements in R

2009-12-19 Thread Gary Miller
Try this, library(lattice) data(barley) names(barley) # Removing first column barley - barley[,c(-1)] names(barley) # Keeping 1st and 3rd column barley - barley[,c(1,3)] names(barley) HTH, Gary On Sat, Dec 19, 2009 at 3:21 PM, sarjin...@yahoo.com wrote: What is equivalent to DROP or KEEP

[R] Lattice boxplots

2009-12-19 Thread Peng Cai
Hi All, I'm familiar with bwplot() in lattice package. Is it possible to get such a boxplot using lattice package: http://www.reading.ac.uk/ssc/publications/graphics/mma-fig1.gif instead of the following default: http://media.wiley.com/wires/WICS/WICS22/mfig005.gif My aim is to get a compact

Re: [R] Lattice boxplots

2009-12-19 Thread David Winsemius
Felix Andrews just today posted an answer to a question on filling the bwplot rectangles with color and using a line instead of a dot for the median. I think you will find it difficult to get the hatching for two related reasons, one aesthetic and the other the fact that patterns are not

Re: [R] Lattice boxplots

2009-12-19 Thread Richard M. Heiberger
The grouped boxplot is one of the features included in the HH package. An example is posted on my site http://astro.ocis.temple.edu/~rmh/HH/bwplot-color.pdf See also the R-help email with an example vaguely similar to yours: https://stat.ethz.ch/pipermail/r-help/2009-March/190541.html

[R] as.xts convert all my numeric data to character

2009-12-19 Thread David L. Van Brunt, Ph.D.
Hello, all... I've been playing with the TTR package and quantmod, and I'm loading the Chicago Board of Exchange put/call ratio data via a simple read.csv call... CBOEtotal-read.csv(file= http://www.cboe.com/publish/ScheduledTask/MktData/datahouse/totalpc.csv ,skip=1) this gives me a data frame

Re: [R] Package creation - require statement?

2009-12-19 Thread Charlie Sharpsteen
On Fri, Dec 18, 2009 at 3:50 PM, Jeff Breiwick jeff.breiw...@noaa.gov wrote: Thanks for you advice.  I do, in fact, have a call to RODBC in my function that uses RODBC functions. The first line of that function is require(RODBC). The odd thing is if I leave off ROBDC from the DESCRIPTION file

Re: [R] as.xts convert all my numeric data to character

2009-12-19 Thread ivan popivanov
Here is what worked for me: 1) Create a single xts object using one column and the index 2) Merge with the other columns tt = read.csv(c:/ttt/totalpc.csv, skip=1) xx = xts(tt$Call, order.by=as.Date(tt$Trade_date, format=%m/%d/%Y)) yy = merge(xx, tt$Put, tt$Total, tt$P.C.Ratio)

Re: [R] Lattice boxplots

2009-12-19 Thread Peng Cai
Thanks Richard. Which function I should explore in HH package to get such boxplot? Peng On Sat, Dec 19, 2009 at 6:06 PM, Richard M. Heiberger r...@temple.eduwrote: The grouped boxplot is one of the features included in the HH package. An example is posted on my site

Re: [R] Lattice boxplots

2009-12-19 Thread Richard M. Heiberger
All the examples have the code file that generate them listed in the captions. The specific panel function that is usually used is panel.bwplot.intermediate.hh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] DROP and KEEP statements in R

2009-12-19 Thread Wensui Liu
drop example. data(iris) summary(iris) Sepal.LengthSepal.Width Petal.LengthPetal.Width Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 Median :5.800 Median :3.000 Median :4.350 Median :1.300 Mean

Re: [R] integer(0) and NA do not equal FALSE

2009-12-19 Thread Gray Calhoun
Hi Jonathan, The function isTRUE is useful for this sort of thing: isTRUE(pmatch(hi, hop)) evaluates to FALSE. --Gray On Sat, Dec 19, 2009 at 12:47 PM, Jonathan jonsle...@gmail.com wrote: Hi,   A noobie question:  I'm simply trying to run a conditional statement that evaluates if a substring

[R] Remove rows in a matrix that match rows in another matrix

2009-12-19 Thread Raymond Danner
Dear R Community, The following seems like a simple problem, but I've been stuck on it for some time, with no luck using matching or subsetting functions. I'm trying to remove the rows from a large matrix that match rows in another large matrix. A (small scale) example: col1-c(A, B, C, D)

[R] read.table: mysterious line omissions

2009-12-19 Thread Jonathan
Hello again, I am simply trying to import a rectangular table of strings. The table's dimensions are 1990 x 2, yet my read.table() command can only find 362 of the rows (and they're not the first 362). I would've taken the time to figure out how to use scan, readLines, or some other tool

Re: [R] Remove rows in a matrix that match rows in another matrix

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 11:11 PM, Raymond Danner wrote: Dear R Community, The following seems like a simple problem, but I've been stuck on it for some time, with no luck using matching or subsetting functions. I'm trying to remove the rows from a large matrix that match rows in another

Re: [R] read.table: mysterious line omissions

2009-12-19 Thread David Winsemius
On Dec 19, 2009, at 11:42 PM, Jonathan wrote: Hello again, I am simply trying to import a rectangular table of strings. The table's dimensions are 1990 x 2, yet my read.table() command can only find 362 of the rows (and they're not the first 362). I would've taken the time to figure

Re: [R] read.table: mysterious line omissions

2009-12-19 Thread David Winsemius
On Dec 20, 2009, at 12:07 AM, David Winsemius wrote: On Dec 19, 2009, at 11:42 PM, Jonathan wrote: Hello again, I am simply trying to import a rectangular table of strings. The table's dimensions are 1990 x 2, yet my read.table() command can only find 362 of the rows (and they're not

Re: [R] read.table: mysterious line omissions

2009-12-19 Thread Jonathan
Tried deleting several line above and below line 362; did that and changed the extension. Still finds the same number of rows (362). Strange! Jonathan On Sun, Dec 20, 2009 at 12:19 AM, David Winsemius dwinsem...@comcast.netwrote: On Dec 20, 2009, at 12:07 AM, David Winsemius wrote: On

Re: [R] Remove rows in a matrix that match rows in another matrix

2009-12-19 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Raymond Danner Sent: Saturday, December 19, 2009 8:12 PM To: r-help@r-project.org Subject: [R] Remove rows in a matrix that match rows in another matrix Dear R Community,

[R] how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?

2009-12-19 Thread Jonathan
Last one for you guys: The command: length(gregexpr('cus','hocus pocus')[[1]]) [1] 2 returns the number of times the substring 'cus' appears in 'hocus pocus' (which is two) It's returning the number of **disjoint** matches. So: length(gregexpr('aa','aaa')[[1]]) [1] 1 returns 1. **What I

Re: [R] read.table: mysterious line omissions

2009-12-19 Thread Berend Hasselman
hedelhusk wrote: Tried deleting several line above and below line 362; did that and changed the extension. Still finds the same number of rows (362). On Sun, Dec 20, 2009 at 12:19 AM, David Winsemius dwinsem...@comcast.netwrote: On Dec 20, 2009, at 12:07 AM, David Winsemius wrote: