[R] Simple Function

2010-11-09 Thread rnick
Hi guys, Very new to R and your help would be highly appreciated for the following problem. I am trying to create a simple function which registers values within an array through a for loop. These are the steps I have followed: 1) Declared 2 global matrices 2) Create function mat() with i as an

[R] poisson regression

2010-11-09 Thread avsha38
Hello All, I have a question regarding using Poission Regression, I would like to Model the number of hospitalizations by a set of covariates. The issue I ran into is "lack of fit" even after I tried to solve the "overdispersion" problem with negetive binomial. What would you suggest? 1. Is t

Re: [R] Centring titles for pairs of plots.

2010-11-09 Thread Jim Lemon
On 11/10/2010 11:31 AM, Rolf Turner wrote: I would like to centre titles for pairs of plots in a 3-x-2 array. Each row of the array corresponds to a calendar year and I would like to have the year value centred between the two plots in the row, and just above their upper edges. I have attached

Re: [R] Simple Function

2010-11-09 Thread Michael Bedward
If you want to assign to a variable in your workspace, rather than a local variable in your function, you can use the <<- operator (double headed arrow) like this... mat <- function(i) { for (k in i:10) { y[k] <<- k+1 f[k] <<- y[k-1] / 2 } } Type ?"<<-" for the help page. Michael O

[R] Simple Function

2010-11-09 Thread rnick
Hi guys, Very new to R and your help would be highly appreciated for the following problem. I am trying to create a simple function which registers values within an array through a for loop. These are the steps I have followed: 1) Declared 2 global matrices 2) Create function mat() with i as

Re: [R] concatenating a string to a column

2010-11-09 Thread Santosh Srinivas
Try on these lines library(MASS) data(Boston) Boston$crim<-paste(Boston$crim,"Test",sep="-") -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of sachinthaka.abeyward...@allianz.com.au Sent: 10 November 2010 10:39 To: R-help Forum Subject

Re: [R] Which - value not present

2010-11-09 Thread vioravis
Thank you. It works fine. -- View this message in context: http://r.789695.n4.nabble.com/Which-value-not-present-tp3035455p3035575.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/

Re: [R] R-2.12.0 problem on Sparc Solaris 10

2010-11-09 Thread Prof Brian Ripley
I don't see enough information to help here, and this is rather an R-devel topic (see the posting guide for the difference). Which compiler and which version? What level of optimization and other compiler flags? 32- or 64-bit build? The Sun Studio compiler works (see the R-admin manual and the

Re: [R] jags error message

2010-11-09 Thread Michael Bedward
Hi James, The following is probably more an expression of empathy than direct help :) I've used rjags quite a bit but have often found it to be very picky about the formulation of the model. Scripts that run without problem under WinBUGS (for instance) provoke errors with jags and more often than

Re: [R] arrays of arrays

2010-11-09 Thread Michael Bedward
Hi Sachin, That's OK - you don't need to know the dimensions up front and you can add new vectors, or elements to an existing vector, as required. # empty list to start with X <- list() # we get a vector v1 <- c(1, 2, 3, 4, 5) # add it to the ragged array X <- c(X, list(v1)) # get another coup

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Ab Hu
Peter Langfelder wrote: > > Sorry, I'm not sure what you want to do in points 2-4. Shrink the > mountain vertically or horizontally? You can for example look up image > resizing algorithms if you want to shrink the area under the mountain > but keep the shape of the mountain (approximately) the

Re: [R] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana
Hi Michael, Thanks for that. Its a starting point I guess. But what if I didn't know the length of the outer vector is? (i.e. all dimensions are variable). Or for that matter I don't actually know what the initial dimensions are going to be. All of it is created within a for loop. I was hoping fo

Re: [R] Performing a geometric seqeunce using iterators?

2010-11-09 Thread Dennis Murphy
Hi: Is this what you're looking for? x <- 1:10 1 + sum((1/x)^(1:10)) [1] 2.291286 1 + sum(x^(-(1:10))) [1] 2.291286 Since this may be a homework question, I'll let you figure out how to turn it into a function - it only needs one change. On Tue, Nov 9, 2010 at 7:16 PM, vicho wrote: > > I wan

Re: [R] concatenating a string to a column

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 9:09 PM, wrote: > > Hi All, > > Suppose I want to concatenate a zero to all the values to a column called > period in data frame A. I want to do the following but the following > command actually deletes the entire column altogether. > >  A$period<-cat(A$period,"0",sep="");

