[R] Odp: How to see the previous commands after save workspace/load workspace ?

2011-08-04 Thread Petr PIKAL
Hi > > I did save workspace and when I load it, I can see the variables, > using ls(). > But I cannot see the commands from the program I saved. How to do > that? Perhaps you can check .Rhistory file. Regards Petr > > __ > R-help@r-project.org maili

Re: [R] Sweave - landscape figure

2011-08-04 Thread Duncan Mackay
Hi Eduardo in the preamble put \usepackage[figureright]{rotating} see manual for figureright if you do not like it and then some graphics with options where needed \begin{sidewaysfigure} \centering \includegraphics[width=,% clip=true,% trim=0in 0in 0in 0in,%

[R] Latent Class with covariates

2011-08-04 Thread Iasonas Lamprianou
Dear all Last week, I posted a question and some of you spent their valuable time to respond. Thank you (once again). This time, after doing a lot of homework, I return with  a second question on the issue. I was advised to use poLCA for a Latent Class Analysis with covariates. The software w

Re: [R] functions on rows or columns of two (or more) arrays

2011-08-04 Thread Dennis Murphy
Hi: Here's one approach: a=matrix(1:50,nrow=10) a2=floor(jitter(a,amount=50)) # Write a function to combine the columns of interest # into a data frame and fit a linear model regfn <- function(k) { rdf <- data.frame(x = a[k, ], y = a2[k, ]) lm(y ~ x, data = rdf) } # Use lapply() to

[R] Translate Sine Function in R?

2011-08-04 Thread Katrina Bennett
Hello, I'm trying to generate a sine wave in R to fit my observations using the general formula: y=a*sin(b[x+h*pi)]+k where a = amplitude, b=period, h=phase shift, and k=vertical shift I want to use following translation to bring the sine function up onto the y-axis to range from 0-1, and this w

Re: [R] source() or OS X Lion?

2011-08-04 Thread Mark Ebbert
For pete's sake, I knew that. I apologize for wasting everyone's time. I tell ya, this has been an off week for me. Thank you for your kind responses. On Aug 4, 2011, at 9:35 PM, Rolf Turner wrote: > > Note that ***histogram()*** (as opposed to "hist()") is a function from the > "lattice" pack

Re: [R] Not really off-topic ...

2011-08-04 Thread John Kane
You clearly have some strange ... err, whatever. --- On Thu, 8/4/11, Ted Harding wrote: > From: Ted Harding > Subject: [R] Not really off-topic ... > To: r-h...@stat.math.ethz.ch > Received: Thursday, August 4, 2011, 8:44 PM > Greetings all! > Just arrived via my daily digest of the ALLSTAT li

[R] boolean SEXP interpretation upon function return

2011-08-04 Thread Alexandre Aguiar
Hi, When a function returns a SEXP of type LGLSXP (logical) to signal whether it succeeded or failed, how is it intrepreted? Is it like C where SUCCESS = 0 or other value? Thanks. -- Alexandre -- Alexandre Santos Aguiar, MD, SCT signature.asc Description: This is a digitally signed mess

Re: [R] Which is more efficient?

2011-08-04 Thread R. Michael Weylandt
You can study this yourself using the System.time() utility: just write System.time() around any block of code and R will time it for you. Offhand, I'd guess example2 may be ever so slightly quicker since it doesn't have to create colA and colB, but not to a degree that would be noticeable for rea

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread R. Michael Weylandt
Yes, the stats package has a lag function, but it's not really appropriate for the sample data Dimitri gave us: to wit, it's not of "ts" (time series) class so lag doesn't know what to do with it and gives an error message. Perhaps it's just that I never really took the time to get used to it, but

Re: [R] source() or OS X Lion?

2011-08-04 Thread Rolf Turner
Note that ***histogram()*** (as opposed to "hist()") is a function from the "lattice" package. So at some stage you must have issued the command "require(lattice)" or equivalently "library(lattice)". (So your ``exact code'' is a little misleading.) You are thus getting bitten by the fact that

[R] Which is more efficient?

2011-08-04 Thread Matt Curcio
Greetings all, I am curious to know if either of these two sets of code is more efficient? Example1: ## t-test ## colA <- temp [ , j ] colB <- temp [ , k ] ttr <- t.test ( colA, colB, var.equal=TRUE) tt_pvalue [ i ] <- ttr$p.value or Example2: tt_pvalue [ i ] <- t.test ( temp[ , j ], temp[ , k ]

Re: [R] source() or OS X Lion?

2011-08-04 Thread Dylan Beaudette
Save the result of histogram(), then print() the saved object. On Aug 4, 2011 5:13 PM, "Mark Ebbert" wrote: Dear R Gurus, I'm seeing some strange behavior that I can't explain. I'm generating a figure for a paper and I like to save the script (no matter how simple) for future reference. My prac

Re: [R] source() or OS X Lion?

2011-08-04 Thread Duncan Murdoch
On 11-08-04 5:24 PM, Mark Ebbert wrote: Dear R Gurus, I'm seeing some strange behavior that I can't explain. I'm generating a figure for a paper and I like to save the script (no matter how simple) for future reference. My practice is to write the script and run it using the 'source()' functi

[R] Not really off-topic ...

2011-08-04 Thread Ted Harding
Greetings all! Just arrived via my daily digest of the ALLSTAT list is the following: http://www.youtube.com/StatisticalSongs#p/u/4/JEYLfIVvR9I If you watch/listen, you will see/hear that it is not at all off-topic. And now to bed, before my correspondence is analysed. Best wishes, Ted. --

Re: [R] Running a column loop through the Moran.I function.

2011-08-04 Thread R. Michael Weylandt
I'm on my phone so I can't verify this but have you tried the apply function? apply(attri,2,Moran.I,Locate.dists.inv,NA.rm=T) Michael Weylandt On Aug 4, 2011, at 4:54 PM, Scott Seely wrote: > Dear R users, > > I have two data frames that consist of statistical information for most > countries

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Jannis
Your function only works for the first dimensions (e.g. indices indicating the positions in the first two dimensions in datacube), correct? Otherwise it looks very handy! And certainly more elegent than my function monster! Jannis On 08/04/2011 09:58 PM, R. Michael Weylandt wrote: Hi Jannis

[R] Running a column loop through the Moran.I function.

2011-08-04 Thread Scott Seely
Dear R users, I have two data frames that consist of statistical information for most countries around the world. One dataframe consists of the latitude and longitude ("coord.csv") of each country, while the other consists of 100's of different attributes ("countryattri.csv") for each country (lik

[R] source() or OS X Lion?

2011-08-04 Thread Mark Ebbert
Dear R Gurus, I'm seeing some strange behavior that I can't explain. I'm generating a figure for a paper and I like to save the script (no matter how simple) for future reference. My practice is to write the script and run it using the 'source()' function. What's weird is that the resultant fig

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Ken H
Hey all, Correct me if I'm wrong but, the 'stats' package has a lag() function like so lagged.series=lag(series,number of lags wanted) Furthermore, I am pretty sure that lag( ) accepts negative lags:=> leads. lag(x,1)=> object of one lag, lag(x,-1) object with one lead

Re: [R] functions on rows or columns of two (or more) arrays

2011-08-04 Thread Florent D.
The apply function also works with multi-dimensional arrays, I think this is what you want to achieve using a 3d array: aaa <- array(NA, dim = c(2, dim(a))) aaa[1,,] <- a aaa[2,,] <- a2 apply(aaa, 3, function(x)lm(x[1,]~x[2,])) __ R-help@r-project.org m

Re: [R] Can glmnet handle models with numeric and categorical data?

2011-08-04 Thread Paul Smith
On Fri, Aug 5, 2011 at 12:02 AM, Marc Schwartz wrote: >> Can the x matrix in the glmnet() function of glmnet package be a >> data.frame with numeric columns and factor columns? I am asking this >> because I have a model with both numeric and categorical predictors, >> which I would like to study w

Re: [R] Can glmnet handle models with numeric and categorical data?

2011-08-04 Thread Marc Schwartz
On Aug 4, 2011, at 5:41 PM, Paul Smith wrote: > Dear All, > > Can the x matrix in the glmnet() function of glmnet package be a > data.frame with numeric columns and factor columns? I am asking this > because I have a model with both numeric and categorical predictors, > which I would like to stud

[R] Can glmnet handle models with numeric and categorical data?

2011-08-04 Thread Paul Smith
Dear All, Can the x matrix in the glmnet() function of glmnet package be a data.frame with numeric columns and factor columns? I am asking this because I have a model with both numeric and categorical predictors, which I would like to study with glmnet. I have already tried to use a data.frame, bu

Re: [R] Automatic creation of binary logistic models

2011-08-04 Thread Paul Smith
On Thu, Aug 4, 2011 at 9:35 PM, Marc Schwartz wrote: >> Suppose that you are trying to create a binary logistic model by >> trying different combinations of predictors. Has R got an automatic >> way of doing this, i.e., is there some way of automatically generating >> different tentative models an

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread R. Michael Weylandt
As currently implemented it works for both "Location" and "Destination" (I really should think of some better variable names) of any dimensionality, but it does assume that if say, you give a 2d location, those correspond to the first two dimensions of destination. But if you give 1d or 3d, e.g.,

Re: [R] matrix rows to single numeric element

2011-08-04 Thread R. Michael Weylandt
> This seems to work: > > apply(mat1,1,function(x){paste(x,collapse="")}) > > The collapse command inside of paste is (I think) the easiest way to > combine strings. > > Michael Weylandt > > > On Thu, Aug 4, 2011 at 5:45 PM, Wegan, Michael (DNRE) > wrote: > >> I have a matrix of 5 columns and 64 r

Re: [R] survival probability estimate method

2011-08-04 Thread array chip
Dear Peter, Thanks very much for the references. It seems the method is based on parametric proportional hazard models by incorporating cubic spline of the baseline hazards, not sure if tweaking survreg() would do? Best, John - Original Message - From: Peter Jepsen To: 'array chip'

[R] matrix rows to single numeric element

2011-08-04 Thread Wegan, Michael (DNRE)
I have a matrix of 5 columns and 64 rows, let's call it "mat1". All values are 1 or 0. I need to take the values of the elements by row and create a single numeric element that can be placed its respective slot in a 64-element list, named "list1". For example, mat1[11,1:5] = 0,1,1,0,1 and I m

[R] multi-dimensional Gaussian quadrature

2011-08-04 Thread Lei Liu
Hi there, Does anyone know if there is a package in R for multi-demensional Gaussian quadrature? I checked out the package "gaussquad" but it can only do 1D. Thanks! Lei Liu Associate Professor Division of Biostatistics Department of Public Health Sciences University of Virginia School of Med

Re: [R] functions on rows or columns of two (or more) arrays

2011-08-04 Thread R. Michael Weylandt
I hope someone experience with plyr package comes and helps because this sounds like what it does well, but for your specific example something like this works: A = rbind(a,a2) q = apply(A,2,function(x) {lm(x[1:nrow(a)] ~ x[-(1:nrow(a))])}) but yeah, that's pretty rough so I hope someone can come

Re: [R] survival probability estimate method

2011-08-04 Thread array chip
Hi all, the reference for this method was: “Flexible parametric proportional-hazards and proportional-odds models for censored survival data, with application to prognostic modeling and estimation of treatment effects” published in Stat Med (2002) 21: 2175   The abstract is:   Modelling of censo

[R] functions on rows or columns of two (or more) arrays

2011-08-04 Thread Jim Bouldin
I realize this should be simple, but even after reading over the several help pages several times, I still cannot decide between the myriad "apply" functions to address it. I simply want to apply a function to all the rows (or columns) of the same index from two (or more) identically sized arrays

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
This function you wrote is interesting, but I almost missed it since I didn't see a direct example! cubeValues(NULL, data, indices) cubeValues(1, data, indices) cubeValues(c(1,2), data, indices) (sorry if I'm beating a dead horse here) On Thu, Aug 4, 2011 at 2:58 PM, R. Michael Weylandt < michae

