Re: [R] Principle components analysis on a large dataset

2009-08-20 Thread Jari Oksanen
Moshe Olshansky yahoo.com> writes: > > Hi Misha, > > Since PCA is a linear procedure and you have only 6000 observations, you do not need 68000 variables. Using > any 6000 of your variables so that the resulting 6000x6000 matrix is non-singular will do. You can choose > these 6000 variables (co

Re: [R] Histogram problem

2009-08-20 Thread Petr PIKAL
Hi R does what you said to it it shall do! Without **reproducible** code and explanation what you did, what you get and what you **expect** to get it would be quite complicated task to understand what your code actually do. e.g. this > > for (i in 1:Count){ > > > > for (j in 1:Count2){

[R] Keeping track of memory usage

2009-08-20 Thread Stavros Macrakis
How can I determine how much memory a given piece of my code is allocating (directly or indirectly)? -- essentially, the space analogue of system.time, something like this: system.space( x <- rnorm(1) ) 1 Vcells system.space( for (i in 1:1000) x <- rnorm(1) ) 1

[R] Possible bug with lrm.fit in Design Library

2009-08-20 Thread Noah Silverman
Hi, I've come across a strange error when using the lrm.fit function and the subsequent predict function. The model is created very quickly and can be verified by printing it on the console. Everything looks good. (In fact, the performance measures are rather nice.) Then, I want to use th

Re: [R] extra .

2009-08-20 Thread Moshe Olshansky
My guess is that 6. comes for 6.0 - something which comes from programming languages where 6 represents 6 as integer while 6. (or 6.0) represents 6 as floating point number. --- On Fri, 21/8/09, kfcnhl wrote: > From: kfcnhl > Subject: [R] extra . > To: r-help@r-project.org > Received: Friday

[R] extra .

2009-08-20 Thread kfcnhl
sigma0 <- sqrt((6. * var(maxima))/pi) What does the '.' do here? -- View this message in context: http://www.nabble.com/extra-.-tp25073255p25073255.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list htt

Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Frank E Harrell Jr
Gabor Grothendieck wrote: Try: w <- function(formula, ...) do.call("lm", list(formula, ...)) Thanks very much Gabor. That seems to do the trick. Thanks also Rolf and Chuck. Chuck I had tried your approach earlier but ran into a problem. Frank On Thu, Aug 20, 2009 at 7:01 PM, Frank E

Re: [R] Understanding R code

2009-08-20 Thread Rolf Turner
On 21/08/2009, at 3:30 PM, David Winsemius wrote: On Aug 20, 2009, at 4:31 PM, kfcnhl wrote: What is 1. par.ests <- optimfit$par Just a guess... the parameter estimates from an optimization procedure? 2. fisher <- hessb(negloglik, par.ests, maxvalue=maxima); Probably the Fisher Inf

[R] a --no-save option for Rprofile.site?

2009-08-20 Thread Scott Hyde
I need to set up Rcmdr for use in a testing center that uses Windows. Since it is in a testing center, we don't want to have data saved, and want it cleared (or never saved) each time R or Rcmdr is run. The method I used to get Rcmdr to run automatically is to add the lines: -

Re: [R] Understanding R code

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 4:31 PM, kfcnhl wrote: What is 1. par.ests <- optimfit$par Just a guess... the parameter estimates from an optimization procedure? 2. fisher <- hessb(negloglik, par.ests, maxvalue=maxima); Probably the Fisher Information matrix. 3. varcov <- solve(fisher); I seem

Re: [R] Problem with predict.coxph

2009-08-20 Thread Marc Schwartz
On Aug 20, 2009, at 9:26 PM, Therneau, Terry M., Ph.D. wrote: Ramon and Michael There were 2 simple issues: first a set of fixes I made in May that hadn't been pushed out to CRAN yet; second I needed to replace 'terms' with 'delete.response(terms)' in one place so that predict didn't try

Re: [R] Appending elements according to criteria to an empty array

2009-08-20 Thread Marc Schwartz
On Aug 20, 2009, at 9:30 PM, Steven Kang wrote: Hi all R users, I am trying to extract elements from an array (x as shown below) where the difference between the consecutive elements does not equal 1. The desired output is: j = 6,17,27,38,58,69,79,90 However, the code belo

Re: [R] Problem with predict.coxph

2009-08-20 Thread Therneau, Terry M., Ph.D.
Ramon and Michael There were 2 simple issues: first a set of fixes I made in May that hadn't been pushed out to CRAN yet; second I needed to replace 'terms' with 'delete.response(terms)' in one place so that predict didn't try to find a response that it doesn't need. You can grab the up to

[R] Principle components analysis on a large dataset

2009-08-20 Thread misha680
Dear Sirs: Please pardon me I am very new to R. I have been using MATLAB. I was wondering if R would allow me to do principal components analysis on a very large dataset. Specifically, our dataset has 68800 variables and around 6000 observations. Matlab gives "out of memory" errors. I have trie

[R] Video demo of using svSocket with data.table

2009-08-20 Thread Matthew Dowle
Dear r-help, If you haven't already seen this then : http://www.youtube.com/watch?v=rvT8XThGA8o The video consists of typing at the console and graphics, there is no audio or slides. Please press the HD button and maximise. Its about 8 mins. Regards, Matthew __

[R] Appending elements according to criteria to an empty array

2009-08-20 Thread Steven Kang
Hi all R users, I am trying to extract elements from an array (x as shown below) where the difference between the consecutive elements does not equal 1. The desired output is: j = 6,17,27,38,58,69,79,90 However, the code below only returns: j = 1,69,79,90 I am a

[R] Understanding R code

2009-08-20 Thread kfcnhl
What is 1. par.ests <- optimfit$par 2. fisher <- hessb(negloglik, par.ests, maxvalue=maxima); 3. varcov <- solve(fisher); 4. par.ses <- sqrt(diag(varcov)); Thanks a lot, fit.GEV <- function(maxima) { sigma0 <- sqrt((6. * var(maxima))/pi) mu0 <- mean(maxima) - 0.57722 * sigma0 xi0 <- 0.1 theta <

Re: [R] RGoogleDocs/RCurl through proxy

2009-08-20 Thread Remko Duursma
Duncan, I tested the new RCurl with the proxy option, and it works great (I tested a curlPerform example, which does not work otherwise). Problem with RGoogleDocs though: > auth = getGoogleAuth("remkoduur...@gmail.com", GPASS) Error in strsplit(type, "/")[[1]] : subscript out of bounds If I g

Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Charles C. Berry
On Thu, 20 Aug 2009, Frank E Harrell Jr wrote: Dear Colleagues: I would like to write a front end for a modeling function, but run into trouble when passing a weights argument. You might want to look at the code at the beginning of lm for some ideas. Something like: w <- function(formula,

Re: [R] Principle components analysis on a large dataset

2009-08-20 Thread Moshe Olshansky
Hi Misha, Since PCA is a linear procedure and you have only 6000 observations, you do not need 68000 variables. Using any 6000 of your variables so that the resulting 6000x6000 matrix is non-singular will do. You can choose these 6000 variables (columns) randomly, hoping that the resulting matr

[R] trouble with Vista & reading files

2009-08-20 Thread Mike Williamson
All, I am having trouble with a "read.table()" function that is inside of another function. But if I call the function by itself, it works fine. Moreover, if I run the script on a Mac OS X (with the default Mac OS X version of R installed, rev 2.8), it works fine. But it does not work if I r

[R] Principle components analysis on a large dataset

2009-08-20 Thread misha680
Dear Sirs: Please pardon me I am very new to R. I have been using MATLAB. I was wondering if R would allow me to do principal components analysis on a very large dataset. Specifically, our dataset has 68800 variables and around 6000 observations. Matlab gives "out of memory" errors. I have trie

Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Gabor Grothendieck
Try: w <- function(formula, ...) do.call("lm", list(formula, ...)) On Thu, Aug 20, 2009 at 7:01 PM, Frank E Harrell Jr wrote: > Dear Colleagues: > > I would like to write a front end for a modeling function, but run into > trouble when passing a weights argument. > > y <- 1:5 > x <- c(1,3,2,5,4)

Re: [R] Wind-data analysis with R?

2009-08-20 Thread Thomas Adams
Oliver, You may consider looking at the climatol: Some Tools for Climatology (http://cran.r-project.org/) contributed package. This may come close to what you're looking for. I would suggest using R with GRASS GIS (http://grass.osgeo.org/), which is a powerful combination. Tom Oliver Bandel

[R] Problem passing a statistical model as an argument

2009-08-20 Thread Frank E Harrell Jr
Dear Colleagues: I would like to write a front end for a modeling function, but run into trouble when passing a weights argument. y <- 1:5 x <- c(1,3,2,5,4) w <- function(formula, ...) lm(formula, ...) lm(y ~ x, weights=c(1,1,1,2,2)) w(y ~ x) w(y ~ x, weights=c(1,1,1,2,2)) Error in eval(expr

[R] Wind-data analysis with R?

2009-08-20 Thread Oliver Bandel
Hello, are there people outside who use R for analysis of wind-measurement data (meteorological or for planning of wind power stations)? Are there already scripts/modules available for analysing and displaying/plotting wind data in the way it is done in projection/planning of wind power stations?

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread guox
> > On Aug 20, 2009, at 4:07 PM, g...@ucalgary.ca wrote: > >>> >>> On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote: >>> Thanks! > > On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: > >> I got two questions on factors in regression: >> >> Q1. >> In a table, t

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Stephan Kolassa
Hi Rakknar, I believe that the menu command File -> Save to File (or some such, I use the German version) in the R GUI for Windows (I'm unclear on your OS) has not yet been suggested. This writes a file containing the entire R session. Does this create the kind of log you are looking for? HT

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 4:07 PM, g...@ucalgary.ca wrote: On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote: Thanks! On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread guox
> > On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote: > >> Thanks! >>> >>> On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: >>> I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and

Re: [R] change default measurement unit to millimetre

2009-08-20 Thread Patrick Connolly
On Thu, 20-Aug-2009 at 10:25PM +1000, Jim Lemon wrote: > e-letter wrote: >> Readers, >> >> How do I configure R so that all units of measurement are in >> millimetres? For example if I want to set the width of a graph, I want >> to write: >> width=100 >> and R interprets this value as millimetres.

Re: [R] Embedding lists in matrices and matrices in lists

2009-08-20 Thread Michael Kogan
In fact there should be just one level of nesting but the top level object must be a matrix, not a list, since the matrices that should be embedded in it must be grouped after their nrow _and_ ncol - thus the container object must be two-dimensional, a matrix. The only question is how to get ri

[R] Calculating loess value

2009-08-20 Thread Noah Silverman
Hello, I'm attempting to evaluate the accuracy of the probability predictions for my model. As previously discussed here, the AUC is not a good measure as I'm not concerned with classification accuracy but probability accurcy. It was suggested to me that the loess function would be a good m

Re: [R] PowerCut Killed R - is my code retrievable?

2009-08-20 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Rolf Write: > If you've been cut-and-pasting from a text editor, then your commands > *might* be in the file .Rhistory. Unfortunately this history gets saved > only when you exit R (and by default only when you also say ``yes'' to > saving the workspace) or if you explicitly savehistory(). Was ho

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 3:42 PM, g...@ucalgary.ca wrote: Thanks! On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Rakknar
Thanks to all for your useful comments. I'll try to take them into account to advance with my research. If I got stuck again I'll ask again. Greetings! Greg Snow-2 wrote: > > If you are using a pre created script file, then you may want to consider > going one more step and creating a sweave

Re: [R] problems with RODBC, sqlQuery

2009-08-20 Thread Marc Schwartz
On Aug 20, 2009, at 12:49 PM, JoK LoQ wrote: Hello, Im trying to get a Oracle database to R, but I'm having problems with most of SQL sintax. Suppose that Im trying to bring a table "TABLE" with columns "COL1","COL2",.. from schema "SCHEMA". What am I doing wrong? library(RODBC) channel<

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread guox
Thanks! > > On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: > >> I got two questions on factors in regression: >> >> Q1. >> In a table, there a few categorical/factor variables, a few numerical >> variables and the response variable is numeric. Some factors are >> important >> but others not.

[R] Subsetting expand.grid() result

2009-08-20 Thread jack.kel...@bigpond.com
Hi, I have only 2 months' experience with R. Here is one sort of problem that arose: * Site 1 has transects A,B,C,D. * Site 2 has transects A,B,C,D,E,F. * Site 3 has transect A. * ... and Site 1000 has transects A,B,C. At each transect, measure ALL of the various categories belonging to propertie

Re: [R] categorized barplot

2009-08-20 Thread John Kane
I think you want a barplot. I don't see what a histogram will add. Your attachement seems to have been lost so I am just guessing what you might want but, assuming you have a data.frame try barplot(as.matrix(xx[,2:3]), beside = TRUE) dd <- t(as.matrix(xx[,2:3])) colnames(dd) <- xx[,1] barplo

Re: [R] Geometric mean of rows in matrix

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 2:22 PM, Edward Chen wrote: Is there a function or an easier way to computer geometric means of each rows in a nxn matrix and spit out in an 1xn matrix ? > xx <- matrix(10+rnorm(100), 10) > apply(xx, 1, function(x) exp(mean(log(x))) ) [1] 10.084711 10.034054 9.622909

[R] categorized barplot

2009-08-20 Thread Rafael Moral
Sorry for the double post, I couldn't attach the image in the previous one, so I uploaded it to imageshack, the link is http://img32.imageshack.us/img32/2042/imageyvh.jpg Thanks! Dear useRs, I can't seem to find out how to categorize my histogram. I have the following dataset: Time   

Re: [R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread Tal Galili
Hello everyone, David, sorry for the confusion. I meant keeping the inner-order of column "b" inside the new order of column "a". Chuck, Don and Greg - Each of you gave me a new way to approach this that I didn't think about - thank you very much for your help! I ran a competition between all th

[R] Canonical Discriminant Function Analysis

2009-08-20 Thread AbouEl-Makarim Aboueissa
Dear R users: Could you please help me out how to use R to get and interpret Standardized discriminant functions and structure coefficients for sex, Degree_Program, and Enrol_USM Please find the data file at: http://www.usm.maine.edu/~aaboueissa/Rhelps/Rhelps.html data files are (xls file

Re: [R] Geometric mean of rows in matrix

2009-08-20 Thread Benilton Carvalho
set.seed(1) x <- matrix(runif(1000), 100) system.time(tmp1 <- exp(rowMeans(log(x system.time(tmp2 <- apply(x, 1, function(y) prod(y)^(1/length(y all.equal(tmp1, tmp2) ## tmp1 is more robust, btw On Aug 20, 2009, at 3:22 PM, Edward Chen wrote: Is there a function or an easier way to comp

[R] Factor

2009-08-20 Thread ogbos okike
Hi all, I have three columns of lightning data. The first column is dates, the second and third are latitude and longitude respectively. The data is extremely large as many observations are made every second. Using the factor function reduces the activity to a few number per a day. But factor and

[R] categorized barplot

2009-08-20 Thread Rafael Moral
Dear useRs, I can't seem to find out how to categorize my histogram. I have the following dataset: Time    First.day  Second.day 08:00-10:00    9     8 10:00-12:00   13   15 12:00-14:00    9     9 14:00-16:00   10    9 I attached a jpeg fi

Re: [R] How to extract row values?

2009-08-20 Thread John Kane
--- On Thu, 8/20/09, Peter Ehlers wrote: > From: Peter Ehlers > Subject: Re: [R] How to extract row values? > To: "John Kane" > Cc: r-help@r-project.org, "Henrik Kallberg" > Received: Thursday, August 20, 2009, 12:08 PM > > John Kane wrote: > > What you have is a one-dimensional vector.  >

[R] Geometric mean of rows in matrix

2009-08-20 Thread Edward Chen
Is there a function or an easier way to computer geometric means of each rows in a nxn matrix and spit out in an 1xn matrix ? -- Edward Chen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] optimization free software

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 2:08 PM, Gaspar Núñez wrote: Hi i´m starting to work with free software (with free as in freedom) i've been working with GAMS (General Algebraic Modeling System) to solve static and dynamic optimization problems and non-linear large systems of equations i'm wondering if t

Re: [R] Questions on factors in regression analysis

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 1:46 PM, g...@ucalgary.ca wrote: I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some factors are important but others not. How to determine which cate

[R] optimization free software

2009-08-20 Thread Gaspar Núñez
Hi i´m starting to work with free software (with free as in freedom) i've been working with GAMS (General Algebraic Modeling System) to solve static and dynamic optimization problems and non-linear large systems of equations i'm wondering if there is any free software and documentation on the su

Re: [R] Basic question: Reading in multiple choice question responses to a single column in data frame

2009-08-20 Thread Magnus Torfason
On 8/19/2009 11:06 PM, Damion Dooley wrote: Slight addendum. Working from your code, I found 1 line of code does the conversion: myColumn = unlist(strsplit(as.character(myData[[myQuestion]]),",")); But the dataframe you set up may prove more useful. I'm glad my suggestion was useful.

[R] problems with RODBC, sqlQuery

2009-08-20 Thread JoK LoQ
Hello, Im trying to get a Oracle database to R, but I'm having problems with most of SQL sintax. Suppose that Im trying to bring a table "TABLE" with columns "COL1","COL2",.. from schema "SCHEMA". What am I doing wrong? library(RODBC) channel<-odbcConnect("xxx",uid="xxx",pwd="xxx") sqlQuery(cha

[R] Questions on factors in regression analysis

2009-08-20 Thread guox
I got two questions on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some factors are important but others not. How to determine which categorical variables are significant to the response variable?

Re: [R] function of probability for normal distribution

2009-08-20 Thread Greg Snow
It looks like you are reinventing wheels here (not necessarily a bad thing). If you want the probabilities associated with the normal distribution, then look at the help for dnorm and pnorm functions. If you are recreating this as a learning experience/homework, then you should be up front abou

Re: [R] globally set digits=3 in Sweave

2009-08-20 Thread Duncan Murdoch
On 8/20/2009 12:17 PM, Liviu Andronic wrote: On 8/20/09, Duncan Murdoch wrote: Why not put <>= options(digits=4) @ somewhere near the top of your document? I did so, but it has no practical effect on \Sexpr{} (which I'm interested in, and failed to mention in the original e-mail). Wit

Re: [R] Is there a construct for conditional comment?

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 1:19 PM, Duncan Murdoch wrote: On 8/20/2009 11:54 AM, Steve Jaffe wrote: Why not if ( 0 ) { commented with zero } else { commented with one } But an extremely simple modification "succeeds": if ( 0 ) {" commented with zero "} else {" commented with one "} Returns:

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Greg Snow
If you are using a pre created script file, then you may want to consider going one more step and creating a sweave file. Then you can process this file and the results will include the commands (unless you suppress them) as well as the output, nicely formatted. It can also include graphics an

Re: [R] Is there a construct for conditional comment?

2009-08-20 Thread Duncan Murdoch
On 8/20/2009 11:54 AM, Steve Jaffe wrote: Why not if ( 0 ) { commented with zero } else { commented with one } Because that doesn't work unless the comments are syntactically correct R. For example, yours gives: Error in source("clipboard") : clipboard:2:11: unexpected symbol 1: if ( 0 )

Re: [R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread Greg Snow
Here is a one liner: (yy <- do.call( rbind, sample( split(xx, xx$a) ) )) Basically reading from inside out, it splits the data frame by a (keeping the structure of b intact within each data frame) and returns it as a list, then that list is randomized, then put back together into a single data

Re: [R] Is there a construct for conditional comment?

2009-08-20 Thread Greg Snow
That works if everything within the brackets is proper R code (though if(FALSE) reads better to me). But sometimes this (or similar) question is asked when the user wants to comment out a section of code that is currently not working, or someone may even want to do something like: y <- rnorm(

Re: [R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread Charles C. Berry
On Thu, 20 Aug 2009, Tal Galili wrote: Hello dear R-help group. My task looks simple, but I can't seem to find a "smart" (e.g: non loop) solution to it. Task: I wish to randomize a data.frame by one column, while keeping the inner-order in the second column as is. xx[ order( sample(

Re: [R] help with regular expressions in R

2009-08-20 Thread Mark Kimpel
Thanks guys. I've pulled my O'Reilly book and will begin reviewing it. Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & M

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Rakknar
"This is why sink() has the split=TRUE option, which logs output to a connection and sends it to the screen. The R sink("analysis.log",split=TRUE) is almost identical to the Stata log using analysis.log with sink() to close the log and flush to disk at the end of the session." I've alre

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 10:59 AM, Rakknar wrote: "To echo what others have said, it is often easier to write a script (in STATA terms, a "do" file) of commands and then "source" the script. When it runs to your satisfaction, usually not the first time for me, there are several ways to store t

[R] Problem:: Passing r list to java method as parameter

2009-08-20 Thread bed.si...@oracle.com
Hi Simon, I have some doubts in the function calling R. I am using the R 2.9.1 with window XP. I am passing the r list to the java method as a parameter. And then try to read this r list from java code. Is it possible that we can read the r list into the java code? My scrip

Re: [R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 11:22 AM, Tal Galili wrote: Hello dear R-help group. My task looks simple, but I can't seem to find a "smart" (e.g: non loop) solution to it. Task: I wish to randomize a data.frame by one column, while keeping the inner-order in the second column as is. So for examp

Re: [R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread Don MacQueen
I believe this will do what you want: tmp1 <- split(xx, xx$a) do.call(rbind, tmp1[ sample(length(unique(xx$a))) ]) The idea is to split the dataframe, and then reassemble in a random order. Whether or not it will be faster for a large dataframe, I don't know. There's probably also an index

[R] Using 'unlist' (incorrectly?!) to collate a series of objects

2009-08-20 Thread Steve Murray
Dear R Users, I am attempting to write a new netCDF file (using the ncdf) package, using 120 grids I've created and which are held in R's memory. I am reaching the point where I try to put the data into the newly created file, but receive the following error: > put.var.ncdf(evap_file, evap_di

Re: [R] re ading in array

2009-08-20 Thread David Winsemius
On Aug 20, 2009, at 9:30 AM, kobiwan wrote: I saved an array of dim=c(28,28,28,28) using write.table. When I try to read it in with read.table I get a data frame of dim=c(28,28^3). Of course it is very important to preserve the structure of the saved array when I read it in. Does anyone

Re: [R] help with regular expressions in R

2009-08-20 Thread William Dunlap
Replace ".*" (any number of any character) with "[^]]*" (any number of anycharacter except "]") or use the perl-specific non-greedy operator, ?, which means to match the shortest amount of text matching the pattern instead of the longest. gsub("\\[.*?\\]", "", text, perl=TRUE) Dealing with nes

Re: [R] help with regular expressions in R

2009-08-20 Thread Mark Kimpel
Well, I guess I'm not quite there yet. What I gave earlier was a simplified example, and did not accurately reflect the complexity of the task. This is my real world example. As you can see, what I need to do is delete an arbitrary number of characters, including brackets and parens enclosing them

Re: [R] globally set digits=3 in Sweave

2009-08-20 Thread Liviu Andronic
On 8/20/09, Duncan Murdoch wrote: > Why not put > > <>= > options(digits=4) > @ > > somewhere near the top of your document? > I did so, but it has no practical effect on \Sexpr{} (which I'm interested in, and failed to mention in the original e-mail). With <>= options(digits=4) @ , the fol

Re: [R] expanding 1:12 months to Jan:Dec

2009-08-20 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Moshe Olshansky > Sent: Thursday, August 20, 2009 1:21 AM > To: r-help@r-project.org Help; Liviu Andronic > Subject: Re: [R] expanding 1:12 months to Jan:Dec > > One possible (bu

Re: [R] How to extract row values?

2009-08-20 Thread Peter Ehlers
John Kane wrote: What you have is a one-dimensional vector. Is that true? I think that you are up against an R default. You are going to get some names no matter what you do. You can always change them using the names() command, e.g. names(xx) <- c("a","b", "c") to replace the v1 v2 v3

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Thomas Lumley
On Thu, 20 Aug 2009, Ottorino-Luca Pantani wrote: Rakknar ha scritto: 1. Make a log. I've been using Stata and there i have a great tool to register what the program do: the log file, wich it's a simple .txt file where Stata writes every output it makes (not graphics of course). When I wanted

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Barry Rowlingson
On Thu, Aug 20, 2009 at 3:59 PM, Rakknar wrote: > I already using script. I'm using Tinn-R to write them. Thanks for the > recommendation of the R2HTML package I'll see how to use it right now. If you run your script using the command line: R CMD BATCH script.R script.Rout then you'll get a f

[R] contour plot

2009-08-20 Thread FMH
Hi, Could someone give some ideas on plotting a contour by using geoR package, please? Thank you Kagba [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do r

[R] [R-pkgs] New package for multivariate Kalman filtering, smoothing, simulation and forecasting

2009-08-20 Thread Jouni Lehtonen
Dear all, I am pleased to announce the CRAN release of a new package called 'KFAS' - Kalman filter and smoother. The package KFAS contains functions of multivariate Kalman filter, smoother, simulation smoother and forecasting. It uses univariate approach algorithm (aka sequential processing), whi

Re: [R] RMySQL - overwrite record, not table

2009-08-20 Thread whizvast
Hi, Adrian- If you use "overwrite=T" parameter, you will overwrite the entire table, not each record. this is the essence of my problem and i still haven't found out right solution. i am thinking of writing my own MySQLwriteTable function... Thank you for your answer anyway! Adrian Dusa wrot

Re: [R] Is there a construct for conditional comment?

2009-08-20 Thread Steve Jaffe
Why not if ( 0 ) { commented with zero } else { commented with one } Greg Snow-2 wrote: > > I believe that #if lines for C++ programs is handled by the preprocessor, > not the compiler. So if you want the same functionality for R programs, > it would make sense to just preprocess the R file.

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread jim holtman
Put the objects that you want to save in a 'list' and then 'save' the list. You can build up the contents of the list dynamically in your program and then save it at the appropriate point. On Thu, Aug 20, 2009 at 10:59 AM, Rakknar wrote: > > "To echo what others have said, it is often easier to w

Re: [R] help with regular expressions in R

2009-08-20 Thread Chuck Taylor
Mark, Try this: > myCharVec [1] "[the rain in spain]" "(the rain in spain)" > gsub("\\[.*\\]", "", myCharVec) [1] """(the rain in spain)" You need two backslashes to "escape" the square brackets. The regular expression "\\[.\\]" translates to "a [ followed by 0 or more insta

Re: [R] [SPAM] - help with regular expressions in R - Bayesian Filter detected spam

2009-08-20 Thread davidr
Possibly just a typo: > gsub('\\[.*\\]', '', myCharVec) ^^ [1] """(the rain in spain)" HTH, -- David -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Kimpel Sent: Thursday, August 20, 2009 10:31 A

Re: [R] help with regular expressions in R

2009-08-20 Thread jim holtman
How about this: > myCharVec <- c("[the rain in spain]", "(the rain in spain)") > gsub('\\[.*\\]', '', myCharVec) [1] """(the rain in spain)" > you had "*." when you should have ".*" On Thu, Aug 20, 2009 at 11:30 AM, Mark Kimpel wrote: > I'm having trouble achieving the resul

[R] help with regular expressions in R

2009-08-20 Thread Mark Kimpel
I'm having trouble achieving the results I want using a regular expression. I want to eliminate all characters that fall within square brackets as well as the brackets themselves, returning an "". I'm not sure if it's R's use of double slash escapes or something else that is tripping me up. If I on

Re: [R] eval and evironments: call local function in a global function

2009-08-20 Thread Duncan Murdoch
On 8/20/2009 4:27 AM, Renaud Gaujoux wrote: Hi, in my project I want the user to be able to write hook functions that are in turn called in my main code. I'd like the user's hooks to be able to call some function that set a variable outside their running environment. The trick is that this v

Re: [R] globally set digits=3 in Sweave

2009-08-20 Thread Duncan Murdoch
On 8/20/2009 6:19 AM, Liviu Andronic wrote: Dear all I would like to globally set options(digits = 4) in an Sweave document. I've read this thread [1] where it was suggested to set the above option and pass every printed number through format(). Aanother way to do so would be to round(expr, 4).

[R] simple randomization question: How to perform "sample" in chunks

2009-08-20 Thread Tal Galili
Hello dear R-help group. My task looks simple, but I can't seem to find a "smart" (e.g: non loop) solution to it. Task: I wish to randomize a data.frame by one column, while keeping the inner-order in the second column as is. So for example, let's say I have the following data.frame: xx <-data.

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Steve Jaffe
For history of both commands and output, consider running R inside emacs using the ESS package and simply saving the buffer to a file. If you save the session as an "S transcript" file (extension .St) it is also easy to reload and re-execute any part of it. Emacs or xemacs is available on most pl

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Ottorino-Luca Pantani
Rakknar ha scritto: 1. Make a log. I've been using Stata and there i have a great tool to register what the program do: the log file, wich it's a simple .txt file where Stata writes every output it makes (not graphics of course). When I wanted to make the same thing with R I started to use the f

Re: [R] ANCOVA with defined error terms

2009-08-20 Thread Richard M. Heiberger
Yes, I meant summary(). anova() isn't defined for aovlist objects and summary() is. Warning message: In aov(kotz.mice ~ kotz.coon + block * veget * fruit * time - block:veget:fruit:time + : Error() model is singular You will need to investigate the singular Error() model. You might want

[R] predict.HoltWinters source misunderstanding.

2009-08-20 Thread rkevinburton
If I look in the stats package for the 'R' source code for predict.HoltWinters I see the following lines: vars <- function(h) { psi <- function(j) object$alpha * (1 + j * object$beta) + (j%%f == 0) * object$gamma * (1 - object$alpha) var(residuals(object)) * if (o

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Rakknar
Bert: Thanks for your help. I'll try to clarify some of your doubts "1. logs. help.search("history") and ?savehistory shows you that R does exactly what you want very easily (depending on the platform, which contrary to the posting guide's request, you did not tell us)." I've already find out a

Re: [R] Several simple but hard tasks to do with R

2009-08-20 Thread Rakknar
"To echo what others have said, it is often easier to write a script (in STATA terms, a "do" file) of commands and then "source" the script. When it runs to your satisfaction, usually not the first time for me, there are several ways to store the output. Both the R2HTML and prettyR packages co

[R] possible problem with plot.lm

2009-08-20 Thread Benilton Carvalho
Hi, Here's one toy example that shows what I believe to be a problem with plot.lm. This was brought up by another user (Marcos Tadeu Andrade Cordeiro). I took a look at the source and the problem appears to be related to the fact that you need to reorder the data by the group means and th

Re: [R] Insert rows in between dataframes

2009-08-20 Thread Henrique Dallazuanna
Try this also: as.data.frame(t(sapply(append(split(mydata, row.names(mydata)), list(c('f', 6)), after = 2), as.matrix))) The after argument of append can be the line number where you want the new line. On Thu, Aug 20, 2009 at 8:18 AM, Moumita Das wrote: > Hi all, > > Can anyone suggest me how t

Re: [R] getting R 2.9.1 from the tar.gz file

2009-08-20 Thread Dirk Eddelbuettel
On Thu, Aug 20, 2009 at 10:57:52AM +0300, Lazarus Mramba wrote: > Dear Sir, > > I am almost giving up on getting the R-2.9.1 on the ubuntu 9.04 using the > instructions found on the R site. > > I decided to use the R-2.9.1.tar.gz and untarred it. > > I then typed ./configure and the results are

[R] Odp: Histogram problem

2009-08-20 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 20.08.2009 15:33:38: > I'm trying to create a histogram from the following code, but my data keeps > adding the Num vector and plotting that. My data in the CSV file is just > one vector. Does anyone know why? Well, I think that only you know why CS

  1   2   >