Re: [R] Gamma Distribution - is there any problem with "pgamma"?

2015-03-11 Thread Martyn Byng
Hi, Try pgamma(amounts,shape_gamma,scale=scale_gamma) as I am guessing you mean scale_gamma to be the scale of the distribution, but are using it as the rate ( = 1 / scale) instead Martyn -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Amelia Marsh S

Re: [R] difference between max in summary table and max function

2015-02-13 Thread Martyn Byng
Its a formatting thing, try summary(testrow,digits=20) -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Franckx Laurent Sent: 13 February 2015 11:00 To: r-help@r-project.org Subject: [R] difference between max in summary table and max function Dear all

Re: [R] Median of streaming data

2014-09-24 Thread Martyn Byng
Something else that might be of interest ... Zhang Q and Wang W (2007) A fast algorithm for approximate quantiles in high speed data streams Proceedings of the 19th International Conference on Scientific and Statistical Database Management IEEE Computer Society 29 -Original Message- Fro

Re: [R] How Can SVD Reconstruct a Matrix

2014-08-14 Thread Martyn Byng
Hi, The G matrix can be constructed from the SVD because GGt is square and symmetric, so the matrices of the left and right singular values (i.e. U and V) are the same. Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Pete

Re: [R] Generate quasi-random positive numbers

2014-08-05 Thread Martyn Byng
Hi, As a slight aside, did you mean pseudo-random or quasi-random? http://en.wikipedia.org/wiki/Pseudorandom_number_generator http://en.wikipedia.org/wiki/Low-discrepancy_sequence runif gives a sequence of pseudo-random numbers, for quasi-random numbers you will need something else, for example

Re: [R] PCA with a lot of zeros

2014-07-08 Thread Martyn Byng
Hi, Not sure if these are relevant as they have been on my "must look at" list for some time and I've not managed to get around to it ... http://www.cmap.polytechnique.fr/~aspremon/PDF/SPCAhandbookSV.pdf http://www2.imm.dtu.dk/projects/manifold/Papers/sparsepc.pdf Martyn -Original Message-

Re: [R] C: drive memory full

2014-06-17 Thread Martyn Byng
Hi, Try http://social.technet.microsoft.com/wiki/contents/articles/19295.windows-8-how-to-search-for-large-files.aspx Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hiyoshi, Ayako Sent: 17 June 2014 11:40 To: Prof Brian R

Re: [R] create new rows with 0, if nessecary

2014-05-16 Thread Martyn Byng
Hi, Something like: aa <-structure(list(Cat = c(101, 103), Hours = c(15, 10)), .Names = c("Cat","Hours"), row.names = c(NA, -2L), class = "data.frame") bb <-structure(list(Cat = c(103, 106), Hours = c(16, 11)), .Names = c("Cat","Hours"), row.names = c(NA, -2L), class = "data.frame") dd <- data.

Re: [R] Problem with R "density" function

2014-05-14 Thread Martyn Byng
Hi, Have you tried using a different bandwidth rather than the number of points, the default bandwidth gives ... x <- rnorm(1) dd <- density(x,kernel="epanechnikov",n=101) sum(dd$y)*(dd$x[2]-dd$x[1]) [1] 1.001014 Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:

Re: [R] problem (un)detecting changepoints

2014-01-27 Thread Martyn Byng
Hi, I don't think you are doing anything wrong, the routine is doing what it is documented to do, from ?cpt.mean cpt: Vector containing the changepoint locations for the penalty supplied. This always ends with n. i.e. as your series is of length 50, the last value returned in cpts will alwa

Re: [R] triangular matrix inverse

2013-12-03 Thread Martyn Byng
Hi, backsolve() is probably what you are looking for. Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Meyer Sent: 03 December 2013 12:25 To: r-help@r-project.org Subject: [R] triangular matrix inverse Greetings,  

Re: [R] Weighted least squares

2012-11-21 Thread Martyn Byng
Hi, That message usually means that an unknown argument has been supplied to the function. In this case you have spelt weights incorrectly. Best wishes Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rbowman16 Sent: 21 Nov

Re: [R] Measure of separation for survival data

