Re: [R] a question on matrix manipulation

2009-06-16 Thread Simon Blomberg
How about this: > mat <- matrix(rep(1:4, each=4), nrow=4, byrow=TRUE) > mat[rep(1:4, times=c(3,2,4,5)),] Cheers, Simon. On Wed, 2009-06-17 at 01:54 -0400, Lei Liu wrote: > Hi there, > > I have a question on manipulating a matrix. Say I have a matrix A > with 3 rows. I want to generate a new m

Re: [R] ifelse(is.na), with function inside

2009-06-16 Thread joscani
Try: b<- ifelse(is.na(a),1,2) Grześ wrote: > > 2 - is.na(a) - it's superb! but I need call a function: wy[i]<- > ifelse(((is.na(a))), call_fun1(x), call_fun2(x) > > > > Gabor Grothendieck wrote: >> >> Try: >> >> 2 - is.na(a) >> >> >> On Tue, Jun 16, 2009 at 5:46 PM, Grześ wrote: >>> >

Re: [R] a question on matrix manipulation

2009-06-16 Thread Dimitris Rizopoulos
Hi Lei, one way to do this is the following: mat <- matrix(rnorm(4*6), 4, 6) ind <- c(3, 2, 4, 5) mat[rep(seq_along(ind), ind), ] I hope it helps. Best, Dimitris Lei Liu wrote: Hi there, I have a question on manipulating a matrix. Say I have a matrix A with 3 rows. I want to generate a

[R] a question on matrix manipulation

2009-06-16 Thread Lei Liu
Hi there, I have a question on manipulating a matrix. Say I have a matrix A with 3 rows. I want to generate a new matrix B with 3 duplicates of the first row of A, 2 duplicates of the second row, and 4 duplicates of the third row. So B is a matrix with 9 rows. Or more general, I want to gener

Re: [R] How to subset my dataframe? (a bit tricky)

2009-06-16 Thread Don MacQueen
I would probably try a different approach than the other suggestions. Paste all the columns other than pond_id together. You now have a character vector. Then keep the rows in which an element of the vector contains "dnv" but does not contain "0 dnv" [use grep()]. This assumes there are no ext

[R] longitudinal analysis with latent construct

2009-06-16 Thread Carlos Santos Jr.
Folks, I need to test a model that has one predictor (a construct with three indicators) influencing four other variables. Something like what I try to show below. X ---> Y1, Y2, Y3, Y4 / | \ i1 i2 i3 Also, each variable was measured at 5 points in time. So, I'd like to

[R] getting cd_plot in vcd package to work with layout

2009-06-16 Thread Lyndon Walker
Hi, I'm trying to get 2x2 (or other layouts) of cd_plot from the vcd package. I have tried the usual commands like layout, par(mfrow...) etc and but cd_plot seems to ignore them and send the plotting window back to 1x1. I have also tried turning off the pop and newpage options in cd_plot but I st

Re: [R] ifelse(is.na), with function inside

2009-06-16 Thread Gabor Grothendieck
Try: 2 - is.na(a) On Tue, Jun 16, 2009 at 5:46 PM, Grześ wrote: > > Hi, > I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a) > function to get a vector like this: > wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in > vector "a" > > This is my

Re: [R] Constrained Optimization, a full example

2009-06-16 Thread Hesen Peng
H, I'm assuming that you are trying to find the solution of \beta to the question: argmin |y-X\beta|_2^2, which is a quadratic programming problem. On Tue, Jun 16, 2009 at 6:29 PM, Hesen Peng wrote: > Hello, > > Since the optimization goal is quadratic and constraint is linear, > quadratic pr

Re: [R] loop help

2009-06-16 Thread Rolf Turner
On 17/06/2009, at 3:12 PM, dde...@sciborg.uwaterloo.ca wrote: Hi all, I'm stuck trying to get syntax correct for the follwing type of loop. I would like to find the column with the largest value in a given row, and create a new column with a categorical variable indicating which column the high

[R] problem with scan recognizing newline '\n'

2009-06-16 Thread Mark Kimpel
I'm using R to do some file processing in Linux and am trying to read in the output of find . -type f -print > ~/Music_Archives_search_problem/ls.output.find.txt This command yields a text file with each line representing the full path name of all files in the directory and subdirs. Unfortunately,

[R] loop help

2009-06-16 Thread ddepew
Hi all, I'm stuck trying to get syntax correct for the follwing type of loop. I would like to find the column with the largest value in a given row, and create a new column with a categorical variable indicating which column the highest value of "i" comes from. too=data.frame(A=rnorm(10,1)