[R] Multi-task SVM in R

2011-08-04 Thread Vishal Thapar
Hi, Does anyone know of a package that implements Multi-task SVM in R? I found one in Matlab : http://www.ece.umn.edu/users/cherkass/predictive_learning/Resources/MTL_Software_Description.pdf I was wondering if there is something similar in R? Thank you for your help. Sincerely, Vishal

Re: [R] Multiple endpoint (possibly group sequential) sample size calculation

2011-08-04 Thread Marc Schwartz
On Aug 4, 2011, at 2:03 PM, Paul Miller wrote: > > Hello everyone, > > I need to do a sample size calculation. The study two arms and two endpoints. > The two arms are two different cancer drugs and the two endpoints reflect > efficacy (based on progression free survival) and toxicity. > > U

Re: [R] How to see the previous commands after save workspace/load workspace ?

2011-08-04 Thread R. Michael Weylandt
Check out ?savehistory in utils. Also, I think most GUI's do this - I can certainly attest that RStudio does Michael Weylandt On Thu, Aug 4, 2011 at 11:55 AM, Bogdan Lataianu wrote: > I did save workspace and when I load it, I can see the variables, > using ls(). > But I cannot see the commands

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
(I was just about to send this before your last reply) As a more general tip, I find that using %in% is easier to understand than "is.element" and "setdiff" because it can be more universal, especially when combined with "all" and the "!". To me the functions like setdiff are easier to read, but h