Re: [R] concatenating a string to a column

2010-11-09 Thread Michael Bedward
You want the paste command (cat is for printing to the console)... A$period <- paste(A$period, 0, sep="") Michael On 10 November 2010 16:09, wrote: > > Hi All, > > Suppose I want to concatenate a zero to all the values to a column called > period in data frame A. I want to do the following bu

Re: [R] arrays of arrays

2010-11-09 Thread Michael Bedward
Hello Sachin, You have a "ragged array" and you can easily store this as a list of vectors... x <- list(c(0,0,1,1), c(1,3,5), 4, c(7, -1, 8, 9, 10, 6)) The only gotcha with this is that you will then need to use double brackets for the first index when retrieving values (single brackets will ret

[R] concatenating a string to a column

2010-11-09 Thread sachinthaka . abeywardana
Hi All, Suppose I want to concatenate a zero to all the values to a column called period in data frame A. I want to do the following but the following command actually deletes the entire column altogether. A$period<-cat(A$period,"0",sep=""); Any help would be appreciated. Thanks, Sachin p.s.

Re: [R] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana
Hi Erik, Thanks for replying. Only problem with that is that each row has 5 elements (or 5 columns). I want varying number of columns as shown in my example. x<- 0 0 1 1 1 3 5 4

Re: [R] Centring titles for pairs of plots --- a solution.

2010-11-09 Thread Greg Snow
Also look at the grconvertX function for a different way of finding the coordinates to plot at. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun

[R] matrix limit

2010-11-09 Thread zhiji19
Dear experts, I need to write R code for lim(I+X/n)^n with "repeat loop". (note: limit is n from 1 to infinity, I is identity matrix, X is square symmetric matrix) Can anyone please provide help with my question. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/matrix

Re: [R] Performing a geometric seqeunce using iterators?

2010-11-09 Thread Erik Iverson
On 11/09/2010 09:16 PM, vicho wrote: I want to make a function for geometric seqeunce since testing=function(x){i=1;ans=1;while(true){ans=ans+(1/x)^i ; i=i+1} ;return(ans)} doesn't work... the program is freeze... What exactly are you trying to do? Where does "true" get set? Did you mean T

Re: [R] arrays of arrays

2010-11-09 Thread Erik Iverson
This type of object has the "matrix" class in R. So just use ?matrix to create it. matrix(1:25, ncol = 5) for example. On 11/09/2010 08:55 PM, sachinthaka.abeyward...@allianz.com.au wrote: Hi All, I want to have an array/ matrix that looks this x<- 0 0 1 1 1

Re: [R] How to extract Friday data from daily data.

2010-11-09 Thread Gabor Grothendieck
On Tue, Nov 9, 2010 at 11:23 AM, thornbird wrote: > > Thanks for your suggestion. I received a few error messages. Can anyone help > me figure out why I get the following error messages and how to solve them > by revising my code? The data is shown in the post above. Thanks. > > >> library(zoo) >>

Re: [R] arrays of arrays

2010-11-09 Thread Santosh Srinivas
Not sure if this is the best way ... but something similar to my question from yesterday that I could solve as follows. > tD <- read.csv("Book1.csv") > tD X0 X0.1 X1 X1.1 X X.1 1 13 5 NA NA NA 2 44 NA NA NA NA 3 7 -1 89 10 6 > x1 <- tD[1,1:3] > > x2 <- tD[2,1:2] > >

Re: [R] Which - value not present

2010-11-09 Thread jim holtman
length(result) == 0 > result <- integer(0) > result integer(0) > length(result) == 0 [1] TRUE > On Tue, Nov 9, 2010 at 9:55 PM, vioravis wrote: > > I am trying to use which function to obtain the index of a value in a > dataframe. Depending on whether the value is present in the dataframe or no

[R] Performing a geometric seqeunce using iterators?

2010-11-09 Thread vicho
I want to make a function for geometric seqeunce since testing=function(x){i=1;ans=1;while(true){ans=ans+(1/x)^i ; i=i+1} ;return(ans)} doesn't work... the program is freeze... from my research, i know i should use iterators. I read iterators.pdf at http://cran.r-project.org/web/packages/itera

[R] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana
Hi All, I want to have an array/ matrix that looks this x<- 0 0 1 1 1 3 5 4 4 7 -1 8 9 10 6 I hope this makes sense. So basically if I want x[1,3] it will access 0 and similarly x[4,2], -1. Thanks in ad

[R] Which - value not present

2010-11-09 Thread vioravis
I am trying to use which function to obtain the index of a value in a dataframe. Depending on whether the value is present in the dataframe or not I am performing further operations to the dataframe. However, if the value is not present in the dataframe, I am getting an integer(0). How do I chec

Re: [R] simulation from pareto distn

2010-11-09 Thread Dennis Murphy
Hi: library(sos) findFn('truncated Pareto') On my system, it scared up 17 matches. It looks like the VGAM package would be a reasonable place to start looking. HTH, Dennis On Tue, Nov 9, 2010 at 8:50 AM, cassie jones wrote: > Dear all, > > I am trying to simulate from truncated Pareto distribu

Re: [R] Centring titles for pairs of plots --- a solution.

2010-11-09 Thread Rolf Turner
That's cute. I had *thought* about using layout(), but of course didn't see the trick of specifying *9* plots and doing each of the text()s in a new plot. Very suave! :-) Thanks. cheers, Rolf On 10/11/2010, at 3:32 PM, Paul Murrell wrote: > Hi > > Here's one approac

