[R] How can this code be improved?

2009-11-11 Thread Richard R. Liu
I am running the following code on a MacBook Pro 17" Unibody early 2009 with 8GB RAM, OS X 10.5.8, R 2.10.0 Patch from Nov. 2, 2009, in 64-bit mode. freq.stopwords <- numeric(0) freq.nonstopwords <- numeric(0) token.tables <- list(0) i.ss <- c(0) cat("Beginning at ", date(), ".\n") for (i.d i

Re: [R] Finding covariance in a lmer mixed effects model

2009-11-11 Thread Viechtbauer Wolfgang (STAT)
The way you have specified the model implies that the covariance is 0. If you actually want to estimate the covariance, you need to use: fm1 <- lmer(fpg ~ 1 + time + (time|ID), fpg_lme) Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and St

[R] Reading a data file one record at a time [SEC=UNCLASSIFIED]

2009-11-11 Thread Justin Peter
Dear r-help, I have a radar data file in the following format: nrays for (1 to n_rays) { some_data_info for (1 to n_gates) { some_data_info} } N_rays=360 and n_gates=950 The data looks something like: Header line1 Ray1 header gate1 var1, var2,.,varN ...

[R] trap window pop up when running 'bugs' in R

2009-11-11 Thread Dongli Zhou
Hi, I'm writing to ask what is the reason that a Trap window always pops up in WinBUGS? I'm tring to run the function 'bugs' in R for a zero-inflated gaussian model. The contents appear in the Trap window is as follows: *incompatible copy BugsCmds.TextError [03A1H] .begINTEGER

[R] saving custom functions to existing library

2009-11-11 Thread venkata kirankumar
Hi all, I writen one function in Rgui(R Editor) I saved it as testfunction.R and while I am running that file using source(C:/testfunction.R) its running and it is giving subsequent result insted of this there is any thing like to save my function to save in existing library to reuse it wh

[R] Non linear programming optimization (which package to use?)

2009-11-11 Thread Jerome Chong
Hello, 1) Is there any nonlinear programming optmizer that I can user for the following problem? Obj function: (max) revenue = price * volume Constraints: price and volume pair must be from the following variable data set: Variable data set: # price volume 1 10 500 2 20 450 3 30 330 4 40 250 5 5

Re: [R] redundant factor levels after subsetting a dataset