[R] randomForest partial dependence plot variable names

2011-08-04 Thread Katharine Miller
Hello, I am running randomForest models on a number of species. I would like to be able to automate the printing of dependence plots for the most important variables in each model, but I am unable to figure out how to enter the variable names into my code. I had originally thought to extract the

[R] Text annotation of a graph

2011-08-04 Thread Lisa
Dear All, I am trying to add some text annotation to a graph using matplot() as follows: vars <- c("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v8", "v10") id <- seq(5.000, 0.001, by = -0.001) sid <- c(4.997, 3.901, 2.339, 0.176, 0.151, 0.101, 0.076, 0.051, 0.026, 0.001) rn <- sample

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Jannis
Thanks, Gene, for your hint! I indeed did not check any possible situation and my function was not returning what I intened it to return. This updated version, however, should. I am sure there are much easier ways (or ready made functions) to do the same. ind.datacube = function( ##title<< c

Re: [R] Automatic creation of binary logistic models

2011-08-04 Thread Marc Schwartz
On Aug 4, 2011, at 2:23 PM, Paul Smith wrote: > Dear All, > > Suppose that you are trying to create a binary logistic model by > trying different combinations of predictors. Has R got an automatic > way of doing this, i.e., is there some way of automatically generating > different tentative model

Re: [R] random value generation with added constraint.

2011-08-04 Thread Duncan Murdoch
On 04/08/2011 12:03 PM, Vijayan Padmanabhan wrote: Hi I am looking at generating a random dataset of say 100 values fitting in a normal distribution of a given mean and SD, I am aware of rnorm function. However i am trying to build into this function one added constraint that all the random value

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Dimitri Liakhovitski
Thanks a lot for the recommendations - some of them I am implementing already. Just a clarification: the only reason I try to compare things to SPSS is that I am the only person in my office using R. Whenever I work on an R code my goal is not just to make it work, but also to "boast" to the SPSS

[R] random value generation with added constraint.

2011-08-04 Thread Vijayan Padmanabhan
Hi I am looking at generating a random dataset of say 100 values fitting in a normal distribution of a given mean and SD, I am aware of rnorm function. However i am trying to build into this function one added constraint that all the random value generated should also obey the constraint that they

Re: [R] Automatic creation of binary logistic models

2011-08-04 Thread Paul Smith
Wonderful! Thanks, Jeremy. Is bestglm() also able of trying nonlinear transformations of the variables, say log(X1) for instance? Paul On Thu, Aug 4, 2011 at 8:28 PM, Jeremy Miles wrote: > > Sounds like you want a best subsets regression, the bestglm() function, > found in the bestglm() packa

[R] Apply sensitivity library to dummy variables

2011-08-04 Thread Chih-Lin Chi
I am using SRC function in the sensitivity library. The independent variables (X) are a few dummy variables and the dependent variable (y) is numeric, ranged from 0,18 to 0.84. Example of independent variables are red coded as [0,0,0,1], green [0,0,1,0], blue [0,1,0,0], and yellow [1,0,0,0]. Error

[R] How to see the previous commands after save workspace/load workspace ?

2011-08-04 Thread Bogdan Lataianu
I did save workspace and when I load it, I can see the variables, using ls(). But I cannot see the commands from the program I saved. How to do that? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the pos

Re: [R] Sweave - landscape figure

2011-08-04 Thread Marc Schwartz
On Aug 4, 2011, at 2:40 PM, Eduardo M. A. M. Mendes wrote: > Dear R-users > > I am trying to understand how Sweave works by running some simple examples. > In the example I am working with there is a chunk where the R-commands > related to plotting a figure are placed. When running R CMD Swe

Re: [R] Limited number of principal components in PCA

2011-08-04 Thread William Armstrong
David and Josh, Thank you for the suggestions. I have attached a file ('q_values.txt') that contains the values of the 'Q' variable. David -- I am attempting an 'S' mode PCA, where the columns are actually the cases (different stream gaging stations) and the rows are the variables (the maximum f

Re: [R] survival probability estimate method

2011-08-04 Thread Peter Jepsen
Dear John I am not aware of an R package that does this, but I believe that Patrick Royston's -stpm- function for Stata does. Here's two references found in http://www.stata-journal.com/sjpdf.html?articlenum=st0001_2: Royston, P. 2001. Flexible parametric alternatives to the Cox model. Stata J

[R] input equivalent of capture.output

2011-08-04 Thread Antonio Piccolboni
Hi, I am looking for the equivalent of capture.output for stdin. Imagine I am writing a test for a function that reads from stdin, say scan. >1: foobar 2: Read 1 item [1] "foobar" (please don't reply that scan can also read from a file, that's not what I am trying to test; let's say I found a bug

Re: [R] Sweave - landscape figure

2011-08-04 Thread Duncan Murdoch
On 04/08/2011 3:40 PM, Eduardo M. A. M. Mendes wrote: Dear R-users I am trying to understand how Sweave works by running some simple examples. In the example I am working with there is a chunk where the R-commands related to plotting a figure are placed. When running R CMD Sweave … , pdflate

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Joshua Wiley
On Aug 4, 2011, at 11:46, Dimitri Liakhovitski wrote: > Thanks a lot, guys! > It's really helpful. But - to be objective- it's still quite a few > lines longer than in SPSS. Not once you've sources the function! For the simple case of a vector, try: X <- 1:10 mylag2 <- function(X, lag) {

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread R. Michael Weylandt
Hi Jannis, Like Gene, I'm not entirely sure what your code is intended to do, but it wasn't hard to adapt mine to at least print out the desired slice through the higher-dimensional array: cubeValues <- function(Insert, Destination, Location) { Location = as.matrix(Location) Location = ar

[R] Sweave - landscape figure

2011-08-04 Thread Eduardo M. A. M. Mendes
Dear R-users I am trying to understand how Sweave works by running some simple examples. In the example I am working with there is a chunk where the R-commands related to plotting a figure are placed. When running R CMD Sweave … , pdflatex the output is a portrait figure. I wonder whether it

Re: [R] Automatic creation of binary logistic models

2011-08-04 Thread Jeremy Miles
Sounds like you want a best subsets regression, the bestglm() function, found in the bestglm() package will do the trick. Jeremy On 4 August 2011 12:23, Paul Smith wrote: > Dear All, > > Suppose that you are trying to create a binary logistic model by > trying different combinations of predicto

Re: [R] labelling a stacked barchart (lattice)

2011-08-04 Thread Weidong Gu
Marc, Try this one barchart(data=dta, ~x, group=y, stack=T,col=sort(brewer.pal(7,"Purples")), xlab="Percent", box.width=.5, scales=list(tick.number=10), panel=function(x,y,...){ panel.barchart(x,y,...) panel.text(cumsum(x)-dta$x/2,y,labels=dta$x) panel.text(cumsum(x)-dta$x/2,1.3,labels=as.charact

[R] Automatic creation of binary logistic models

2011-08-04 Thread Paul Smith
Dear All, Suppose that you are trying to create a binary logistic model by trying different combinations of predictors. Has R got an automatic way of doing this, i.e., is there some way of automatically generating different tentative models and checking their corresponding AIC value? If so, could

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Daniel Nordlund
> -Original Message- > From: Dimitri Liakhovitski [mailto:dimitri.liakhovit...@gmail.com] > Sent: Thursday, August 04, 2011 11:47 AM > To: Daniel Nordlund; r-help > Subject: Re: [R] Efficient way of creating a shifted (lagged) variable? > > Thanks a lot, guys! > It's really helpful. But

Re: [R] General indexing in multidimensional arrays

2011-08-04 Thread Gene Leynes
I'm just wondering When I use your function on your data I get a result that is not very intuitive. Is this what you were trying to do? (I took the liberty of setting dims to 3 since 'auto', 1, and 2 didn't work. > data<- array(rnorm(64),dim=c(4,4,4)) > indices<- matrix(FALSE,nc

[R] Multiple endpoint (possibly group sequential) sample size calculation

2011-08-04 Thread Paul Miller
Hello everyone, I need to do a sample size calculation. The study two arms and two endpoints. The two arms are two different cancer drugs and the two endpoints reflect efficacy (based on progression free survival) and toxicity. Until now, I have been trying to understand this in terms of a on

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread R. Michael Weylandt
But quite a few thousand dollars cheaper - seems a fair trade to me! Seriously though: your last few requests have been focused on time objects, so I strongly suggest you take a look at xts/zoo ( http://cran.r-project.org/web/packages/xts/index.html) -- it will make time objects much easier for yo

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Dimitri Liakhovitski
Thanks a lot, guys! It's really helpful. But - to be objective- it's still quite a few lines longer than in SPSS. Dimitri On Thu, Aug 4, 2011 at 2:36 PM, Daniel Nordlund wrote: > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] >> On Beha

[R] survival probability estimate method

2011-08-04 Thread array chip
Hi, I was reading a paper published in JCO "Prediction of risk of distant recurrence using 21-gene recurrence score in node-negative and node-positive postmenopausal patients with breast cancer treated with anastrozole or tamoxifen: a TransATAC study" (ICO 2010 28: 1829). The author uses a metho

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread Dimitri Liakhovitski
Michael, thanks a lot! Really appreciate it - what wasn't hard for you would be for me! Dimitri On Thu, Aug 4, 2011 at 2:20 PM, R. Michael Weylandt wrote: > You are getting 105 because the default behavior of findInterval  is such > that v[N+1] := + Inf (as noted in ? findInterval); that is, the

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread R. Michael Weylandt
You are getting 105 because the default behavior of findInterval is such that v[N+1] := + Inf (as noted in ? findInterval); that is, the last interval is actually taken to stretch from the final element of sbwl.dates unto eternity. It shouldn't be hard to write a catch line to set that to whatever

Re: [R] special recursive filter

2011-08-04 Thread R. Michael Weylandt
More than happy to help. I think the term is "sparse" matrix. I haven't totally wrapped my mind around why your version seems to work (and testing it, it does seem to work for non-sparse matrices as well), but still, if it makes sense to you, why bother with adding one to the sum and the if state

[R] use of modMCMC

2011-08-04 Thread Paola Lecca
Dear all, I used modFit of the package FME to fit a set of ODE to a ste of experimental data. The summary of this fit give me the following error > summary(Fit) Residual standard error: 984.1 on 452 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In add

Re: [R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread R. Michael Weylandt
If you start looking at the time series classes (xts, zoo, etc) they have very quick and flexible lag functions built in. Might this be a slightly more efficient solution for the homebrew implementation? OurLag <- function(y, k=1) { t = y[,1,drop=F]; d = y[,-1,drop=F]; if (is.matrix(y)) {

[R] error bar plot with log scale in lattice

2011-08-04 Thread Xiao Hu
Hi, all, I'm trying to modify the code to a log scale for y-axis from the post http://tolstoy.newcastle.edu.au/R/help/06/06/28612.html However, the error bar did not change accordingly. The following is the code I used based on the singer.ucl data. Thanks in advance! prepanel.ci <- function(x,

[R] Efficient way of creating a shifted (lagged) variable?

2011-08-04 Thread Dimitri Liakhovitski
Hello! I have a data set: set.seed(123) y<-data.frame(week=seq(as.Date("2010-01-03"), as.Date("2011-01-31"),by="week")) y$var1<-c(1,2,3,round(rnorm(54),1)) y$var2<-c(10,20,30,round(rnorm(54),1)) # All I need is to create lagged variables for var1 and var2. I looked around a bit and found several

[R] use of modMCMC

2011-08-04 Thread Paola Lecca
Dear all, I used modFit of the package FME to fit a set of ODE to a ste of eperiemntal data. The summary of this fit give me the following error > summary(Fit) Residual standard error: 984.1 on 452 degrees of freedom Error in cov2cor(x$cov.unscaled) : 'V' is not a square numeric matrix In addit

Re: [R] Possible bug of QR decomposition in package Matrix

2011-08-04 Thread C6H5NO2
Thank you, Martin. Yes, on my computer (48Gb memory) it also gives a message "caught segfault" as you got. So it is because the matrix size is too large. I apologize for the offence I've caused. 2011/8/4 Martin Maechler : >> C6H5NO2   >>     on Thu, 4 Aug 2011 16:03:54 +0800 writes: > >

Re: [R] Plotting just a portion of a smoother graph in ggplot2

2011-08-04 Thread Timothy Bates
It's not immediately obvious You need to look at coord_cartesian() and its ylim argument. Best, t Sent from my iPhone On 4 Aug 2011, at 02:38 PM, Christopher Desjardins wrote: > Hi, > I am using ggplot2 to with the following code: > > gmathk2 <- > qplot(time,math,colour=Kids,data=kids.ach.

Re: [R] limma contrast matrix

2011-08-04 Thread Patrick Breheny
On 08/04/2011 08:53 AM, Belmont, John W wrote: I am trying to correct for the effect of 2 covariates in a gene expression data set. design<-model.matrix(~0 + Factor + cov1 + cov2) QUESTION: How to set up the contrast matrix? The usual commands fit <- lmFit(selDataMatrix, design) cont.matrix

Re: [R] Rdconv LaTeX files

2011-08-04 Thread Michael O'Keeffe
Thanks! I found (by properly reading docs) to use the inputenc package. The Rd package solve most problems except for where I has a multiple line code element in my Rd file. I tried to convert it to a LaTeX Rd 'code' element and use an 'alltt' environment to hold the multi-line text. I worked arou

Re: [R] slow computation of functions over large datasets

2011-08-04 Thread Paul Hiemstra
Hi all, After reading this interesting discussion I delved a bit deeper into the subject matter. The following snippet of code (see the end of my mail) compares three ways of performing this task, using ddply, ave and one yet unmentioned option: data.table (a package). The piece of code generates

Re: [R] conditional data replace (recode, change or whatsoever)

2011-08-04 Thread R. Michael Weylandt
Best I know, they are effectively the same** within R but I prefer "[" for a couple of reasons. 1) "[" works for all data types, while $ is sometimes picky: e.g., x = matrix(rnorm(9),3); colnames(x) <- c("a","b","c") x.df = as.data.frame(x) x$a gives "Error in x$a : $ operator is invalid for atom

[R] Plotting multiple age distributions with histogram()

2011-08-04 Thread Juliane Struve
Dear list,   I would like to plot several age distributions that are influenced by a factor (called group in the data example below). I would like to use historam() in the lattice package, but I can't figure out how to set up the data. Could someone give me a hint how to do it  for the example b

Re: [R] R loop problem

2011-08-04 Thread testrider
Worked like a charm! Thanks a lot Jean V Adams -- View this message in context: http://r.789695.n4.nabble.com/R-loop-problem-tp3718449p3718670.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://s

[R] Plotting just a portion of a smoother graph in ggplot2

2011-08-04 Thread Christopher Desjardins
Hi, I am using ggplot2 to with the following code: gmathk2 <- qplot(time,math,colour=Kids,data=kids.ach.lm.k5,geom="smooth",method="lm",formula=y~ns(x,1)) + opts(title="Smoother Plot: Math K-5") + xlab("Time") + ylab("Math") + scale_colour_brewer(pal="Set1"); gmathk2 This plots all the smoother f

Re: [R] How to extract sublist from a list?

2011-08-04 Thread R. Michael Weylandt
I'm not Josh Wiley, but I think I can answer this: When dealing with lists, its often more convenient to use "[[" instead of "[" because "[" returns a single element list while "[[" returns the list element itself. (i.e., if I set x = list(Q = rnorm(64), V = matrix(rnorm(64),8)) then x["Q"] is a l

Re: [R] limma contrast matrix

2011-08-04 Thread James W. MacDonald
Hi John, The limma package is part of Bioconductor, so you should be asking this question on the BioC listserv rather than R-help. In addition, please see the posting guide. The example you give is not self-contained, and the term 'does not work' is so unspecific as to be useless. On 8/4

Re: [R] identifying weeks (dates) that certain days (dates) fall into

2011-08-04 Thread Dimitri Liakhovitski
Sorry for renewing the topoic. I thought it worked but now I've run into a little problem: # My data frame with dates for week starts (Mondays) y<-data.frame(week=seq(as.Date("2009-12-28"), as.Date("2011-12-26"),by="week") ) # I have a vector of super bowl dates (including the future one for 201

[R] Odp: Counting rows given conditional

2011-08-04 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 04.08.2011 14:56:09: > a217 > Odeslal: r-help-boun...@r-project.org > > 04.08.2011 14:56 > > Komu > > r-help@r-project.org > > Kopie > > Předmět > > [R] Counting rows given conditional > > Hello, > > I have an input file that contains multiple

Re: [R] Possible bug of QR decomposition in package Matrix

2011-08-04 Thread Martin Maechler
> C6H5NO2 > on Thu, 4 Aug 2011 16:03:54 +0800 writes: > Thank you very much, Josh! > As you suggested, I will contact the developers of "Matrix". > PS, C6 are just initial characters of my email account :-) > Best wishes, > C6 well, as the posting guide (http:/

[R] Counting rows given conditional

2011-08-04 Thread a217
Hello, I have an input file that contains multiple columns, but the column I'm concerned about looks like: "TR" 5 0 4 1 0 2 0 To count all of the rows in the column I know how to do NROW(x$TR) which gives 7. However, I would also like to count only the number of rows with values >=1 (i.e. not 0

[R] limma contrast matrix

2011-08-04 Thread Belmont, John W
I am trying to correct for the effect of 2 covariates in a gene expression data set. design<-model.matrix(~0 + Factor + cov1 + cov2) QUESTION: How to set up the contrast matrix? The usual commands fit <- lmFit(selDataMatrix, design) cont.matrix <- makeContrasts(FacCont=Group1-Group2, level

Re: [R] 3D Bar Graphs in ggplot2?

2011-08-04 Thread Duncan Murdoch
On 11-08-04 8:20 AM, Martin Maechler wrote: Duncan Murdoch on Tue, 2 Aug 2011 16:51:38 -0400 writes: > On 11-08-02 2:39 PM, wwreith wrote: >> Does anyone know how to create a 3D Bargraph using >> ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a >> 2D b

Re: [R] R loop problem

2011-08-04 Thread Jean V Adams
Try this: q <- z[match(p, y)] Jean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA 715-627-4317, ext. 3125 (Office) 715-216-8014 (Cell) 715-623-6773 (FAX) http://www.g

Re: [R] Rdconv LaTeX files

2011-08-04 Thread Duncan Murdoch
On 11-08-04 1:42 AM, Michael O'Keeffe wrote: Hi, I've written a package and converted my Rd files into LaTeX using Rdconv. When I copy and paste these files in to my Sweave document I get the error message when compiling the Sweave file: ! Undefined control sequence. l.32 \inputencoding

Re: [R] persp()

2011-08-04 Thread Jean V Adams
Rosario, I don't think persp() is the function you need. You may find that the maps in R's historical world map would work for you. In that case you can try something like this (an example mapping France and Germany): require(maps) map("world", c("France", "Germany"), xlim=c(-6.61, 17.21), yl

Re: [R] persp()

2011-08-04 Thread Eik Vettorazzi
Hi Rosario, you might have a look at the "maps" and "maptools" (for reading shape-files) packages. #e.g. library(maps) map("world",c("sweden","germany")) Cheers Am 04.08.2011 02:58, schrieb Rosario Garcia Gil: > Hello > > I am trying to draw a basic black and white map of two European countri

Re: [R] 3D Bar Graphs in ggplot2?

2011-08-04 Thread Martin Maechler
> Duncan Murdoch > on Tue, 2 Aug 2011 16:51:38 -0400 writes: > On 11-08-02 2:39 PM, wwreith wrote: >> Does anyone know how to create a 3D Bargraph using >> ggplot2/qplot. I don't mean 3D as in x,y,z coordinates. Just a >> 2D bar graph with a 3D shaped bard. See attach

Re: [R] R loop problem

2011-08-04 Thread jim holtman
A subset of actual data and what you would expect as a result would be very helpful. All you say is that p.q are vectors, but it would appear that they are character vectors, but the content is unknown. Also will the expression "q[i==p]<-z[i==y]" have the same length on each side; the vectors app

[R] Sweave: pdf-graphics got three times lager with R 2.13.1

2011-08-04 Thread eriksengewald
Dear R-Users, I am using R for years now but recently I encounter a problem with the pdf-size of graphics generated with sweave. However, I am new in this forum. Hence, please don't hesitate if I am wrong here. I use a script which runs perfectly in R 2.11.1 and the pdf-size of the graphs is abou

[R] New multilevel modelling course practicals for the lmer and glmer functions - now online

2011-08-04 Thread Hilary Browne
The Centre for Multilevel Modelling is very pleased to announce the addition of R practicals to our free on-line multilevel modelling course. These give detailed instructions of how to carry out a range of analyses in R, starting from multiple regression and progressing through to multilevel m

Re: [R] How to extract sublist from a list?

2011-08-04 Thread Richard Ma
Hi Joshua, Really helpful that you posted so many useful solutions for my problem. I can understand all your codes except these: *[code] lapply(lst, `[[`, "y") ## or if you are only retrieving a single value sapply(lst, `[[`, "y") [/code]* Can you explain these a little bit? What does '[[' mean

Re: [R] Coefficient names when using lm() with contrasts

2011-08-04 Thread Peter Morgan
Many thanks, Greg. It works like a dream. Best wishes, Pete From: Greg Snow To: Peter Morgan , "r-help@r-project.org" Date: 03/08/2011 19:06 Subject:Re: [R] Coefficient names when using lm() with contrasts Sent by:r-help-boun...@r-project.org If you add column nam

  1   2   >