2011-11-23 Thread Martyn Byng
Hi, I've not come across "Royston's measure of prognostic separation" before, so I might be completely off the mark, but it is likely that by "invnormal" it is meant the inverse of a standard normal distribution, i.e. one with a mean of 0 and standard deviation of 1. Which is what qnorm gives by d

Re: [R] unable to get "R CMD" to work as expected on a 64 bit windows machine

2011-11-14 Thread Martyn Byng
ed to paste the text into the environment variable - time to go home I think :) Cheers Martyn -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: 14 November 2011 18:17 To: Martyn Byng Cc: r-help@r-project.org Subject: Re: [R] unable to get "R CMD" t

Re: [R] unable to get "R CMD" to work as expected on a 64 bit windows machine

2011-11-14 Thread Martyn Byng
x27;m guessing why "R CMD --help" works), do I need the others in the path as well, and if so, in what order? Cheers Martyn -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: 14 November 2011 16:57 To: Martyn Byng Cc: r-help@r-project.org Subject: Re: [R

[R] unable to get "R CMD" to work as expected on a 64 bit windows machine

2011-11-14 Thread Martyn Byng
Hi, I've just downloaded and installed R 2.14.0 using the windows binary on a 64bit windows machine running windows 7. Rterm / RGui work as expected, as does R CMD --help and R CMD BATCH --help however R CMD check --help returns no information and I seem to be unable to check a package. Va

Re: [R] adding a dummy variable...

2011-10-04 Thread Martyn Byng
Hi, I am sure there are better / more efficient ways of doing this, but the following seems to work ... ids <- sapply(split(df,df$ID),function(x) {length(x$rel.head)==2 & any(x$rel.head==1) & any(x$rel.head==3)}) ids <- as.numeric(names(ids)[ids]) added.dummy <- as.numeric(df$ID%in%ids) cbind(df

[R] Rtools - "The setup files are corrupted" message when trying to install

2011-06-09 Thread Martyn Byng
Hi, Apologies if this is the wrong list to be sending this question to. I am trying to install a copy of the R tools required to create / compile packages on windows. After downloading Rtools from http://www.murdoch-sutherland.com/Rtools/ windows keeps complaining that "The setup files are corrup

Re: [R] Loop stopping after 1 iteration

2011-05-18 Thread Martyn Byng
Hi, The answer to (2) is that num_obs is a scalar, so length(num_obs) is 1. You probably wanted to do for (i in 1:num_obs) instead. Best wishes Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of armstrwa Sent: 18 May 2011 1

[R] Summarising by group

2011-05-09 Thread Martyn Byng
I wonder if someone with more experience than me on using R to summarise by group wants to post a reply to this http://www.analyticbridge.com/group/sasandstatisticalprogramming/forum/t opics/why-still-use-sas-with-a-lot To save everyone having to follow the link, the text is copied below "SAS h

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-31 Thread Martyn Byng
y.day,sum) } by.grp <- split(myframe,myframe$group) lapply(by.grp,sum.by.week) Martyn -Original Message- From: Dimitri Liakhovitski [mailto:dimitri.liakhovit...@gmail.com] Sent: 30 March 2011 18:03 To: Martyn Byng Cc: r-help Subject: Re: [R] summing values by week - based on daily

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-30 Thread Martyn Byng
Hi, How about something like: sum.by.day <- function(ff) { by.day <- split(ff$value,weekdays(ff$dates)) lapply(by.day,sum) } by.grp <- split(myframe,myframe$group) lapply(by.grp,sum.by.day) Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-pro

Re: [R] Infinite loop