[R] ifelse(is.na), with function inside

2009-06-16 Thread Grześ
Hi, I have a vector a=c(NA, 3, 4, 4, NA, NA, 3) and I would like to use is.na(a) function to get a vector like this: wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in vector "a" This is my short code but something is wrong and I don't know what... for (i in 1:7){ a

Re: [R] Bin Category Labels on Axis

2009-06-16 Thread jproville
Thanks David! I had trouble understanding how to convert factors, and was playing around with as.numeric but it had never occurred to me to use a combination of both that and as.character. I am getting really close to the graph I want - I've played around with the arguments however I am still hit

Re: [R] how to verify gauss-markov hypothesis for linear model validity?

2009-06-16 Thread Charles C. Berry
On Tue, 16 Jun 2009, jose romero wrote: Hello list: (This is probably a stupid question).?Is there a "quick and easy" way to confirm the gauss-markov conditions of a linear multiple regression model? Well, those 'conditions' are _assumptions_, and as often happens they can be hard to veri

Re: [R] wrong results when apply+sum with missing values (NA)

2009-06-16 Thread Rolf Turner
Where the did you get the argument ``na.nr''? Perhaps you need new reading glasses. Anyhow, unless there's something else you're not telling us, apply(nafam,2,sum,na.rm=TRUE) should work just fine. cheers, Rolf Turner On 17/06/2009, at 1:56 PM, Germán Bonill

[R] wrong results when apply+sum with missing values (NA)

2009-06-16 Thread Germán Bonilla
Hi all, I can't compute the sum by columns to a matrix using apply() when I've got missing values (either 0 or NA)... I've got this matrix: >nafam Micro Flavo Helio Pseud Rhodo Bdello Chloro Syntro Verruco Prochloro SAR11 I 1 1 1NANA 1 3 NA 1

[R] how to verify gauss-markov hypothesis for linear model validity?

2009-06-16 Thread jose romero
Hello list: (This is probably a stupid question).  Is there a "quick and easy" way to confirm the gauss-markov conditions of a linear multiple regression model?  That the mean of the residuals is 0 can easily be tested for. The normality of the residuals as well (shapiro-wilk?).  But what abou

Re: [R] [R-help] how to install own R withour root?

2009-06-16 Thread J Dougherty
On Monday 08 June 2009 08:50:35 pm Daofeng Li wrote: > Dear list members, > > i am currently want to install Rpy2 in a linux box which has R 2.4.0 > installed > RPy requries R 2.7.0 or above > but i have no root previlleges > so my question is how to install R 2.7.0 on my own directory? > and repla

Re: [R] Constrained Optimization, a full example

2009-06-16 Thread Hesen Peng
Hello, Since the optimization goal is quadratic and constraint is linear, quadratic programming functions will help. There are many such packages available, e.g. quadprog. On Tue, Jun 16, 2009 at 5:54 PM, Stu @ AGS wrote: > After a few days of work, I think I nearly have it. > > Unfortunately, th

[R] R: R and miRecords