Re: [R] Centring titles for pairs of plots --- a solution.

2010-11-09 Thread Paul Murrell
Hi Here's one approach ... # The layout's the important bit layout(rbind(c(7, 7), c(1, 2), c(8, 8), c(3, 4), c(9, 9), c(5, 6)), heights=c(1, 5, 1, 5, 1, 5)) # Dummy plots par(mar=c(5.1, 3.1, 0, 2)) plot(1:10, xlab="", ylab=

Re: [R] Add text to a stacked barplot

2010-11-09 Thread Dennis Murphy
Hi: Did you mean panel.text(x,y/2,label = round(y,3),cex=1) ?? HTH, Dennis On Tue, Nov 9, 2010 at 1:11 AM, Ashraf Yassen wrote: > Dear All, > > Now with data. Any suggestion how to center the text in the filling would > be > appreciated. > > Kind regards, > Ashraf > > library(lattice) > a<-c(

Re: [R] "repeated"repeated measures in ANOVA or mixed model

2010-11-09 Thread Dennis Murphy
Hi: This sounds like a 'doubly repeated measures problem'. Are any treatments assigned to individuals or is this a purely observational study? Is the time horizon of the between-visit factor (much?) longer than that of the within-visit factor? You could try to assess the strength of correlation o

Re: [R] Centring titles for pairs of plots --- a solution.

2010-11-09 Thread Rolf Turner
I have figured out a *slightly* less kludgy way of accomplishing my goal. Still a bit of a hack, but it works and seems to be consistent across graphics devices. Essentially it's this: After the *first* plot in each row, do: U <- par()$usr XD <- diff(U[1:2]) YD <- diff(

Re: [R] Question in using e1071 svm routine

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 11:18 AM, nathan.kupp wrote: > > R, by default, has some of the most cryptic error / debug messages ever > invented. I nominate the html 404 error for that. > The error message encountered by the two posters: > > Error in if (any(co)) { : missing value where TRUE/FALSE nee

Re: [R] Help make this simpler – count business da y

2010-11-09 Thread Gabor Grothendieck
On Tue, Nov 9, 2010 at 11:49 AM, cameron wrote: > > Help make this simpler – count business day > > > I am a beginner in R and this is my first post > > Want to count the day in month.  For example > >                 Day > 2010-09-01   1      Wed > 2010-09-02   2  Thurs > 2010-09-03   3  Friday >

[R] Retrieve all names of nested list and index list based on these names

2010-11-09 Thread wwa418
Hi all, I looked for a function that would retrieve all(!) names of an arbitrary deeply nested named list. Also, names should optionally be arranged in a way that reflects the list's hierarchy structure (i.e. 'a$a.1$a.1.1' etc.) Also, there should be a recursive index linked to a respective list

Re: [R] Exponent of asymmetric matrix

2010-11-09 Thread Peter Langfelder
> the exponent of asymmetric matrix makes me very curious. > can anyone please explain to me "what will happen if we apply exponent to > the asymmetric matrix"? The gates of Hell will open, the world will come to an end, and we will all perish in a firestorm :) Sorry, couldn't resist. Exponentiat

Re: [R] subsampling table

2010-11-09 Thread Henrique Dallazuanna
Try this: > x V1 V2 V3 1 1 15 34 2 1 4 66 3 1 24 65 4 2 23 47 5 2 9 36 6 3 58 9 7 3 38 64 8 3 12 64 9 3 4 15 10 4 1 88 11 4 23 90 x[tapply(seq(nrow(x)), x$V1, sample, 1),] On Tue, Nov 9, 2010 at 9:01 PM, Achim Eberhart < a.eberh...@pgrad.unimelb.edu.au> wrote: > G'

[R] Exponent of asymmetric matrix

2010-11-09 Thread zhiji19
Dear Experts, the exponent of asymmetric matrix makes me very curious. can anyone please explain to me "what will happen if we apply exponent to the asymmetric matrix"? Thank you very much -- View this message in context: http://r.789695.n4.nabble.com/Exponent-of-asymmetric-matrix-tp3035374p3

Re: [R] Question in using e1071 svm routine

2010-11-09 Thread David Winsemius
On Nov 9, 2010, at 2:18 PM, nathan.kupp wrote: R, by default, has some of the most cryptic error / debug messages ever invented. The error message encountered by the two posters: Error in if (any(co)) { : missing value where TRUE/FALSE needed In addition: Warning message: In FUN(newX[, i],

[R] subsampling table

2010-11-09 Thread Achim Eberhart
G'day R-helpers, I want to subsample rows of a large table based on the value in its first column. Of all rows sharing the same value in the first column I want to RANDOMLY extract only one. Thanks in advance, Achim example input 1 15 34 1 4 66 1 24 65 2

[R] Centring titles for pairs of plots.

2010-11-09 Thread Rolf Turner
I would like to centre titles for pairs of plots in a 3-x-2 array. Each row of the array corresponds to a calendar year and I would like to have the year value centred between the two plots in the row, and just above their upper edges. I have attached an example in "demo.pdf" showing roughly wha

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
>> >> zCenter = mean(Z) >> > >> >  How can that be right? Suppose your mountain is very flat, so that >> > your mountain is effectively a cube. The Z values are all the same, >> > and so their mean is the same. However the centre of mass is, by >> > symmetry, clearly at height/2. >> > >> >  Similar

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Peter Langfelder > Sent: Tuesday, November 09, 2010 3:49 PM > To: Barry Rowlingson > Cc: r-help@r-project.org; Ab Hu > Subject: Re: [R] Centre of gravity of a mountain > > On Tue

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Tue, Nov 9, 2010 at 3:40 PM, Barry Rowlingson wrote: > On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder > wrote: > >> If you also need the z coordinate, it simply the mean of the matrix Z. >> >> zCenter = mean(Z) > >  How can that be right? Suppose your mountain is very flat, so that > your mo

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Barry Rowlingson
On Mon, Nov 8, 2010 at 5:15 PM, Peter Langfelder wrote: > If you also need the z coordinate, it simply the mean of the matrix Z. > > zCenter = mean(Z) How can that be right? Suppose your mountain is very flat, so that your mountain is effectively a cube. The Z values are all the same, and so th

Re: [R] lattice mutiple y scales in each panel

2010-11-09 Thread Ben Bolker
Arunava Chakravartty gmail.com> writes: > I have a data set with two y variables (y1 and y2) and one dependent > variable(x) and a 1 strata variable Z. It so happens that y1 and y2 have > very different scales such that single y-axis scale does not allow the data > to be visualized fully. http:/

[R] lattice mutiple y scales in each panel

2010-11-09 Thread Arunava Chakravartty
Hi, I have a data set with two y variables (y1 and y2) and one dependent variable(x) and a 1 strata variable Z. It so happens that y1 and y2 have very different scales such that single y-axis scale doesnot allow the data to be visualized fully. I am trying the following lattce graphics to do my p

Re: [R] R-2.12.0 problem on Solaris 10

2010-11-09 Thread Dr. David Kirkby
On 11/ 9/10 10:30 PM, Dr. David Kirkby wrote: On 11/ 9/10 09:22 PM, Zhang,Jun wrote: It's been a few days I cannot compile to get R-2.12.0 working at sparc Solaris 10. Seems the R software installation is OK, but the recommended package called Matrix stopped me, since I can finish the installati

Re: [R] Centre of gravity of a mountain

2010-11-09 Thread Peter Langfelder
On Mon, Nov 8, 2010 at 11:31 PM, Ab Hu wrote: > > Thanks! Works great. > I have more questions on this, so I'll continue here: > > Now that I have the weighted mean, is it possible to reduce the size of > mountain based on this weighted mean such the original matrix remains 21x21 > while the mount

Re: [R] likelyhood maximization problem with polr

2010-11-09 Thread tjb
blackscorpio wrote: > > Thank you for your answer. I have already tried lrm and it's true that it > works better than polr in such a case. Nevertheless lrm does not work with > the addterm and dropterm functions (to my knowledge) and I need to use > them. Maybe do you know alternate functions th

Re: [R] R-2.12.0 problem on Solaris 10

2010-11-09 Thread Dr. David Kirkby
On 11/ 9/10 09:22 PM, Zhang,Jun wrote: It's been a few days I cannot compile to get R-2.12.0 working at sparc Solaris 10. Seems the R software installation is OK, but the recommended package called Matrix stopped me, since I can finish the installation with the configure option -with-recommend

Re: [R] Change a value in a matrix randomly

2010-11-09 Thread Steve Taylor
A=matrix(0,nr=3,nc=4) A[sample(prod(dim(A)),1)]=1 >>> From: "Barroso, Judit" To:"r-help@r-project.org" Date: 10/Nov/2010 11:12a Subject: [R] Change a value in a matrix randomly I have a matrix of ceros, for example: 0 0 0 0 0 0 0

Re: [R] Change a value in a matrix randomly

2010-11-09 Thread Peter Alspach
Tena koe Judit If it is really a matrix (and not a data.frame) and you wish to change a randomly selected zero to a one, then judit <- matrix(0, nrow=3, ncol=4) judit[sample(1:length(judit), 1)] <- 1 will do. This uses the fact that a matrix is a vector with a dim attribute. HTH Peter A

Re: [R] how do i plot this "hist"?

2010-11-09 Thread Samuel Dennis
To superimpose anything onto a barplot you just need to know the x axis locations of the bars, then everything behaves as expected. You can find this by writing the barplot to an object, ie: bp <- barplot(c(1:5),beside=TRUE) bp is now a matrix containing the actual x axis locations of the bars (i

[R] Change a value in a matrix randomly

2010-11-09 Thread Barroso, Judit
I have a matrix of ceros, for example: 0 0 0 0 0 0 0 0 0 0 0 0 And I would like that one of these values turn into 1, for example if one condition is got, but not in a concrete posi

[R] R-2.12.0 problem on Solaris 10

2010-11-09 Thread Zhang,Jun
It's been a few days I cannot compile to get R-2.12.0 working at sparc Solaris 10. Seems the R software installation is OK, but the recommended package called Matrix stopped me, since I can finish the installation with the configure option -with-recommended-packages=no. I then run Ø Install.pa

Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 12:41 PM, patrick nguyen wrote: > Hi > > > I'm having problems displaying multiple chart.StackedBar from > PerformanceAnalysis library on a  single plot. I've tried using I am assuming you mean the PerformanceAnalytics package, at least that is what I will talk about. > pa

[R] Bootstrap confidence intervals using bootcov from the rms package

2010-11-09 Thread Kim Fernandes
Hello, I am using R.12.2.0. I am trying to generate bootstrap confidence intervals using bootcov from the rms package. I am able to impute the missing data using aregImpute and to perform a linear regression on the imputed datasets using fit.mult.impute, but I am unable to use bootcov to generat

[R] R-2.12.0 problem on Solaris 10

2010-11-09 Thread Zhang,Jun
It's been a few days I cannot compile to get R-2.12.0 working at sparc Solaris 10. Seems the R software installation is OK, but the recommended package called Matrix stopped me, since I can finish the installation with the configure option -with-recommended-packages=no. I then run Ø Install.pa

Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot

2010-11-09 Thread salmajj
Hi, try par(new=T) patrick nguyen writes: Hi I'm having problems displaying multiple chart.StackedBar from PerformanceAnalysis library on a single plot. I've tried using par(mfrow=c(2,1)) but that doesn't work. If I do it with barplot(), it works fine and I see both plots on a single p

[R] haplotype and epistasis analysis using 3 or more SNPs?

2010-11-09 Thread Ferid Fathalli
Dear Mme/Mr. Hope you are doing well. I am doing some genetic analysis using The R software and I have difficulties to find how I can perform an Interaction/epistasis analysis using 3 or more SNPs (=markers) ? (In the instructive manual, there is only an interaction/epistasis analysis with 2 ma

Re: [R] Question in using e1071 svm routine

2010-11-09 Thread nathan.kupp
R, by default, has some of the most cryptic error / debug messages ever invented. The error message encountered by the two posters: Error in if (any(co)) { : missing value where TRUE/FALSE needed In addition: Warning message: In FUN(newX[, i], ...) : NAs introduced by coercion results from the i

[R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot

2010-11-09 Thread patrick nguyen
Hi I'm having problems displaying multiple chart.StackedBar from PerformanceAnalysis library on a single plot. I've tried using par(mfrow=c(2,1)) but that doesn't work. If I do it with barplot(), it works fine and I see both plots on a single plot. > plot(mfrow=c(2,1)) > barplot(blahblah) > b

Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot

2010-11-09 Thread Samuel Dennis
I am unfamiliar with the chart.StackedBar function, but since barplot works as expected I thought I'd check that you do know you can obtain stacked bar charts using barplot also? (beside = FALSE). On 10 November 2010 09:41, patrick nguyen wrote: > Hi > > > I'm having problems displaying multiple

Re: [R] how do i plot this "hist"?

2010-11-09 Thread casperyc
Thanks! now it's just a matter of 'superposing' the density onto the barplot I am looking at the example here, but it does not seem to applicable to barplot. casper -- View this message in context: http://r.789695.n4.nabble.com/how-do-i-plot-this-hist-tp3032796p3035110.html Sent from the R h

[R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot

2010-11-09 Thread patrick nguyen
Hi I'm having problems displaying multiple chart.StackedBar from PerformanceAnalysis library on a single plot. I've tried using par(mfrow=c(2,1)) but that doesn't work. If I do it with barplot(), it works fine and I see both plots on a single plot. > plot(mfrow=c(2,1)) > barplot(blahblah) >

Re: [R] how do i plot this "hist"?

2010-11-09 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 09.11.2010 20:25:09: > casperyc > Odeslal: r-help-boun...@r-project.org > > 09.11.2010 20:25 > > Re: [R] how do i plot this "hist"? > > > Hi all, > > Thank you both. The codes work perfectly. > > I now use > > barplot(t(x.m)[-1,], names.arg = x.

[R] Odp: Question regarding to replace

2010-11-09 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 09.11.2010 18:33:54: > Kate Hsu > Odeslal: r-help-boun...@r-project.org > > 09.11.2010 18:33 > > Komu > > r-help@r-project.org > > Kopie > > Předmět > > [R] Question regarding to replace > > Dear r-users, > > Basically, I have a data as follow

Re: [R] Add values of rlm coefficients to xyplot

2010-11-09 Thread PtitBleu
Thank you very much David for the advice ! I haven't checked the plyr and data.table packages but here is the script to replace the for loop :: dfrlm1<-as.data.frame(do.call("rbind", lapply(split(df1, df1$Name), function(X){coef(rlm(col2 ~ col3, data=X))}))) names(dfrlm1)<-c("Intercept", "Slope")

[R] Problem on installing statconnDCOM and RBloomberg

2010-11-09 Thread Stephen Liu
Installation of rcom, statconnDCOM and RBloomberg Hi folks, Win7 64bit R version 2.11.1 (2010-05-31) Perform following steps to install rcom, statconnDCOM and RBloomberg 1) rcom installation login Win7 as administrator and start R > install.packages("rcom") --- Please select a CRAN mirror fo

Re: [R] Creating a list to store output objects from a recursive loop

2010-11-09 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 09.11.2010 10:26:09: > "Santosh Srinivas" > Odeslal: r-help-boun...@r-project.org > > 09.11.2010 10:26 > > > Re: [R] Creating a list to store output objects from a recursive loop > > Figured this out this ways I think > > outPut <- list(list(resul

Re: [R] how do i plot this "hist"?

2010-11-09 Thread casperyc
Hi all, Thank you both. The codes work perfectly. I now use barplot(t(x.m)[-1,], names.arg = x.m[,1]) to make the 'histogram' plot. Now how do I add a dentity line to it? like 'superpose' on the graph? say if I got a Normal with mean 100 and variance 3... And I can work out the mean and vari

Re: [R] Merge Data

2010-11-09 Thread Tal Galili
Hello Nasrin, I think you might be wanting to use rbind instead of merge Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-

Re: [R] tukey.1

2010-11-09 Thread Raphael Fraser
aov.pen = aov(y ~ blend + treatment) summary(aov.pen) tukey.1 = function(aov.obj,data) { vnames=names(aov.obj$contrasts) if(length(vnames) != 2) stop("the model must be two-way") vara=data[,vnames[1]] varb=data[,vnames[2]] na=length(levels(vara)) nb=length(levels(varb)) resp=data[,as.charact

Re: [R] code ok in unix & R2.6 , fails in windows & R 2.12

2010-11-09 Thread Robert Kinley
apologies for omitting the data conc response curve 150 0.7533954 1 250 0.7755960 2 350 0.8001151 3 489 0.2858031 1 589 0.2883478 2 689 0.2954936 3 7 158 0.4296482 1 8 158 0.4406220 2 9 158 0.4567403 3 10 282 0.6484347

[R] Merge Data

2010-11-09 Thread Nasrin Pak
Hello; I have a problem merging data sets. I use this command: FileNames <- list.files(path="C:/updated_CFL_Rad_files/2007/11", full.names=TRUE) > dataMerge <- data.frame() > for(f in FileNames){ + ReadInMerge <- read.csv(file=f, header=T, na.strings="NULL") + dataMerge <- merge(dataMerge, Re

Re: [R] ggplot2: facet_grid with different vertical lines on each facet

2010-11-09 Thread Ista Zahn
Hi Scott, You can put the vline data in a separate data.frame: dat <- data.frame(x=rnorm(20), y=rnorm(20), z=rep(c("a", "b"), each=10)) vline.dat <- data.frame(z=levels(dat$z), vl=c(0,1)) library(ggplot2) ggplot(dat, aes(x=x, y=y)) + geom_point() + geom_vline(aes(xintercept=vl), data=vline.da

Re: [R] code ok in unix & R2.6 , fails in windows & R 2.12

2010-11-09 Thread Uwe Ligges
We cannot help since we do not have the data. Uwe On 09.11.2010 16:40, Robert Kinley wrote: hello ... Can anyone help me with this : In R.exe 2.6 , Unix , :- plot.data<-model[[i]]$data$conc newdata<-seq(min(plot.data),max(plot.data),by=1) model.pred<-predict(model[[i]],data.frame(newdata),

Re: [R] Lattice: xyplot group title format

2010-11-09 Thread Deepayan Sarkar
On Tue, Nov 9, 2010 at 2:06 AM, Marcus Drescher wrote: > Dear all, > > if I plot a lattice xyplot like: > > library(lattice); require(stats); > Depth <- equal.count(quakes$depth, number=8, overlap=.1) > > xyplot(lat ~ long | Depth, data = quakes) > > > How can I manipulate the group title format (

Re: [R] agrep pmatch recursive???

2010-11-09 Thread Henrique Dallazuanna
Try this: sapply(exclude, grep, x = dataset, value = TRUE) On Tue, Nov 9, 2010 at 2:36 PM, Broeckling,Corey < corey.broeckl...@colostate.edu> wrote: > Hello R Helpers, > > Business - 64 bit windows 7, R 2.11.1 > > > > I am trying to match the character contents of one list, called 'exclude', >

[R] agrep pmatch recursive???

2010-11-09 Thread Broeckling,Corey
Hello R Helpers, Business - 64 bit windows 7, R 2.11.1 I am trying to match the character contents of one list, called 'exclude', to those of a second list, called 'dataset' dataset is a list of file names with folder locations, and looks like this when called: > dataset [1] "A/10-10-29a-

Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Henrique Dallazuanna
Maybe: gsub("\\.(\\d{1}\\s)", ".0\\1", x) On Tue, Nov 9, 2010 at 3:43 PM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: > Thanks a lot, Henrique, > but I realised, my strings look a bit more complicated, like this: > x<-c("starts 2000.1 some words","starts 2001.2 different > wo

Re: [R] Question regarding to replace

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 9:43 AM, Joshua Wiley wrote: > On Tue, Nov 9, 2010 at 9:39 AM, Joshua Wiley wrote: >> Hi Kate, >> >> is.na() does not work on entire data frames. > > whoops, I did not mean that.  is.na() has a data frame method, but > there are assignment issues (as you saw) when you use i

[R] Help make this simpler – count business day

2010-11-09 Thread cameron
Help make this simpler – count business day I am a beginner in R and this is my first post Want to count the day in month. For example Day 2010-09-01 1 Wed 2010-09-02 2 Thurs 2010-09-03 3 Friday 2010-09-07 4 Tuesday 2010-09-08 5 Wed 2010-09-09 6 Th

[R] ggplot2: facet_grid with different vertical lines on each facet

2010-11-09 Thread Scott Chamberlain
Hello, I am plotting many histograms together using facet_grid in ggplot2. However, I want to then add a vertical line to each histogram, or facet, each of which vertical lines are at different x-values. The following example adds all vertical lines to each facet: ggplot(data,aes(values)) + geom_

Re: [R] How to extract Friday data from daily data.

2010-11-09 Thread thornbird
Thanks for your suggestion. I received a few error messages. Can anyone help me figure out why I get the following error messages and how to solve them by revising my code? The data is shown in the post above. Thanks. > library(zoo) > > colClasses <- c("character", "character", "numeric", "chara

Re: [R] replaing 1-digit months with 2-digit months in a date

2010-11-09 Thread Dimitri Liakhovitski
Thanks a lot, Henrique, but I realised, my strings look a bit more complicated, like this: x<-c("starts 2000.1 some words","starts 2001.2 different words","starts 2008.10 other stuff","starts 2010.12 sth else") I tried to modify the gsub statement but can't get it working. Thank you for your help!

Re: [R] Question regarding to replace

2010-11-09 Thread Joshua Wiley
On Tue, Nov 9, 2010 at 9:39 AM, Joshua Wiley wrote: > Hi Kate, > > is.na() does not work on entire data frames. whoops, I did not mean that. is.na() has a data frame method, but there are assignment issues (as you saw) when you use it that way. Josh [snip]

Re: [R] help to add a new column filled with value 1

2010-11-09 Thread Henrique Dallazuanna
Try this: as.data.frame(append(iris, 1, after = 2)) On Tue, Nov 9, 2010 at 12:25 PM, Mohan L wrote: > Dear All, > > I have a data frame with 5 column and 201 row data. I want to add one > more column between column 1 and 2 with value of 1. So the new column > has to be the second column fille

Re: [R] Question regarding to replace

2010-11-09 Thread Phil Spector
Kate - As the error message indicates, num.strata is a factor. This can occur when you're reading in data and R encounters a non-numeric value which was not specified in the na.strings= argument to read.table. To do what you want, you'll need to convert it to a character variable first:

Re: [R] Calculate Mean from List

2010-11-09 Thread Greg Snow
You could use the "Reduce" function to get the sum of the matrices, then if there are no missing vales just divide by the number of matrices. If there are missing values then you would probably need to use Reduce again to count the number of non-missing values. Since all the matrices are the s

[R] jags error message

2010-11-09 Thread Maas James Dr (MED)
Could anyone give me some clues as to the best way to debug this error message? I think it is from the passing of variables back to R from the jags function which does Bayesian fitting. The curious part for me is that the error messages seem random, yet the input data are always the same. An

Re: [R] Merging data frames one of which is NULL

2010-11-09 Thread Dimitri Liakhovitski
Thanks a lot, Phil. I decided to do it via the list - as you suggested, but had to do some gymnastics, which Reduce will greatly help me to avoid now! Dimitri On Tue, Nov 9, 2010 at 12:36 PM, Phil Spector wrote: > Dimitri - >   Usually the easiest way to solve problems like this > is to put all t

Re: [R] Question regarding to replace

2010-11-09 Thread Joshua Wiley
Hi Kate, is.na() does not work on entire data frames. You just need to specify the column, for example: data[is.na(data[, 8]), 8] <- 0 if the NAs were in column 8. Best regards, Josh On Tue, Nov 9, 2010 at 9:33 AM, Kate Hsu wrote: > Dear r-users, > > Basically, I have a data as follows, >

Re: [R] help to add a new column filled with value 1

2010-11-09 Thread Greg Snow
Here are 2 possibilities: cbind( iris[,1, drop=FALSE], 1, iris[,2:5] ) cbind( iris, 1) [ ,c(1,6,2:5) ] -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r

Re: [R] Merging data frames one of which is NULL

2010-11-09 Thread Phil Spector
Dimitri - Usually the easiest way to solve problems like this is to put all the dataframes in a list, and then use the Reduce() function to merge them all together at the end. You don't give many details about how the data frames are constructed, so it's hard to be specific about the best way

[R] Question regarding to replace

2010-11-09 Thread Kate Hsu
Dear r-users, Basically, I have a data as follows, > data S s1 s2 s3 s4 s5 prob obs num.strata 1 N N N N N N 0.108 32 2 Y N N N N Y 0.0005292 16 3 NNNYN N N N Y N 0.0005292 24 4 NNNYY N N N Y Y 0.0259308 8 1

Re: [R] How to eliminate this for loop ?

2010-11-09 Thread Greg Snow
OK, double oops. I first tested my code with length 100, then upped the number but forgot to up the preallocation part, I should have used a variable there instead so that only one place needed to be changed. My version did have problems when I tried to do a vector of length 10,000, some value

  1   2   >