2011-03-22 Thread Martyn Byng
Hi, This might do what you want: iter <- 0 repeat { iter <- iter + 1 ss <- numeric(40) ss[1] <- sample(1:40,1) for (i in 1:39) { ## calculate all possible step sizes that will give a new value in the 1:40 range pmove <- sample((1 - ss[i]):(40-ss[i])) ## drop all step sizes tha

Re: [R] adding linear regression data to plot

2011-03-16 Thread Martyn Byng
Hi, ?summary.lm describes what summary statistics get calculated and returned, so ll <- lm(y ~ x) ss <- summary(ll) ss$fstatistic for example would give the F statistic Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of d

Re: [R] How to read "Cumulative proportion" in using princomp?

2011-03-16 Thread Martyn Byng
Hi, The values are calculated on the fly in the summary function stats:::print.summary.princomp using vars <- result$sdev^2 vars <- vars/sum(vars) cumsum(vars) Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ian_zhangty

Re: [R] Scope of variable?

2011-03-16 Thread Martyn Byng
Hi, Not sure what you are trying to do with the "cat" command, but cat returns an invisible NULL (as described in the doc), so a = cat(a,v) just sets a to NULL Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ravi Kulkarni

Re: [R] rms: getting adjusted R^2 from ols object

2011-03-09 Thread Martyn Byng
Hi, If you look in the print.ols function you can see that the adjusted R^2 is not stored in the ols object but calculated on the fly, the relevant code snippet from that function looks to be: x <- ols1 stats <- x$stats resid <- x$residuals n <- length(resid) ndf <- stats["d.

Re: [R] Probabilities greather than 1 in HIST

2011-03-03 Thread Martyn Byng
Hi, Does xx = rnorm(100) hist(xx,freq=FALSE) curve(dnorm,add=TRUE) give you what you want? Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: 03 March 2011 17:00 To: jpmaroco Cc: r-help@r-project.org Sub

Re: [R] Help

2011-03-01 Thread Martyn Byng
Hi, It is a bit unclear what it is you are trying to do, as mentioned in replies by a variety of people previously, if you are just trying to get your data into R and label rows / columns, then tt = matrix(c(24,134,158,9,52,61,23,72,95,12,15,27),ncol=3,byrow=T) rownames(tt) = c("None", "Healthy"

Re: [R] better way to iterate matrix multiplication?

2011-02-01 Thread Martyn Byng
Hi, If you only want the final matrix, i.e. in this case the pm at 10 months, then you might be better off looking at something like the square-and-multiply algorithm (http://en.wikipedia.org/wiki/Exponentiation_by_squaring) rather than a brute force multiplication. Martyn -Original Message-

Re: [R] a problem with is.na

2011-01-26 Thread Martyn Byng
Hi, This isn't an issue with is.na, you get the same if you use aa = c(1,1,0,1,1,1,1,1,1) bb = abs(aa - 1) xtabs(aa~x1+x2) xtabs(bb~x1+x2) it is because you do not have any data in (1,1), i.e. there is no case where x1 = 1 and x2 = 1 so xtabs is putting a zero in that cell Hope this helps Mar

Re: [R] Problem about for loop

2011-01-17 Thread Martyn Byng
Hi, Looks like the function "theta" takes a variable "data", but that variable is not being used in the body of the function (you are using the global dataX and dataY, which will be the same each time the function is called). Martyn -Original Message- From: r-help-boun...@r-project.org [

Re: [R] how to control ticks

2010-12-21 Thread Martyn Byng
Hi, The following seems to work: plot(1:12,1:12,xaxt='n',xlab=NA) axis(1,at=1:12,labels=c("J","F","M","A","M","J","J","A","S","O","N","D") ) So I'd guess that your X axis data, file$time, doesn't take the values 1 to 12. Martyn -Original Message- From: r-help-boun...@r-project.org [mai

Re: [R] Installing the latest version of BRugs

2010-11-09 Thread Martyn Byng
package to work correctly (assuming that all pre-requisites are present / the same version). Cheers -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: 09 November 2010 12:25 To: Martyn Byng Cc: r-help@r-project.org Subject: Re: [R] Installing the latest

[R] Installing the latest version of BRugs

2010-11-09 Thread Martyn Byng
Hi, I am trying to install the latest version of the BRugs package on a 32 bit windows machine which, due to the set up, won't allow me to install it via the usual R GUI. Can anyone point me to a link from which I can download the relevant files that allow me to install it manually (most pages fl

Re: [R] Truncating leading zeros in strings

2010-10-07 Thread Martyn Byng
Hi, Think I might be misunderstanding what you want, because ... > t = "123" > as.integer(t) [1] 123 anyway > t = "123" > substr(t,regexpr("[^0]",t),nchar(t)) [1] "123" seems to trim the leading 0's Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-

Re: [R] quantile regression

2010-10-07 Thread Martyn Byng
Hi, Your code is of the form for (i in 1:nsim) { ## Do something that generates variable qf05 M <- coeff(qf05) } This means that you are overwriting the variable M at each iteration and so when the loop has finished you only have the coefficients from the last simulation. There are lots of

Re: [R] Splitting data in to multiple boxplots

2010-09-29 Thread Martyn Byng
Hi, Something like bb = data.frame(label=c("a","b","a","b","c","a","b","c"),val=c(4,2,1,6,4,3,2, 1)) l = split(bb,bb$label) par(mfrow=c(2,2)) lapply(l,function(a) {boxplot(a$val)}) might be what you are looking for Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-

Re: [R] image plot but data not on grid.

2010-08-06 Thread Martyn Byng
Hi, Not really sure what you are after, but the following plots a series of points of varying colour plot(x,y,type='n') apply(cbind(x,y,z),1,function(a) {points(a[1],a[2],col=a[3],pch=".")}) but its going to be really slow for a large number of points Martyn -Original Message- From: r-

Re: [R] How to get vector of poitions in a vector ?

2010-07-23 Thread Martyn Byng
(1:length(a))[a != 0] -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of vikrant Sent: 23 July 2010 12:13 To: r-help@r-project.org Subject: [R] How to get vector of poitions in a vector ? I have a vector a = c(1,0,0,0,1,0,4,0,0,0) Now

Re: [R] Help with replacing a substring in a string

2010-07-19 Thread Martyn Byng
Hi, Have you tried gsub? > a = "abc.degg.hijk" > gsub("."," ",a,fixed=TRUE) [1] "abc degg hijk" Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Tolga I Uzuner Sent: 19 July 2010 12:38 To: r-help@r-project.org Subject: Re: [

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Martyn Byng
Hi, Is this what you are looking for? a = c(528,528,528,528,708,708,529,1208,423,1506,321) paste(substr(a,1,nchar(a)-2),substr(a,nchar(a)-1,nchar(a)),sep="/") [1] "5/28" "5/28" "5/28" "5/28" "7/08" "7/08" "5/29" "12/08" "4/23" "15/06" "3/21" Martyn -Original Message- From: r-h

Re: [R] reverse string

2010-07-14 Thread Martyn Byng
Hi, I've no idea if there is a function for doing it, but if not, the following seems to work a = "this is a string" paste(rev(substring(a,1:nchar(a),1:nchar(a))),collapse="") Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of

Re: [R] Equivalent of SAS's FIRST. And LAST. Variable in R?

2010-07-13 Thread Martyn Byng
Hi, I expect there are better ways of doing this then the following, but you can probably get the same sort of thing using the split command bb = matrix(c(1,1,1,2,2,2,3,3,3,3,10,11,12,43,23,14,52,52,12,23),ncol=2,byrow =FALSE) aa = split(bb,bb[,1]) sapply(aa,function(temp) {cc = matrix(temp,ncol=

Re: [R] problem with if else statement

2010-06-08 Thread Martyn Byng
Hi, You are using if/then/else which is a logical control statement and so doesn't return a value, see ?if for details. You are probably looking for the ifelse function. Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Pe

Re: [R] Build Design Matrix with avoiding loops

2010-06-04 Thread Martyn Byng
Hi, Something like x = as.factor(rep(1:k,rep(n/k,k)) X = model.matrix(~x-1) Might be what you are looking for Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gildas Mazo Sent: 04 June 2010 16:19 To: r-help@r-project.org Su

Re: [R] Help barplots

2010-06-01 Thread Martyn Byng
Hi, If you want to draw lines on your barchart then aa = barplot(chromosome, col="purple", xlab="Oryza sativa Chromosomes", border = NA, space = 5, ylim = c(0,45)) returns the midpoints of each bar in the vector aa and then you can use the lines() function to do the drawing. Martyn -Origin