2009-06-16 Thread mauede
Thank you so much. Sorry for my basic questions that must read very silly for Biologists. As a physicist I was supposed to help Biology research with physics facets (free energy minimization, Molecular Dynamics, and so on). Unluckily, the student in charge of providing the test data (miRNA seque

[R] Constrained Optimization, a full example

2009-06-16 Thread Stu @ AGS
After a few days of work, I think I nearly have it. Unfortunately, theta is unchanged after I run this (as a script from a file). I thought that theta would contain the fitted parameters. The goal here is to find the least squares fit according to the function defined as "rss" subject to the

Re: [R] Coefficient of determination

2009-06-16 Thread Rolf Turner
On 17/06/2009, at 9:03 AM, stephen sefick wrote: look at the archives - I don't remember who gave a wonderful explanation on this topic, but it is there. hth Stephen Sefick Don't know if this is what you had in mind, but Martin Maechler's post of 28 April 2009 http://finzi.psych.upenn.edu/R

Re: [R] save the output of summary(lmList(x)) into a dataframe

2009-06-16 Thread Paul Johnson
On Tue, Jun 16, 2009 at 3:29 AM, Cecilia Carmo wrote: > Hi r-helpers! > > I need to save the output of summary() function that I’ve runned like this: > z<- lmList(y~x1+x2| x3, na.action=na.omit,data1,subset=year==1999) > w<-summary(z) > The output (w) is something like this: > Call: >  Model: y ~ x

Re: [R] Statistically detecting thresholds...

2009-06-16 Thread milton ruser
Hi Jonathan, I don't know if I got the point, but for thresholds assessments, give a look at segmented package. bests milton brazil=toronto On Tue, Jun 16, 2009 at 5:23 PM, Jonathan Greenberg wrote: > Rers: > > I have some ecological data (stream velocity vs. % cover of submerged > weeds) that

Re: [R] xyplot format axis

2009-06-16 Thread Deepayan Sarkar
On Tue, Jun 16, 2009 at 7:24 AM, taz9 wrote: > > Hi All, > > I'm trying to format the y-axis in an xyplot to show numbers with a comma > separating the thousands but I'm not able to do it using formatNum(y, > big.mark=","). This is what I have: > > library(lattice) > > year<-c(2003,2004,2005,2006,2

[R] Statistically detecting thresholds...

2009-06-16 Thread Jonathan Greenberg
Rers: I have some ecological data (stream velocity vs. % cover of submerged weeds) that shows strong evidence of a thresholding step-function, e.g. below some velocity, % cover ranges from 0% to 100% (with no apparent relationship to velocity within this range of velocities), but above a cert

Re: [R] How to subset my dataframe? (a bit tricky)

2009-06-16 Thread markleeds
Hi Bill: I was trying to do below myself but was having problems. So I took your solution and made another one. yours was working a little weirdly because I don't think the person wants to keep rows where there are 2 dnv's in a row and he/she also wanted to keep the row if the sec

Re: [R] Coefficient of determination

2009-06-16 Thread Bert Gunter
For linear, yes: ?summary.lm For nonlinear, no, since there is no such thing (unambiguously, anyway) in nonlinear regression. It's almost always a bad idea even in linear regression, though. Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-projec

Re: [R] Coefficient of determination

2009-06-16 Thread stephen sefick
look at the archives - I don't remember who gave a wonderful explanation on this topic, but it is there. hth Stephen Sefick On Tue, Jun 16, 2009 at 4:50 PM, Derek An wrote: > Dear all, > > Is there a instruction that can help me obtain the coefficient of > determination R^2 after doing linear/non

Re: [R] Confidence Bands in Polynomial Regression

2009-06-16 Thread Rolf Turner
Perhaps I'm just being obtuse, but I don't see what ols() has to do with the question that was asked. Often with R it is easier to roll your own rather than struggling with the arcana of someone else's software. Here is a function that seems to do what Ben wants: pecb <- function(fit,tt,alp

Re: [R] Running stats on individual data.frames from the split()function list

2009-06-16 Thread Daniel Malter
This easy function you are looking for is tapply. Take a look at the following example: day=rep(1:30,each=30) ##There are thirty days ##with thirty obs each y=rnorm(length(day),mean=2*day,sd=day) ##a dep. variable ##with mean=2*day index no. ##and sd=day tapply(y,day,length) ##shows no. of obs f

[R] Coefficient of determination

2009-06-16 Thread Derek An
Dear all, Is there a instruction that can help me obtain the coefficient of determination R^2 after doing linear/nonlinear regression using lm/nls? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/m

[R] Running stats on individual data.frames from the split() function list

2009-06-16 Thread Eric Vander Wal
Hello, and thanks in advance. I have a data.frame from which I want to count observations that occur on each day and determine the mean and std.error of said counts. For instance: x<-split(my.df, my.df$julian.days) Although I'm still in my R learning infancy I am under the impression that x

Re: [R] R and miRecords

2009-06-16 Thread iaingallagher
Try TargetScan, Pictar, miRbase. These are all useful miRNA databases. Data can be downloaded as cvs or tab delimited files and parsed in R after that. In fact this may be possible with the resource you have looked at (although I haven't checked). Cheers Iain --- On Tue, 16/6/09, David Winsem

Re: [R] How to subset my dataframe? (a bit tricky)

2009-06-16 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Na > Sent: Tuesday, June 16, 2009 11:27 AM > To: r-help@r-project.org > Subject: [R] How to subset my dataframe? (a bit tricky) > > Hi R-helpers, > > I would like to subset

Re: [R] turning off escape sequences for a string

2009-06-16 Thread Allan Engelhardt
Backslashes in character strings need to be doubled. Your "\b" is a backspace. "\\" is a backslash. http://cran.r-project.org/doc/manuals/R-lang.html#Literal-constants On 16/06/09 17:12, Stephen J. Barr wrote: > Hello, > > I would like to create a matrix with one of the columns named > $\del

Re: [R] Sweave template

2009-06-16 Thread Romain Francois
Frank E Harrell Jr wrote: Dear Group, I have made significant improvements to our Sweave template, have made the template self-contained (i.e., you can run it yourself and it will find the datasets it needs), and have included the output pdf file. This is at http://biostat.mc.vanderbilt.edu/

[R] ui and ci explanatory documentation

2009-06-16 Thread Stu @ AGS
Hi Livia and everyone, Did you ever get a response on this question from last year (Jan 2008)? I am also looking for more explanatory documentation on the ui and ci parameters for the function constrOptim(). The examples provided in the R help and the full refe

[R] How to subset my dataframe? (a bit tricky)

2009-06-16 Thread Mark Na
Hi R-helpers, I would like to subset my dataframe, keeping only those rows which satisfy the following conditions: 1) the string "dnv" is found in at least one column; 2) the value in the column previous to the one "dnv" is found in is not "0" Here's what my data look like:     POND_ID 2009-05-

Re: [R] How to extract all rows that contain the value of X in any column?

2009-06-16 Thread Jorge Ivan Velez
Dear Mark, If I understood correctly, the following should work: index <- apply(pvh, 1, function(x) any(x == "dnv") ) pvh_dnv <- pvh[index,] pvh_dnv HTH, Jorge On Tue, Jun 16, 2009 at 1:41 PM, Mark Na wrote: > Hi R-helpers, > > I'm trying to use this code > > > pvh_dnv<-pvh[sapply(pvh=="dnv"

Re: [R] How to extract all rows that contain the value of X in any column?

2009-06-16 Thread Henrique Dallazuanna
Sorry, it should be: pvh[apply(pvh == "dnv", 1, any),] On Tue, Jun 16, 2009 at 3:09 PM, Henrique Dallazuanna wrote: > Try this: > > pvh[apply(pvh == "dnv", 2, any)] > > > On Tue, Jun 16, 2009 at 2:41 PM, Mark Na wrote: > >> Hi R-helpers, >> >> I'm trying to use this code >> >> > pvh_dnv<-pvh[s

Re: [R] How to extract all rows that contain the value of X in any column?

2009-06-16 Thread Henrique Dallazuanna
Try this: pvh[apply(pvh == "dnv", 2, any)] On Tue, Jun 16, 2009 at 2:41 PM, Mark Na wrote: > Hi R-helpers, > > I'm trying to use this code > > > pvh_dnv<-pvh[sapply(pvh=="dnv"),] > > to make a new dataframe containing the rows from pvh that contain the > value of "dnv" in ANY column. > > But, i

Re: [R] How to extract all rows that contain the value of X in any column?

2009-06-16 Thread David Winsemius
No example. You are a regular now and examples ARE requested. Would have thought something along the lines of: pvh[ unlist( apply(pvh, 1, function(x) "dnv" %in% as.character(x) ) ) , ] Not sure if the unlist or as.character are really needed because ... no example on which to test. On J

Re: [R] Indexing Arbitrary Time Intervals in zoo Series

2009-06-16 Thread Gabor Grothendieck
See ?window.zoo Also suggest you use dput to display sample data in posts to r-help. On Tue, Jun 16, 2009 at 1:19 PM, wrote: > Hi guys > > Does anyone know if it is possible to index a zoo series by a sequence? For > instance, with the following irregular zoo object, I can calculate the range >

[R] How to extract all rows that contain the value of X in any column?

2009-06-16 Thread Mark Na
Hi R-helpers, I'm trying to use this code > pvh_dnv<-pvh[sapply(pvh=="dnv"),] to make a new dataframe containing the rows from pvh that contain the value of "dnv" in ANY column. But, it's not working. I get this error Error in match.fun(FUN) : element 1 is empty; the part of the args list o

[R] The R-Inferno

2009-06-16 Thread Stu @ AGS
Patrick, Thanks for your suggestion! The R-Inferno was especially useful!! The first chapter had me chuckling aloud despite the fact that I work alone. Well worth the price! Thanks! Stu > -Original Message- > From: Patrick Burns [mailto:pbu...@pburns.seanet.com] >

[R] Indexing Arbitrary Time Intervals in zoo Series

2009-06-16 Thread rory . winston
Hi guys Does anyone know if it is possible to index a zoo series by a sequence? For instance, with the following irregular zoo object, I can calculate the range of its time-based index: > r <- range(index(l.zoo)) > r [1] "2009-06-15 01:44:20.802 GMT" "2009-06-15 16:54:24.124 GMT" If I just w

Re: [R] using lattice dotplot with two equal data points

2009-06-16 Thread Deepayan Sarkar
On Fri, Jun 12, 2009 at 10:54 AM, Chosid, David (FWE) wrote: > I'm wondering if I am dealing with a limitation in lattice. It's > probably due to my own limitations though. > > I'm working with a lattice dotplot. The x-axis is set at "free". In > one panel, there are only two data points that ha

[R] Help implementing a simple Python port

2009-06-16 Thread Nathan Torrance
Hello list, I wonder if anyone might be able to help me troubleshoot an attempt at porting some simple Python code to R. The function below is supposed to take a matrix containing item ratings from various users and, given a vector containing at least 1 rating and 1 missing value, employ a 'weigh

Re: [R] adressing dataframes

2009-06-16 Thread David Winsemius
I have not figured out why you seem so attached to the c(type) strategy but try: numbers <-summary(rawdata[ , c(type)] ) On Jun 16, 2009, at 12:06 PM, John Fitzgerald wrote: Hi everyone, I experience some problems with adressing of data.frames when I retrieve some information for geo

Re: [R] Sweave template

2009-06-16 Thread Frank E Harrell Jr
Kevin W wrote: Frank, Your template is very interesting. The "pretty-ifing" of the left arrow and tilde in the input chunk has the unfortunate side-effect of making the code non-paste-able into R. Kevin, I haven't needed to do that. It's best to make the .Rnw file available to others, or

Re: [R] Trouble with optim on a specific problem

2009-06-16 Thread Stu @ AGS
Liviu, Thanks for your comments. With continued study and experimentation, I have discovered the following: a. I need to rewrite the function to return a 1x1 as you suggested; b. it seems that constrOptim() is the most appropriate routine to use on a nonlinear

Re: [R] Trouble with optim on a specific problem

2009-06-16 Thread Liviu Andronic
Hello, On 6/16/09, Stu @ AGS wrote: > Thanks for your response! > No, my basic equation does not use matrices at all. It takes scalar values > and returns a scalar. > Not quite. Taking the example above, if you run the following: > with(observs , {1*x1*x2^2*x3^3}) [1] 0.000e+00 4.267e+16 8.910

[R] turning off escape sequences for a string

2009-06-16 Thread Stephen J. Barr
Hello, I would like to create a matrix with one of the columns named $\delta$. I have also created columns $\beta_1$ , $\beta_2$, etc. However, it seems like \d is an escape sequence which gets automatically removed. (Using these names such that they work right in xtable -> latex) colnames(simple

[R] adressing dataframes

2009-06-16 Thread John Fitzgerald
Hi everyone, I experience some problems with adressing of data.frames when I retrieve some information for geographical position (ypos, xpos) ot of a MySQL Database and want to perform some simple statistics. The problem is adressing the dataframes with a construct like rawdata[c(type)] vs. raw

Re: [R] save the output of summary(lmList(x)) into a dataframe

2009-06-16 Thread Daniel Malter
Hi, your problem has nothing to do with your specific dataset. Further, it is - let's say - suboptimal to push a 5 MB dataset through the mailing list. The posting guides asks to provide an example with self-contained code; this is what Milton has asked for. Such an example is not out of reach for

Re: [R] [R-help] how to install own R withour root?

2009-06-16 Thread Daofeng Li
Hi, yes, that's amazing follows my .bashrc file # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi alias rm='rm -i' if [ ! -d $HOME/trash ]; then mkdir $HOME/trash fi del ( ) { mv "$@" $HOME/trash/.; } PATH=/hom

Re: [R] Sweave template

2009-06-16 Thread Kevin W
Frank, Your template is very interesting. The "pretty-ifing" of the left arrow and tilde in the input chunk has the unfortunate side-effect of making the code non-paste-able into R. I seem to recall that your reports used to include the latex source code as an appendix. Maybe one option could b

Re: [R] Question regarding dataframes, matrix, frame, etc...

2009-06-16 Thread David Winsemius
?data.matrix Perhaps: pairs(data.matrix(asdf[ , 1:7]) ) On Jun 16, 2009, at 10:58 AM, njhuang86 wrote: Hi all, As of now, I have a 15x8 matrix (name is "asdf"). The first seven columns contain numbers while the last column contains a string. The class of each column is "character". W

Re: [R] The most straightfoward way to write a function that sums over the rows of a matrix

2009-06-16 Thread David Winsemius
The apply function is the way to iterate over rows or columns of dataframes or matrices. An example would have made this process easier testing and I have given up doing that job for You might try: apply(observs, 1, function(x) Fn(par, x) ) On Jun 16, 2009, at 11:08 AM, Stu @ AGS wrote:

Re: [R] R and miRecords

2009-06-16 Thread David Winsemius
Looks like a BioConductor question. On Jun 16, 2009, at 11:05 AM, wrote: I wonder whether R provides an interface to access miRecords data. Particularly, I am looking for extracting humans miRNA and target genes sequences. All such information is stored in there in a set of structured web

[R] Error using getBM() to query BioMart archives

2009-06-16 Thread Aaron Wolen
I'm trying to identify the positions of all genes within a specific chromosomal region using biomart. When using the current biomart database I'm able to do this without issue. However, I need to use build 36 of the mouse genome which was last included in ensembl mart 46. I selected this ma

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread Prof Brian Ripley
On Tue, 16 Jun 2009, Prof Brian Ripley wrote: On Tue, 16 Jun 2009, jim holtman wrote: I think the only way that you are going to get it to stop on the first mismatch is to write your own function in C if you are concerned about the time. Matching on character vectors will be even more costly

Re: [R] The most straightfoward way to write a function that sums over the rows of a matrix

2009-06-16 Thread Ronggui Huang
Why not just use rowSums? Ronggui 2009/6/16 Stu @ AGS : > Hello! > > > > I am trying to write a function with vector and data.frame parameters that > uses the sum() function and values from the rows of the data.frame. > > I need to pass this function as a parameter to optim(). > > > > My starting

Re: [R] [R-help] how to install own R withour root?

2009-06-16 Thread Michael Dewey
At 10:57 16/06/2009, Daofeng Li wrote: Hi, i just add /home/lidaof/R/bin and /home/lidaof/R/lib to the end of the PATH variable yet i type R command runs the system installed R 2.4.0... [snip] >> >> On Sat, 13-Jun-2009 at 03:43PM +1000, bill.venab...@csiro.au wrote: >> >> |> You need to adj

Re: [R] Question regarding dataframes, matrix, frame, etc...

2009-06-16 Thread stephen sefick
plot(as.numeric(asdf[,1:7])) On Tue, Jun 16, 2009 at 11:10 AM, stephen sefick wrote: > plot(asdf[,1:7]) > > On Tue, Jun 16, 2009 at 10:58 AM, njhuang86 wrote: >> >> Hi all, >> >> As of now, I have a 15x8 matrix (name is "asdf"). The first seven columns >> contain numbers while the last column cont

Re: [R] Question regarding dataframes, matrix, frame, etc...

2009-06-16 Thread stephen sefick
plot(asdf[,1:7]) On Tue, Jun 16, 2009 at 10:58 AM, njhuang86 wrote: > > Hi all, > > As of now, I have a 15x8 matrix (name is "asdf"). The first seven columns > contain numbers while the last column contains a string. The class of each > column is "character". When I use the plot function to displa

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread Prof Brian Ripley
On Tue, 16 Jun 2009, jim holtman wrote: I think the only way that you are going to get it to stop on the first mismatch is to write your own function in C if you are concerned about the time. Matching on character vectors will be even more costly since it is having to loop to check the equality

[R] The most straightfoward way to write a function that sums over the rows of a matrix

2009-06-16 Thread Stu @ AGS
Hello! I am trying to write a function with vector and data.frame parameters that uses the sum() function and values from the rows of the data.frame. I need to pass this function as a parameter to optim(). My starting point is: observs <- data.frame(y, x1, x2, x3) Fn <- function(par,

[R] R and miRecords

2009-06-16 Thread mauede
I wonder whether R provides an interface to access miRecords data. Particularly, I am looking for extracting humans miRNA and target genes sequences. All such information is stored in there in a set of structured web site pages (http://mirecords.umn.edu/miRecords) I would greatly appreciate any

[R] Question regarding dataframes, matrix, frame, etc...

2009-06-16 Thread njhuang86
Hi all, As of now, I have a 15x8 matrix (name is "asdf"). The first seven columns contain numbers while the last column contains a string. The class of each column is "character". When I use the plot function to display a scatter plot between any of the two columns, ie. plot(asdf[, 1], asdf[, 2])

Re: [R] books on Time series

2009-06-16 Thread Bailey, Jason W LCDR OPNAV, N81
Antonio, I just got the Cowpertwait and Metcalfe book (released today in the U.S.) and I think it's what you're looking for. It has good, practical examples and lots of sample code. I looked at Cryer's book, but it had too much on time series theory for my purposes; Cowpertcalfe helpfully marks

[R] question about adding plots in a grid (lattice package)

2009-06-16 Thread Marion Dumas
Hello! I am starting to use the lattice package. I generated an xyplot conditioned on a factor that has three levels: hence I get three plots in three panels spaces and one is left empty. I would like to add a plot to the empty panel space. Is it possible? Thank you ___

Re: [R] Output of Anova (CAR package) in Sweave

2009-06-16 Thread Maria Wolters
Many thanks to John Fox, who replied on-list, and to David Hajage, who replied to me off list. David suggested this quick hack of the print.anova.mlm function, which I am sharing with his permission # From print.Anova.mlm xtable.Anova.mlm <- function (x, ...) { test <- x$test repeated <-

[R] xyplot format axis

2009-06-16 Thread taz9
Hi All, I'm trying to format the y-axis in an xyplot to show numbers with a comma separating the thousands but I'm not able to do it using formatNum(y, big.mark=","). This is what I have: library(lattice) year<-c(2003,2004,2005,2006,2007,2008,2003,2004,2005,2006,2007,2008) dept<-c("Politics","P

Re: [R] How to replace outliers by group median?

2009-06-16 Thread Frank E Harrell Jr
This is a sure way to get a biased variance estimate. Instead, use a robust dispersion (scale) estimator such as Gini's mean difference (average absolute difference between any two observations). The median is a robust location estimator. There are others. If your ultimate goal is a comparis

Re: [R] save the output of summary(lmList(x)) into a dataframe

2009-06-16 Thread milton ruser
Hi Cecilia, Could you send us a reproducible example? cheers milton On Tue, Jun 16, 2009 at 4:29 AM, Cecilia Carmo wrote: > Hi r-helpers! > > I need to save the output of summary() function that I’ve runned like this: > z<- lmList(y~x1+x2| x3, na.action=na.omit,data1,subset=year==1999) > w<-s

Re: [R] Chron / zoo index problem

2009-06-16 Thread rory . winston
Thanks Gabor - I'll check it out. Actually I just realised I can also do what I am looking for in a ridiculously simple manner (as the data I have is intra-day): aggregate(l.zoo, hours(index(l.zoo)), mean) Cheers -- Rory On Jun 16, 2009 2:46pm, Gabor Grothendieck wrote: > See R News 4/1.

[R] How to replace outliers by group median?

2009-06-16 Thread Mao Jianfeng
Dear R-helpers, Very small amount of outliers can greatly affect the mean and many other statistic of a numeric variable. So, usually we must deal with the outliers properly in the process of data analysis. Here, I want to replace outliers with the group median of the variable. But, I can not cons

Re: [R] Chron / zoo index problem

2009-06-16 Thread Gabor Grothendieck
See R News 4/1. On Tue, Jun 16, 2009 at 9:04 AM, wrote: > Hi all > > I have an irregular zoo series, where the time index looks like the > following: > >> head(time(l.zoo)) > > [1] "2009-06-15 01:44:20.802 GMT" "2009-06-15 01:44:20.812 GMT" "2009-06-15 > 01:44:20.837 GMT" "2009-06-15 01:44:20.848

Re: [R] Package Install "Design" fails on Ubuntu 8.04

2009-06-16 Thread Frank E Harrell Jr
Not to fix your fundamental problem, but if you don't mind using the next-to-last versions of the packages you can install them quite easily as debian/Ubuntu packages. They are named r-cran-hmisc and r-cran-design. You can use sudo apt-get install ... or the adept package manager etc. Frank

Re: [R] Output of Anova (CAR package) in Sweave

2009-06-16 Thread John Fox
Dear Maria, > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Maria Wolters > Sent: June-16-09 6:31 AM > To: r-help@r-project.org > Subject: [R] Output of Anova (CAR package) in Sweave > > Dear list, > > I use Sweave almost exc

Re: [R] Assigning Data a name from within another variable?

2009-06-16 Thread Kenny Larsen
Thnaks to both of you, with a combined effort of the Wiki and your code I have now managed to get teh result I was after. When I have a better understanding of what the code is doing I shall make an effort to contribut to the Wiki! Cheers, Kenny Kenny Larsen wrote: > > Hi All, > > I have hu

[R] Generation from COX PH with gamma frailty

2009-06-16 Thread Cetinyürek Aysun
Hello, I want to generate data set from Cox PH model with gamma frailty effects. theta(parameter for frailty distribution)=2 beta=1.5 n=300 cluster size=30 number of clusters=10 I think I should first generate u from Gamma(Theta,theta) and then using this theta I could not decide how I should g

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread utkarshsinghal
Not in the direction I was looking, but your function "fff" really speed up the process, and using it along with "fff3" is fine for me. Thanks Petr PIKAL wrote: > Hi > > r-help-boun...@r-project.org napsal dne 16.06.2009 14:31:21: > > >> Hi Jim, >> >> What you are saying is correct. Although

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread baptiste auguie
[correcting a stupid error in my previous post] testTwoStages <- function(x, y, head.stop = 100){ if(!isTRUE(all(head(x, head.stop) == head(y, head.stop { print(paste("quick test returned FALSE")) return(FALSE) } else { full.test = isTRUE(all(tail(x, length(x) - head.stop) == tail(

Re: [R] Schoenfeld Residuals with tied data

2009-06-16 Thread Terry Therneau
-- begin included message Thank you for the reply. I really appreciate it. I calculated the Scoenfeld residual per event and my results are the following: finage race 17 -0.33942334 -2.0722187270.29024804 20 0.394600944 5.3039687

Re: [R] Trouble with optim on a specific problem

2009-06-16 Thread Stu @ AGS
Thanks for your response! No, my basic equation does not use matrices at all. It takes scalar values and returns a scalar. What I am trying to accomplish is to find the "best-fit" coefficients to the equation as follows: y ~ c1 * x1 * x2^c2 * x3^c3 where y, x1, x2, and x3 are observed data and c

[R] Chron / zoo index problem

2009-06-16 Thread rory . winston
Hi all I have an irregular zoo series, where the time index looks like the following: > head(time(l.zoo)) [1] "2009-06-15 01:44:20.802 GMT" "2009-06-15 01:44:20.812 GMT" "2009-06-15 01:44:20.837 GMT" "2009-06-15 01:44:20.848 GMT" "2009-06-15 06:00:01.320 GMT" [6] "2009-06-15 06:00:01.330 G

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 16.06.2009 14:31:21: > Hi Jim, > > What you are saying is correct. Although, my computer might not have > same speed and I am getting the following for 10M entries: > >user system elapsed > 0.559 0.038 0.607 With numbers you may speed it a

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread baptiste auguie
utkarshsinghal wrote: Hi Jim, What you are saying is correct. Although, my computer might not have same speed and I am getting the following for 10M entries: user system elapsed 0.559 0.038 0.607 Moreover, in the case of character vectors, it gets more than double. In my modeling,

[R] Output of Anova (CAR package) in Sweave

2009-06-16 Thread Maria Wolters
Dear list, I use Sweave almost exclusively for writing papers, and I have become quite spoiled by the excellent xtable export facilities. Has anybody written an xtable method for the Anova function in CAR, or has anybody used a different set of functions to import Anova results into a table in an

Re: [R] color gradation inversion.

2009-06-16 Thread David Winsemius
?rev On Jun 16, 2009, at 5:13 AM, Naoki Irie wrote: Dear list I'm having trouble with inverting color gradation. As seen in the "rgl" example, library(rgl) example(rgl.surface) I understand that I can assign colors to heights for each point. col <- colorlut[ y-ylim[1]+1 ] # assign color

[R] help I want to use anova-pca.

2009-06-16 Thread yongkook Kwon
Hi I want to use anova-pca method, but I don't know what package I use to. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-proj

[R] Package Install "Design" fails on Ubuntu 8.04

2009-06-16 Thread Dennis Proppe
Dear All, I am running a Ubuntu 8.04 System and trying to install the Design-package. Hmisc is already installed, all fortran compilers and a Tex-Package are also on board. I searched the net and the help list for analogue threads, but didn't find any. Whenever I run the install.packages("Des

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread jim holtman
I think the only way that you are going to get it to stop on the first mismatch is to write your own function in C if you are concerned about the time. Matching on character vectors will be even more costly since it is having to loop to check the equality of each character in each element. This is

Re: [R] reading Excel file

2009-06-16 Thread Hans-Peter Suter
> I was using older version of R (installed early). I install new version of R > (R.2.9.0) but i could not find package "xlsReadWrite" to read Excel file. As others have pointed out (thanks) you can find it here: http://treetron.googlepages.com/. It runs fine in 2.9.0. > Is there any alternative

Re: [R] Testing if all elements are equal in a vector/matrix

2009-06-16 Thread utkarshsinghal
Hi Jim, What you are saying is correct. Although, my computer might not have same speed and I am getting the following for 10M entries: user system elapsed 0.559 0.038 0.607 Moreover, in the case of character vectors, it gets more than double. In my modeling, which is already highly

[R] overshoot of formula line in summary output of Sweave

2009-06-16 Thread Ken Knoblauch
Hi, In the Sweave output for summary for several types of model objects and also for the comparison of models with anova, I find that that the display of the call(s) or formula does not obey the width option, even with keep.source=TRUE set, so that a long formula will overshoot the margins in the

  1   2   >