2009-11-11 Thread Daniel Malter
Thanks, works a charme. I was not aware that it had been answered just yesterday. The solution previously suggested in this thread did not work for me. Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: David Winsemius [m

[R] Finding covariance in a lmer mixed effects model

2009-11-11 Thread Kurt Smith
I am having difficulty finding the covariance for the random effects in a mixed effects model. I fit this model: fm1 <- lmer(fpg ~ 1 + time + (1|ID) + (0+time|ID),fpg_lme) and want to find the covariance between the time and intercept random effects. I tried using VarCorr (see below) but it does

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
<> Thanks! So I guess you're suggesting something like (add-hook 'comint-output-filter-functions (lambda (s) (save-restriction (narrow-to-region comint-last-output-start (+ -1 (process-mark (get-buffer-process (current-buffer) ;; stop o

Re: [R] Partial correlations and p-values

2009-11-11 Thread dadrivr
Awesome, that's what I was looking for. I have two additional questions: (1) What can I do if the variables are of different lengths? (2) How do I update the formula if I want to control for more than one variable. Let's take the following example: x <- c(1,20,14,7,9) y <- c(5,6,7,9,10,11) z <-

Re: [R] using R selecte data record?

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 8:53 PM, chalie epps wrote: I have a database containing all the football tournament, however I want only to filter out all the pairwise events. Briefly: If A matches B & B matches A, we reserve the two tournament, otherwise forsake this tournament. Sounds like you might w

Re: [R] By processing on two variables at once?

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 8:51 PM, zwarren wrote: Hello! I'm trying to runs stats on two vars at a time in a big data frame. I knew how to do this in SAS many years ago, but have half-forgotten that as well! I need, for instance, mean(value) by x-y combination: x y z value 1 1 1

Re: [R] By processing on two variables at once?

2009-11-11 Thread Steve Lianoglou
Hi, On Wed, Nov 11, 2009 at 8:51 PM, zwarren wrote: > > Hello! > > I'm trying to runs stats on two vars at a time in a big data frame.  I knew > how to do this in SAS many years ago, but have half-forgotten that as well! > > I need, for instance, mean(value) by x-y combination: > x   y   z   valu

Re: [R] naive "collinear" weighted linear regression

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 7:45 PM, Mauricio Calvao wrote: Hi there Sorry for what may be a naive or dumb question. I have the following data: > x <- c(1,2,3,4) # predictor vector > y <- c(2,4,6,8) # response vector. Notice that it is an exact, perfect straight line through the origin and slope

[R] By processing on two variables at once?

2009-11-11 Thread zwarren
Hello! I'm trying to runs stats on two vars at a time in a big data frame. I knew how to do this in SAS many years ago, but have half-forgotten that as well! I need, for instance, mean(value) by x-y combination: x y z value 1 1 110 1 1 220 1 2 130 with results: x

[R] using R selecte data record?

2009-11-11 Thread chalie epps
I have a database containing all the football tournament, however I want only to filter out all the pairwise events. Briefly: If A matches B & B matches A, we reserve the two tournament, otherwise forsake this tournament. Please help me, thankx. __ R-he

Re: [R] redundant factor levels after subsetting a dataset

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 9:00 PM, Daniel Malter wrote: #I have a data frame with a numeric and a character variable. x=c(1,2,3,2,0,2,-1,-2,-4) md=c(rep("Miller",3), rep("Richard",3),rep("Smith",3)) data1=data.frame(x,md) #I subset this data.frame in a way such that one level of the character va

[R] redundant factor levels after subsetting a dataset

2009-11-11 Thread Daniel Malter
#I have a data frame with a numeric and a character variable. x=c(1,2,3,2,0,2,-1,-2,-4) md=c(rep("Miller",3), rep("Richard",3),rep("Smith",3)) data1=data.frame(x,md) #I subset this data.frame in a way such that one level of the character variable does not appear in the new dataset. data2=data1

Re: [R] Partial correlations and p-values

2009-11-11 Thread Peter Ehlers
dadrivr wrote: I'm trying to write code to calculate partial correlations (along with p-values). I'm new to R, and I don't know how to do this. I have searched and come across different functions, but I haven't been able to get any of them to work (for example, pcor and pcor.test from the ggm

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
Thanks for the suggestion. I'mm familiar with the truncate-lines variable, but that's not quite what I was looking for. I don't want the padding spaces displayed, but I do want to see long strings at the end of the line. Thanks anyway, -s On Wed, Nov 11, 2009 at 5:40 PM, Richard

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread RICHARD M. HEIBERGER
On Wed, Nov 11, 2009 at 8:12 PM, Stavros Macrakis wrote: > Thanks for the suggestion. I'mm familiar with the truncate-lines variable, > but that's not quite what I was looking for. I don't want the padding > spaces displayed, but I do want to see long strings at the end of the line. Then we can

[R] naive "collinear" weighted linear regression

2009-11-11 Thread Mauricio Calvao
Hi there Sorry for what may be a naive or dumb question. I have the following data: > x <- c(1,2,3,4) # predictor vector > y <- c(2,4,6,8) # response vector. Notice that it is an exact, perfect straight line through the origin and slope equal to 2 > error <- c(0.3,0.3,0.3,0.3) # I have (equ

Re: [R] loop through variable names

2009-11-11 Thread Gabor Grothendieck
Try this: lm(environmental[c("ToyOutcome", thisvar)]) or lm(ToyOutcome ~., environmental[c("ToyOutcome", thisvar)]) On Wed, Nov 11, 2009 at 6:49 PM, Jacob Wegelin wrote: > > Often I perform the same task on a series of variables in a dataframe, by > looping through a character vector that hol

[R] loop through variable names

2009-11-11 Thread Jacob Wegelin
Often I perform the same task on a series of variables in a dataframe, by looping through a character vector that holds the names and using paste(), eval(), and parse() inside the loop. For instance: thesevars<-names(environmental) environmental$ToyOutcome<-rnorm(nrow(environmental)) tableOf

Re: [R] Implementation of the "Shuffled Complex Evolution" (SCE-UA) Algorithm

2009-11-11 Thread Felix Andrews
http://code.google.com/p/ihacres/source/browse/trunk/man/SCEoptim.Rd http://code.google.com/p/ihacres/source/browse/trunk/R/sce.R source("http://ihacres.googlecode.com/svn/trunk/R/sce.R";) 2009/11/12 Hans W Borchers : > Simon Seibert mytum.de> writes: > >> >> Good evening list, >> I'm looking

Re: [R] Convert to time from epoch

2009-11-11 Thread jim holtman
try this: > x <- Sys.time() > str(x) POSIXct[1:1], format: "2009-11-11 18:40:10" > x [1] "2009-11-11 18:40:10 EST" > as.numeric(x) # secs from 1/1/1970 [1] 1257982810 > On Wed, Nov 11, 2009 at 6:29 PM, Alon Ben-Ari wrote: > Hello R users, > > Is anyone familiar with an R function that convert

[R] Convert to time from epoch

2009-11-11 Thread Alon Ben-Ari
Hello R users, Is anyone familiar with an R function that converts a time expression ( POSIx for example ) to time (seconds/minutes) from epoch? I was unable to find any Best, Alon [[alternative HTML version deleted]] __ R-help@r-project.org

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham > Sent: Wednesday, November 11, 2009 3:03 PM > To: Peng Yu > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Is there a way to specify drop=FALSE as the > global d

Re: [R] partial cumsum

2009-11-11 Thread Marc Schwartz
On Nov 11, 2009, at 4:45 PM, Carl Witthoft wrote: > By Bill Dunlap: quote: > x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) > rev(cumsum(rev(is.na(x [1] 1 1 1 1 0 0 0 0 0 0 A more natural way to do this is > cumsum(is.na(c(NA,x[-length(x)]))) [1] 1 1 1 1 2 2 2 2 2 2 endquote Both of whi

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread hadley wickham
> See the above example. Is there a way to make 'drop=FALSE' as global > default, so that when I say 'tmp[,1]', R will treat it as > 'tmp[,1,drop=FALSE]'? The following code won't change the defaults, but it would at least let you know when you're making the mistake: trace_all <- function(fs, tra

Re: [R] partial cumsum

2009-11-11 Thread Carl Witthoft
quote: > x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) > rev(cumsum(rev(is.na(x [1] 1 1 1 1 0 0 0 0 0 0 A more natural way to do this is > cumsum(is.na(c(NA,x[-length(x)]))) [1] 1 1 1 1 2 2 2 2 2 2 endquote Both of which suggest the original problem could also be dealt with by usin

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Richard M. Heiberger
Stavros Macrakis wrote: I could of course write my own print function for this, but was wondering if there was a standard way of doing it. If not in R, perhaps there is some way to have ESS delete the final spaces? ESS, or more precisely emacs, can handle that. Use the M-x toggle-truncate-l

Re: [R] R.oo and S4?

2009-11-11 Thread Henrik Bengtsson
Please what I already wrote in my previous message of this thread. Also, everything in R.oo is based on S3 and it uses standard R constructs and data types to achieve what it does. You can submit packages based on R.oo, and there are several such packages on CRAN, see 'Reverse dependencies' on htt

Re: [R] thousands separator in console output?

2009-11-11 Thread Marc Schwartz
On Nov 11, 2009, at 3:52 PM, Patricio Cuarón wrote: Hello, I'm beginning with R and I'm wondering if there's any way to display large values (e.g. 161651654167) using my system's thousands separator or scientific notation. Thanks! To get scientific notation as a default for given large va

[R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
When printing data.frames, R aligns columns by padding with spaces. For example, print(data.frame(x=c('a','bb','ccc')),right=FALSE)   x 1 a  |-- vertical bar shows end of line 2 bb |-- vertical bar shows end of line 3 ccc|-- vertical bar shows end of

Re: [R] eacf

2009-11-11 Thread ECSANT
Dear Michel, The only thing you need to do is download the TSA package, and read its document. In this document you're gonna find the command eacf, so it's as simple as using the source TSA, and in ur Tinn-R just call the instruction with the options you want. I expect this information to be use

[R] plotting time series

2009-11-11 Thread morgi2020
Hi, I'm new to R. I've two sort of time series, one sampled every second and other every 30 minutes stored in two data.frames zy1 and zy2. I've joined the two series using date<-merge(zy1,zy2, all.x=T,all.y=T) when I want to make a plot, using the code below, it doesn't work. It gives me the

[R] thousands separator in console output?

2009-11-11 Thread Patricio Cuarón
Hello, I'm beginning with R and I'm wondering if there's any way to display large values (e.g. 161651654167) using my system's thousands separator or scientific notation. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mail

Re: [R] Loadings and scores from fastICA?

2009-11-11 Thread Tony Plate
The help for fastICA says: The data matrix X is considered to be a linear combination of non-Gaussian (independent) components i.e. X = SA where columns of S contain the independent components and A is a linear mixing matrix. The value of fastICA is a list with components "S" (th

Re: [R] R.oo and S4?

2009-11-11 Thread Gabor Grothendieck
I think it would be best to learn S3 first since that is a fundamental part of R and S4 is an extension of it and also its very simple so there is not much to learn. After that you can branch out. On Mon, Oct 26, 2009 at 2:28 PM, Gabor Grothendieck wrote: > S3 and S4 are part of the core of R so

[R] Partial correlations and p-values

2009-11-11 Thread dadrivr
I'm trying to write code to calculate partial correlations (along with p-values). I'm new to R, and I don't know how to do this. I have searched and come across different functions, but I haven't been able to get any of them to work (for example, pcor and pcor.test from the ggm package). In the

Re: [R] Error: cannot allocate vector of size...

2009-11-11 Thread tlumley
On Wed, 11 Nov 2009, Larry Hotchkiss wrote: Hi, I'm responding to the question about storage error, trying to read a 300 x 100 dataset into a data.frame. I wonder whether you can read the data as strings. If the numbers are all one digit, each cell would require just 1 byte instead of 8.

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread tlumley
On Wed, 11 Nov 2009, Peng Yu wrote: On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu wrote: tmp <- matrix(1:2) tmp tmp[,1,drop=FALSE] See the above example. Is there a way to make 'drop=FALSE' as global default, so that when I say 'tmp[,1]', R will treat it as 'tmp[,1,drop=FALSE]'? Is there a way

Re: [R] LINEAR MIXED EFFECT

2009-11-11 Thread Dave Atkins
Milton's point is dead-on, and I would highly encourage you to give the posting guide a look. That said... you might try "na.action = na.omit" in your call to... actually, we don't know what function you are using (see first point). Regardless, sounds like you have missing data and na.action is

Re: [R] as.Date from data.frame

2009-11-11 Thread separent
Hello Gentlemen, All of your answers were helpfull. Indeed, 'as.is=TRUE' or 'stringsAsFactors=FALSE' avoid importing as factors, as it did when I imported the table without specifying anything. However, data frames will not allow different datatypes within a single column, so, for time series, I

Re: [R] fisher.test negative value error

2009-11-11 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Bhanu Mangipudi > Sent: Wednesday, November 11, 2009 11:16 AM > To: r-help@r-project.org > Subject: [R] fisher.test negative value error > > Hi all, > > I am new to python, R an

Re: [R] fitting a glm with matrix of responses

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 2:24 PM, Murat Tasan wrote: hi all - quick question: i have a matrix 'y' of response values, with two explanatory variables 'x1' and 'x2'. tested values of 'x1' and 'x2' are sitting in two vectors 'x1' and 'x2'. i want to learn model parameters without "unrolling" the matri

[R] fisher.test negative value error

2009-11-11 Thread Bhanu Mangipudi
Hi all, I am new to python, R and rpy2. I having few errors when I am using 'fisher.test' function where I am struck now. Please help to fix these bugs. My code for fisher.test goes this way *from rpy2 import * import rpy2.robjects as robjects def fisherExact(a,b,c,d): v = [a,b,c,d] m = rob

Re: [R] Automating Plot Commands using a Loop

2009-11-11 Thread Koraelus
Hello, Thank you for responding! The data is in the same format as the example I showed earlier. The data is different from matrix to matrix, but the general format is: Time1Time 2 Time3 Time4 Species1 134 5 Species2 34

[R] fitting a glm with matrix of responses

2009-11-11 Thread Murat Tasan
hi all - quick question: i have a matrix 'y' of response values, with two explanatory variables 'x1' and 'x2'. tested values of 'x1' and 'x2' are sitting in two vectors 'x1' and 'x2'. i want to learn model parameters without "unrolling" the matrix of response values. example below: # some fake da

Re: [R] partial cumsum

2009-11-11 Thread Tony Plate
William Dunlap wrote: Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of smu Sent: Wednesday, November 11, 2009 7:58 AM To: r-help@r-project.org Subject: [R] partial cumsum

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread esterhazy
That is wonderful, now I think I am all set! Thanks again! Tony Plate wrote: > > This is a tricky data entry problem. The right technique will depend on > the fine details of the data, and it's not clear what those are. E.g., > when you say "In my first column, for example, I have "henry" ",

Re: [R] as.Date from data.frame

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 1:06 PM, separent wrote: #Hello, #I loaded data using read.table - I needed to convert a row in the data frame to date class: You _should_ have given the actual code (as the Posting Guide requests), but I would guess that you should have added either as.is=TRUE or

Re: [R] as.Date from data.frame

2009-11-11 Thread Marc Schwartz
On Nov 11, 2009, at 12:06 PM, separent wrote: #Hello, #I loaded data using read.table - I needed to convert a row in the data frame to date class: data V1 V2 V3 V4 1 2008-05-19 2008-04-19 2008-03-21 2008-02-22 2 38.16999817 30.7008 36.8661 35.18999

Re: [R] as.Date from data.frame

2009-11-11 Thread Steve Lianoglou
Hi, On Nov 11, 2009, at 1:06 PM, separent wrote: #Hello, #I loaded data using read.table - I needed to convert a row in the data frame to date class: data V1 V2 V3 V4 1 2008-05-19 2008-04-19 2008-03-21 2008-02-22 2 38.16999817 30.7008 36.8661 35.1

[R] Joint counts and spatial autocorrelation - binary data

2009-11-11 Thread DBK
Hi All, I am new to this form and new to R, having just initiated the analysis of my first project using R. I have been working on a logistic model of land use change and am concerned about 1) measuring spatial autocorrelation and 2) including an autocovariate in my model. Here is what I think

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread Tony Plate
This is a tricky data entry problem. The right technique will depend on the fine details of the data, and it's not clear what those are. E.g., when you say "In my first column, for example, I have "henry" ", it's unclear to me whether or not the double quotes are part of the data or not - whi

[R] as.Date from data.frame

2009-11-11 Thread separent
#Hello, #I loaded data using read.table - I needed to convert a row in the data frame to date class: > data V1 V2 V3 V4 1 2008-05-19 2008-04-19 2008-03-21 2008-02-22 2 38.16999817 30.7008 36.8661 35.18999863 3 37.4754 29.9576 36.4508 35.366

Re: [R] source() vs attach()0

2009-11-11 Thread Stefan Zeugner
Duncan Murdoch wrote: Just declaring it there is the only reasonable way, i.e. test<-function(foo) { subtest <- function() { foo <<- foo+1 } subtest() return(foo) } The reason you can't somehow assign it within an existing test is that subtest is a different closure every time.

Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux
Patrick Giraudoux a écrit : Duncan Murdoch a écrit : On 11/11/2009 12:15 PM, Patrick Giraudoux wrote: I am writing a rd doc, and need to use "#" in a url adress. This would make: \url{http://www..org/myfolder/#myanchor} That should work. Of course, I suppose this will not work because

Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux
Duncan Murdoch a écrit : On 11/11/2009 12:15 PM, Patrick Giraudoux wrote: I am writing a rd doc, and need to use "#" in a url adress. This would make: \url{http://www..org/myfolder/#myanchor} That should work. Of course, I suppose this will not work because # is a special character sta

Re: [R] LINEAR MIXED EFFECT

2009-11-11 Thread milton ruser
Dear Ana Golveia, It is completelly impossible someone realise what kind or help you need or what is happening. I suggest you give a look on the posting guide, mainly that part about a minimum reproducible code with self explaining information, etc. Cheers milton On Wed, Nov 11, 2009 at 7:22 AM

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 1:02 PM, esterhazy wrote: Yes, thanks for this, this is exactly what I want to do. However, I have a remaining problem which is how to get R to understand that each entry in my matrix is a vector of names. I have been trying to import my text file with the names in eac

Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Duncan Murdoch
On 11/11/2009 12:15 PM, Patrick Giraudoux wrote: I am writing a rd doc, and need to use "#" in a url adress. This would make: \url{http://www..org/myfolder/#myanchor} That should work. Of course, I suppose this will not work because # is a special character starting a comment line in the

Re: [R] lme4 glmer how to extract the z values?

2009-11-11 Thread sj
Ben , Thanks! This worked after I updated my version of R (from 2.8.1 to 2.10) . Best, Spencer On Tue, Nov 10, 2009 at 7:04 PM, Ben Bolker wrote: > sj gmail.com> writes: > > > I am using glmer() from lmer(lme4) to run generalized linear mixed > models. I > > can't figure out how to extrac

Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread esterhazy
Yes, thanks for this, this is exactly what I want to do. However, I have a remaining problem which is how to get R to understand that each entry in my matrix is a vector of names. I have been trying to import my text file with the names in each vector of names enclosed in quotes and separated by

Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux
Daniel Malter a écrit : x="\url{http://www..org/myfolder/#myanchor}"; print(x,quote=F) Does this work for you? Daniel I am not working on consol mode (which would make your suggestion straight applicable), but writing a rd documentationn (the documentation that comes out with the

Re: [R] partial cumsum

2009-11-11 Thread William Dunlap
> -Original Message- > From: smu [mailto:m...@z107.de] > Sent: Wednesday, November 11, 2009 9:26 AM > To: William Dunlap > Cc: r-help@r-project.org > Subject: Re: [R] partial cumsum > > On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote: > > > > Perhaps > >> ave(x, rev(cu

Re: [R] Introducing R to statisticians

2009-11-11 Thread spencerg
To me, R is the language of choice for a rapidly increasing number of people involved in new statistical algorithm development. If they are happy with the tools they currently use, learning R may be a lot of pain for little gain. However, if they want to stay current with the late

Re: [R] Sweave() within a function: objects not found

2009-11-11 Thread Duncan Murdoch
On 11/11/2009 12:09 PM, Pfaff, Bernhard Dr. wrote: Dear list subscriber, suppose, I do have a minimal Sweave file 'test.Rnw': \documentclass{article} \begin{document} <>= x @ \end{document} Within R, I define the following function: f <- function(x){ Sweave("test.Rnw") } The call: f(x =

Re: [R] partial cumsum

2009-11-11 Thread smu
On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote: > > Perhaps >> ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum) > [1] 1 3 6 NA 5 11 18 26 35 45 > it takes some time to understand how it works, but it's perfect. thank you, stefan __

Re: [R] R.oo and S4?

2009-11-11 Thread Peng Yu
I'm very familiar with C++. In this sense, it is easier for me to learn R.oo according to your advice. On the other hand, S3 and S4 are the most used. I'm wondering what would be the best choice for me. Do you have any recommendation considering the pros and cons of both ways? Is it true that pack

Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Daniel Malter
x="\url{http://www..org/myfolder/#myanchor}"; print(x,quote=F) Does this work for you? Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag

Re: [R] partial cumsum

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 18:11:51 +0100 Karl Ove Hufthammer wrote: > I wish cumsum took a 'na.rm' argument, though. It would make stuff like > this much easier. Or, more specifically, a 'na.value', which could perhaps default to 'NA' to get the current behaviour, but which one could set 0 for 'cum

[R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux
I am writing a rd doc, and need to use "#" in a url adress. This would make: \url{http://www..org/myfolder/#myanchor} Of course, I suppose this will not work because # is a special character starting a comment line in the rd dialect. I did not found a similar example in "Writing R exention

Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 10:57 AM, David Winsemius wrote: On Nov 11, 2009, at 10:36 AM, Dimitris Rizopoulos wrote: one approach is the following: mat <- rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2)) mat / ave(abs(mat), row(mat), sign(mat), FUN = sum) Very elegant. My solution was

Re: [R] partial cumsum

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 08:53:50 -0800 William Dunlap wrote: > > x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) > > > > should become this: > > > > 1 3 6 NA 5 11 18 26 35 45 > > Perhaps >> ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum) > [1] 1 3 6 NA 5 11 18 26 35 45 Clever way of puttin

Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread Peng Yu
On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu wrote: > tmp <- matrix(1:2) > tmp > tmp[,1,drop=FALSE] > > > See the above example. Is there a way to make 'drop=FALSE' as global > default, so that when I say 'tmp[,1]', R will treat it as > 'tmp[,1,drop=FALSE]'? Is there a way to set drop=FALSE globally?

[R] Sweave() within a function: objects not found

2009-11-11 Thread Pfaff, Bernhard Dr.
Dear list subscriber, suppose, I do have a minimal Sweave file 'test.Rnw': \documentclass{article} \begin{document} <>= x @ \end{document} Within R, I define the following function: f <- function(x){ Sweave("test.Rnw") } The call: f(x = 1:10) results in the following error message: > f(x

Re: [R] partial cumsum

2009-11-11 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of smu > Sent: Wednesday, November 11, 2009 7:58 AM > To: r-help@r-project.org > Subject: [R] partial cumsum > > Hello, >

Re: [R] How to get the names of list elements when iterating over alist?

2009-11-11 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu > Sent: Wednesday, November 11, 2009 8:02 AM > To: r-h...@stat.math.ethz.ch > Subject: [R] How to get the names of list elements when > iterating over alist? > > I need

Re: [R] Implementation of the "Shuffled Complex Evolution" (SCE-UA) Algorithm

2009-11-11 Thread Hans W Borchers
Simon Seibert mytum.de> writes: > > Good evening list, > I'm looking for an R implementation of the "Shuffled Complex > Evolution” (SCE-UA) algorithm after Duan et al. (1993). Does anybody > know if there is an extension/ package existing that contains it? > Thanks very much for your help! Che

Re: [R] Introducing R to statisticians

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 10:51:53 -0500 Duncan Murdoch wrote: > If you know their applications you can show how well R does there, And do mention the (increasing) number of books available. It's only a slight exaggeration to say that there are R books on almost any application you could think of.

Re: [R] Error: cannot allocate vector of size...

2009-11-11 Thread Larry Hotchkiss
Hi, I'm responding to the question about storage error, trying to read a 300 x 100 dataset into a data.frame. I wonder whether you can read the data as strings. If the numbers are all one digit, each cell would require just 1 byte instead of 8. That makes 300MB instead of 2.4GB. You can ru

Re: [R] problems in installing biomart

2009-11-11 Thread Martin Morgan
Hi Andreia -- Andreia Fonseca wrote: > Dear Forum > > my machine runs Ubuntu 9.04. I am trying to install Biomart, what I realize > is that something is missing and it can't install XML, RCurl but I don't > know what more to do, I looked in previous posts but I did not find > infoprmation that he

[R] problems in installing biomart

2009-11-11 Thread Andreia Fonseca
Dear Forum my machine runs Ubuntu 9.04. I am trying to install Biomart, what I realize is that something is missing and it can't install XML, RCurl but I don't know what more to do, I looked in previous posts but I did not find infoprmation that helped. Thanks Andreia biocLite("biomaRt") Running b

[R] How to get the names of list elements when iterating over a list?

2009-11-11 Thread Peng Yu
I need to get the names of the list elements when I iterate over a list. I'm wondering how to do so? alist=list(a=c(1,3),b=c(-1,3),c=c(-2,1)) sapply(alist,function(x){ #need to use the name of x for some subsequent process }) __ R-help@r-proje

[R] partial cumsum

2009-11-11 Thread smu
Hello, I am searching for a function to calculate "partial" cumsums. For example it should calculate the cumulative sums until a NA appears, and restart the cumsum calculation after the NA. this: x <- c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10) should become this: 1 3 6 NA 5 11 18 26 35 45 any i

Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 10:36 AM, Dimitris Rizopoulos wrote: one approach is the following: mat <- rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2)) mat / ave(abs(mat), row(mat), sign(mat), FUN = sum) Very elegant. My solution was a bit more pedestrian, but may have some speed advanta

Re: [R] Introducing R to statisticians

2009-11-11 Thread Duncan Murdoch
On 11/11/2009 10:26 AM, Damjan Krstajic wrote: Dear all, I will present R language and R software environment to the Statistical Society of Serbia. As I will doing it to professional statisticians it seems unneccesary to me to present them how R language works in details. I am more interested

Re: [R] architecture of statistical programming language R

2009-11-11 Thread Ben Bolker
mustafa_binar wrote: > > > > > hi, > I'm mustafa. I'm a master student Dokuz Eylül University in > Izmir/Turkey. >   > I focus on Statistical programming language R. I learn architecture > of R. But i don't find out any material in internet. > Would you like to help me this subject? If you

Re: [R] End of Month date capture

2009-11-11 Thread Gabor Grothendieck
Here is one possibility using aggregate.zoo > aggregate(z, as.yearmon, tail, 1) x1 x2 x3 x4 x5 x6 Aug 1998 -0.07043759 NA NA NA NA NA Sep 1998 -0.03098945 NA NA NA NA NA Oct 1998 -0.00726802 NA NA NA NA NA The above is not strictly what you asked for since it uses yearmon times.

Re: [R] source() vs attach()0

2009-11-11 Thread Duncan Murdoch
On 11/11/2009 10:19 AM, Stefan Zeugner wrote: Duncan Murdoch wrote: Just declaring it there is the only reasonable way, i.e. test<-function(foo) { subtest <- function() { foo <<- foo+1 } subtest() return(foo) } The reason you can't somehow assign it within an existing test is that

Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread Dimitris Rizopoulos
one approach is the following: mat <- rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2)) mat / ave(abs(mat), row(mat), sign(mat), FUN = sum) I hope it helps. Best, Dimitris Hao Cen wrote: Hi, I have a matrix with positive numbers, negative numbers, and NAs. An example of the matrix

[R] Introducing R to statisticians

2009-11-11 Thread Damjan Krstajic
Dear all, I will present R language and R software environment to the Statistical Society of Serbia. As I will doing it to professional statisticians it seems unneccesary to me to present them how R language works in details. I am more interested to present them with the latest facts regarding

[R] End of Month date capture

2009-11-11 Thread Research
Dear R-users, I have the following zoo object: x1x2 x3 x4 x5 x6 1998-08-31 -0.0704375904 NA NA NA NA NA 1998-09-01 0.0379028122 NA NA NA NA

Re: [R] Data transformation

2009-11-11 Thread hadley wickham
>> (x.n <- cast(x.m, id ~ var, function(.dat){ > +     if (length(.dat) == 0) return(0)  # test for no data; return > zero if that is the case > +     mean(.dat) > + })) Or fill = 0. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list h

Re: [R] Unexpected behavior for as.date()

2009-11-11 Thread Therneau, Terry M., Ph.D.
The date library was written 20 or so years ago. It was a very good first effort, but the newer Date library has superior functionality in nearly every way. The date library is still available, for legacy projects such as yours, but I do not advise it for new work. To answer your specific qu

[R] update.packages()

2009-11-11 Thread CG Pettersson
Dear all, W.XP I recently upgraded to R2.10.0 and did what I usually do: copied all "special" libraries from the old installation and then used "update.packages()" on the command line. Nothing happened. Then I clicked on the same command on the droplist which generated "update.packages(ask='graph

[R] R installer can't find math.h, stdio.h

2009-11-11 Thread Ted Harding
This is possibly the wrong list, but anyway ... Using Linux Debian-4.0 Etch (regularly upgraded). I set about installing Simon Woods' "soap" package -- see: http://www.maths.bath.ac.uk/~sw283/simon/software.html So I downloaded the tar archive soap_0.1-3.tar.gz and then ran (as root) R CMD I

  1   2   >