Re: [R] Adding a row at top of dataframe

2010-05-17 Thread Peter Ehlers
On 2010-05-17 11:14, Nikhil Kaza wrote: Does this work? data(cars) cars2 - cars cars2[2:nrow(cars)+1,] - cars2[1:nrow(cars),] cars2[1,] - NA Not for me. Did you try it? -Peter Ehlers Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l

Re: [R] suggestions/improvements for recoding strategy

2010-05-17 Thread Peter Ehlers
or factor columns. cl - sapply(numdat, class) idx - which(cl %in% c('character','factor')) g - function(x){ sapply(strsplit(as.character(x),-), function(.x) mean(as.numeric(.x), na.rm=TRUE)) } newData - numdat for(i in idx) newData[,i] - g(newData[,i]) newData -Peter Ehlers On Mon, May 17

Re: [R] suggestions/improvements for recoding strategy

2010-05-17 Thread Peter Ehlers
Sorry, my attempt wasn't quite good enough. I didn't consider the possibility of a 'negative' value in a character/factor column. To fix that, see inline below. On 2010-05-17 14:32, Peter Ehlers wrote: On 2010-05-17 12:54, Henrique Dallazuanna wrote: Try this: newData- sapply(numdat

Re: [R] How to rank matrix data by deciles?

2010-05-16 Thread Peter Ehlers
- .Machine$double.eps #or use something like 1e-10 brks - quantile(vec, (0:10)/10) + eps*(0:10) cut(vec, brks, include.lowest=TRUE, labels=FALSE) #[1] 10 6 7 5 9 1 3 7 4 2 9 4 1 10 5 8 1 -Peter Ehlers On Thu, 13 May 2010, vincent.deluard wrote: Dear Phil, You helped

Re: [R] sample

2010-05-16 Thread Peter Ehlers
would work with matrices, since all of your data are string variables. -Peter Ehlers write.table(output_offspring,offspring_7.txt,row.names=T,col.names=T,quote=F) females.txt: SampleID A1 A2 A3 A4 GM920222 GATTGCC GATTGCC GATAGAC GATAGAC GM930040 GTCATCA GAGTGCA ACTATAA GATTGCC GM930040 GTCATCA

Re: [R] Box-Cox Transformation: Drastic differences when varying added constants

2010-05-16 Thread Peter Ehlers
() computes the Pearson correlation coefficient by default. Try method='spearman'. Better yet, plot the transformed variables vs the original variable for further enlightenment. -Peter Ehlers With higher added values (and a right skewed variable) the lambda estimate was even negative and the correlation

Re: [R] Attempt to customise the plotpc() function

2010-05-16 Thread Peter Ehlers
the printouts of is.na(), pushViewport, popViewport, ...? Egad! Anyway, as you've discovered, when you want to modify code, look at the sources. -Peter Ehlers On 2010-05-16 12:05, Nikos Alexandris wrote: Nikos Alexandris: Among the (R-)tools, I've seen on the net, for (bivariate) Principal Component

Re: [R] Discretize factors?

2010-05-16 Thread Peter Ehlers
1 0 3 3 5 0 1 0 4 4 3 0 0 1 5 5 4 0 0 1 6 6 5 0 0 1 Any ideas? Can't you just use names(...) - c() on your final dataframe? -Peter

Re: [R] Discretize factors?

2010-05-16 Thread Peter Ehlers
And if you do have many variables in one dataframe, you might wish to construct the formula first using paste(): nm - c(0, names(d)[-c(1,2)]) fo - as.formula(paste(~, paste(nm, collapse= +))) d - cbind(d, model.matrix(fo, data=d) -Peter Ehlers On 2010-05-16 15:30, Thomas Stewart wrote

Re: [R] debugging substitute function in R 2.11

2010-05-15 Thread Peter Ehlers
substitute() does not have an argument 'list'; it does have 'env'. Replace this line: list = list (member = as.name (member), with env = list (member = as.name (member), -Peter Ehlers On 2010-05-14 3:09, Gil Tomás wrote: Dear list, A while ago I found in the web

Re: [R] Whiskers on the default boxplot {graphics}

2010-05-14 Thread Peter Ehlers
11:47, David Winsemius wrote: I agree. I was convinced by Ehlers' example that type =2 was a better match to fivenum's result -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] multhist,labels and percentages

2010-05-14 Thread Peter Ehlers
Federico, Yes, do use axis(2, at = whatever, labels = whateverelse) for one axis. Then use axis(4, ...) for the other axis. You may need to use par('usr') to determine the y-extent of the plot. -Peter Ehlers On 2010-05-14 11:50, Federico Calboli wrote: On 14 May 2010, at 18:25, Thomas

Re: [R] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Peter Ehlers
for (i in 4:9) {print(quantile(y, c(1,3)/4, type=i) ) } 25% 75% 15.82506 73.93080 25% 75% 15.87405 74.03625 25% 75% 15.84955 74.08898 25% 75% 15.89854 73.98352 25% 75% 15.86588 74.05383 25% 75% 15.86792 74.04943 -- Peter Ehlers University of Calgary

Re: [R] Whiskers on the default boxplot {graphics}

2010-05-12 Thread Peter Ehlers
# So 118 is the largest data value less than or equal to 119.5. 60.5 + 1.5 * IQR(y) #[1] 116.375 # Using quartiles and the IQR would take the upper whisker to 94. -- Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] difference along a vector

2010-05-12 Thread Peter Ehlers
function for this. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self

Re: [R] Splines under tension

2010-05-12 Thread Peter Ehlers
Aretha won't mind if I add my voice to the chorus. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

Re: [R] Whiskers on the default boxplot {graphics}

2010-05-12 Thread Peter Ehlers
' on that page and the description of the equivalent 'coef' on the help page for boxplot.stats. boxplot.stats has it right. This should be made consistent. [previous posts snipped] -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https

Re: [R] [Fwd: Re: Plotting log-axis with the exponential base to

2010-05-11 Thread Peter Ehlers
Ted, Regarding the addition of a 'line' to a plot with log-y axis, there is a better way: curve() with 'add=TRUE' will respect the current plot's log setting: plot((1:10), log=y, yaxt=n) axis(side=2, at=c(1,2,5,10)) f - function(x, a=0, b=1) {a + b*x} curve(f, add = TRUE)

Re: [R] overlap dot plots with box plots

2010-05-08 Thread Peter Ehlers
.) -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] 3D Surface plot

2010-05-01 Thread Peter Ehlers
(assuming that have installed it): library(rgl) persp3d(x, y, z1, col = 'skyblue') -Peter Ehlers http://n4.nabble.com/forum/FileDownload.jtp?type=nid=2077409name=Excel_Figure.png -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing

Re: [R] Solving equation

2010-05-01 Thread Peter Ehlers
On 2010-05-01 7:13, Berend Hasselman wrote: David Winsemius wrote: On May 1, 2010, at 3:28 AM, Berend Hasselman wrote: Shant Ch wrote: I want to solve: x*(3^x)*log(4)-x*log(4/3)-(3^x)+1=0 for x. I used the following code, uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower

Re: [R] Likelihood ratio based confidence intervals for logistic regression

2010-04-30 Thread Peter Ehlers
with Wald CIs. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained

Re: [R] Flattening and unflattening symmetric matrices

2010-04-30 Thread Peter Ehlers
, 4) A[upper.tri(A)] - vu A - A + t(A) diag(A) - vd A -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

Re: [R] Trouble using Ecdf () from the Hmisc library

2010-04-30 Thread Peter Ehlers
such degenerate (and/or near degenerate) cells and be able to plot the rest. I don't know of any robust ecdf function, but I would consider a data manipulation step before the call to Ecdf to submit only valid data. (But you've probably already tried that and found it too cumbersome.) -Peter Ehlers

Re: [R] image function with date-time on X axis

2010-04-29 Thread Peter Ehlers
= n) axis(1, at = as.numeric(tax), lab = weekdays(tax, TRUE)) -Peter Ehlers Contrast the x axis result of image with that of plot plot(tax,rnorm(length(tax))) where the date-time shows stamps work fine. How can I get image to behave (or is there a better function for the job?) Sincerely

Re: [R] get means of elements of 5 matrices in a list

2010-04-27 Thread Peter Ehlers
=apply(x,2,mean); matrix(x2,byrow=F,nrow=5); Here is one more way: create a 3-dim array, then apply mean(): za - array(unlist(ll), dim = c(5,6,5)) mn - apply(za, c(1,2), mean) -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list

Re: [R] Confusing concept of vector and matrix in R

2010-04-26 Thread Peter Ehlers
to be quite receptive to intelligent and well thought-out suggestions. But It is very annoying! is not the right approach. -Peter Ehlers I have sympathies with the author. When I first began using R (migrating from Matlab), I also found the vector concept strange, especially because I was doing a lot

Re: [R] Mathematical symbol

2010-04-26 Thread Peter Ehlers
Type ?|| and read the help page. If it helps, the statement is equivalent to if( (a 10) || (j 100) ) -Peter Ehlers On 2010-04-26 23:00, assaedi76 assaedi76 wrote: R users Thanks in advance Could someone tell me what this condition means: if ( a 10 | |j 100) Thanks

Re: [R] categorical variable in scatterplot (car)

2010-04-25 Thread Peter Ehlers
-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Ehlers Sent: April-24-10 11:57 PM To: Anthony Lopez Cc: R-help@r-project.org Subject: Re: [R] categorical variable in scatterplot (car) On 2010-04-24 21:30, Anthony Lopez wrote: Hello R folks, I am encountering

Re: [R] Intersection for two curves

2010-04-24 Thread Peter Ehlers
and formulate a response to the second. One may well prefer not to have one's workspace cleared even though this would not lose more than the temporarily suspended work. So, is ther *ever* a good reason to *not* put rm(list=ls()) behind a comment char? I doubt it. Just my 2c. -Peter Ehlers On 2010-04-24 11

Re: [R] Intersection for two curves

2010-04-24 Thread Peter Ehlers
, and it's a hassle to close it down and restart it. Hadley -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

Re: [R] help please: predict error code

2010-04-24 Thread Peter Ehlers
to your predict call. Reproducible code would be best. -Peter Ehlers On 2010-04-24 12:45, Brittany Hall wrote: Hello, I am trying to calculate predicted values derived from one dataset into a hypothetical dataset. I tried this line of code: graphdata$fmgpredvalues- predict(Acs250.3.4

Re: [R] categorical variable in scatterplot (car)

2010-04-24 Thread Peter Ehlers
fix this without recoding my variable? Make z a factor (which it really should be anyway). -Peter Ehlers Thank you! Anthony [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] how to reorder of groups and specify ylim for each row in lattice barchart

2010-04-23 Thread Peter Ehlers
Works for me. Did you replace the '' in mylist() with appropriate c(,) code? For example: mylist - list(c(0,30), c(40,80), c(0,50), c(0,50), c(0,50), c(0,50)) -Peter Ehlers On 2010-04-23 9:22, zhenjiang xu wrote: Peter, thanks, but that doesn't work. Did I missed something

Re: [R] cancelling in fraction

2010-04-23 Thread Peter Ehlers
Greg has provided a solution. Just to answer the question of why set_complement() is not doing what you think it should: You need to change your *vectors* nom and denom to *sets* with as.set(). -Peter Ehlers On 2010-04-23 9:42, Greg Snow wrote: Here is a different approach that may work

Re: [R] how to reorder of groups and specify ylim for each row in lattice barchart

2010-04-23 Thread Peter Ehlers
suggested, then you have to use limits=mylist, not ylim=mylist. This was due to my not testing the code carefully. Sorry about that. -Peter Ehlers library(lattice) barchart(yield ~ variety | site,data=barley, groups = year, layout = c(1,6),auto.key = list(points = FALSE, rectangles = TRUE, space

Re: [R] Intersection for two curves

2010-04-23 Thread Peter Ehlers
) ) $minimum [1] 8.5 $objective (Intercept) 3.155444e-30 Another (crude) way is to use locator(). I usually maximize the plot window for this. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] Library (tm) Error: could not find function TermDocMatrix.

2010-04-23 Thread Peter Ehlers
Package tm does not have a function TermDocMatrix. Where did you get the idea that it does? There _is_ a function TermDocumentMatrix, however. -Peter Ehlers On 2010-04-23 10:21, Ignacio mas data wrote: Hi List I have the next code and the error. I have try with other codes and I have

Re: [R] Error in plotting non-linear regression

2010-04-22 Thread Peter Ehlers
120 0.13317708 new - data.frame(s1,cm) plot(s1,cm) f - function(x,a,b){a*exp(-b*x)} fm - nls(cm~f(x,a,b),data=new,start=c(a=1,b=1)) co - coef(fm) Presumably you want f(s1,a,b) in your nls call. -Peter Ehlers curve(f(x,a=co[1],b=co[2]),add=TRUE,col=blue

Re: [R] how to reorder of groups and specify ylim for each row in lattice barchart

2010-04-22 Thread Peter Ehlers
Ehlers Thank you! -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self

Re: [R] Unwanted boxes in legend

2010-04-21 Thread Peter Ehlers
If the 'border' argument is not recognized, then this won't work. Steve: What version of R are you using? I have no problems with the suggestions I gave you in R 2.10.1 or R 2.11.0 alpha. -Peter Ehlers On Mon, Apr 19, 2010 at 4:21 AM, Steve Murraywrote: Dear all, Thanks for the response

Re: [R] Unwanted boxes in legend

2010-04-21 Thread Peter Ehlers
On 2010-04-21 4:35, Peter Ehlers wrote: The 'border' argument was added in 2.1.10. Egad! Did I really type that? I meant 'in R 2.10.0'. -Peter Ehlers On 2010-04-21 1:53, Steve Murray wrote: Thanks Peter, I'm using version 2.8.0 (2008-10-20). This version should be recent enough

Re: [R] How to obtain the coefficients from a summary of aov ?

2010-04-21 Thread Peter Ehlers
] NA s.npk.aov[[1]]['Pr(F)'][[1]][1] [1] 0.01593879 or, if you prefer: s.npk.aov[[1]]['block', 'Pr(F)'] #[1] 0.01593879 -Peter Ehlers On the other, the procedure to extract coefficients from a summary of lm or aov should be the same. I think one generally extracts the coefficients from

Re: [R] overlaying a levelplot on a map plot

2010-04-21 Thread Peter Ehlers
Try using contour() instead of levelplot. See the examples in help('contour') for how to add contour lines to an existing plot. -Peter Ehlers On 2010-04-21 13:08, David Winsemius wrote: On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote: I've generated a levelplot showing the density

Re: [R] Unwanted boxes in legend

2010-04-20 Thread Peter Ehlers
On 2010-04-19 8:11, Thomas Stewart wrote: Try border=c(0,0,1,0). -tgs If the 'border' argument is not recognized, then this won't work. Steve: What version of R are you using? I have no problems with the suggestions I gave you in R 2.10.1 or R 2.11.0 alpha. -Peter Ehlers On Mon, Apr 19

Re: [R] comparing attitudes of 2 groups / likert scales?

2010-04-20 Thread Peter Ehlers
of thumb}, publisher = {Wiley series in probability and statistics}, year = {2002}, author = {Gerald van Belle} } And a very fine book it is, too. Highly recommended. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list

Re: [R] bwplot puts the bars in the wrong place

2010-04-19 Thread Peter Ehlers
James, It's actually the bars for hour 3 (which don't exist) that are missing. You still need the 'drop.unused.levels=FALSE' and if you make 'OnHour' into a factor then you won't need the 'horizontal=FALSE'. -Peter Ehlers On 2010-04-19 8:27, James Rome wrote: You were right about the gdf

Re: [R] bwplot puts the bars in the wrong place

2010-04-17 Thread Peter Ehlers
are needed for your plot question, there really is no need to give us 21 variables. -Peter Ehlers On 2010-04-17 6:48, James Rome wrote: The data are at http://dl.dropbox.com/u/537118/gdf.zip On 4/17/2010 1:42 AM, Deepayan Sarkar wrote: On Fri, Apr 16, 2010 at 1:54 PM, James Romejamesr...@gmail.com

Re: [R] bwplot puts the bars in the wrong place

2010-04-17 Thread Peter Ehlers
superior to what passes for documentation from, say, MS. -Peter Ehlers The only thing that put the correct data on the correct hours was to call xyplot instead of bwplot, with panel.bwplot in the panel function. Sorry for being so dense, but I really find it much harder to read R documentation

Re: [R] bwplot puts the bars in the wrong place

2010-04-17 Thread Peter Ehlers
'gdf$': this makes no sense to me. What error occurs if you leave that off? -Peter Ehlers On 2010-04-17 13:00, James Rome wrote: David, I did post a solved message: hrs = seq(0, 23, 1) hrlabs = as.character(seq(0,23,1)) g = xyplot(gdf$tt~gdf$OnHour |gdf$Runway, data

Re: [R] how to change the position of xlab in truehist?

2010-04-16 Thread Peter Ehlers
and then adding your preferred labels at your preferred locations: truehist(x, nbins = 4, xaxt = n) ## see xaxt under ?par axis(1, at = 0:3 + 0.5, labels = 0:3) I usually add box(bty = l) -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing

Re: [R] Scanning only specific columns into R from a VERY large file

2010-04-16 Thread Peter Ehlers
to define a colClasses vector whose elements are NA for columns to be read and NULL for columns to be skipped, and then read x.csv with that colClasses vector. I have no idea how slow this would be. -Peter Ehlers __ R-help@r-project.org mailing list https

Re: [R] Ranking correlation with R

2010-04-15 Thread Peter Ehlers
as a 'good' or 'bad' correlation. Everything depends on context. You shouldn't use a statistic if you don't understand it. -Peter Ehlers Cheers, -- David Nemer On Sat, Apr 10, 2010 at 2:58 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: Try this: A- c(file1.java, file3.java, file2

Re: [R] graphic question

2010-04-15 Thread Peter Ehlers
blank column between successive labels. Does this give you what you have in mind: text(par(usr)[1] + max(strwidth(paste(lab1, ))), 2:4,lab1,adj=c(0,0.5)) -Peter Ehlers Thanks! Hocine [[alternative HTML version deleted]] __ R-help

Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers
should always tell us what contributed packages you are using. Here, the qqmath function is from pkg:lattice. Now check FAQ 7.22. -Peter Ehlers As I wrote, I'd really appreciate the understand where this behaviour comes from. Thanks in advance, Uwe

Re: [R] histogram

2010-04-15 Thread Peter Ehlers
the help page. panel.densityplot(x, darg = list(bw = nrd, adjust = 1.2), ...) (I would use one of the built-in bandwidth selectors with a suitable 'adjust' value.) -Peter Ehlers Thanks again, Santosh On Thu, Apr 15, 2010 at 12:41 AM, Paul Hiemstrap.hiems...@geo.uu.nlwrote: Santosh wrote

Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers
On 2010-04-15 4:03, Uwe Dippel wrote: Peter Ehlers wrote: par(mfrow=c(1,1)) qqnorm(rnorm(20)) qqmath(rnorm(20)) par(mfrow=c(3,4)) for(i in 1:12)qqnorm(rnorm(20)) Until here everything works as expected, and the last line prints 12 samples of qqnorm. However, for(i in 1:12)qqmath(rnorm(20

Re: [R] classes and functions for qqnorm and stem

2010-04-15 Thread Peter Ehlers
; it should be just stem(possum$hdlngth). -Peter Ehlers Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self

Re: [R] Consistent behaviour of for-loop

2010-04-15 Thread Peter Ehlers
On 2010-04-15 5:00, Uwe Dippel wrote: Peter Ehlers wrote: You are mixing 'traditional' graphics (par(...)) and 'lattice' graphics. That won't work. In lattice, you use the 'layout' argument to select the number of columns/rows. This is easiest if you set up a conditioning variable: cond - gl

Re: [R] Alignment of x-axis labels

2010-04-15 Thread Peter Ehlers
of every year): axis(1, at=seq(1,96,12), 1978:1985) Your seq() needs to index the elements of temp. Something like axis(1, at = temp[seq(...)], ...) -Peter Ehlers This one has stumped me somewhat, so I'd be grateful to receive any suggestions as to how I might resolve this. Many thanks

Re: [R] using nls for gamma distribution (a,b,d)

2010-04-15 Thread Peter Ehlers
I don't know what else is wrong, but do you really want a shape parameter equal to 28? gamma(28) is about 10^28. That's not a model I would trust. -Peter Ehlers On 2010-04-15 9:37, Asif Wazir wrote: Dear all i want to estimated the parameter of the gamma density(a,b,d) f(x) = (1/gamma(b

Re: [R] Unwanted boxes in legend

2010-04-15 Thread Peter Ehlers
= FALSE # in which case no box is drawn for any element or border = c(NA, NA, black, NA) -Peter Ehlers Many thanks, Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Problem with recode -Error in parse(text = range[[1]][1]) : unexpected end of input in c(0

2010-04-14 Thread Peter Ehlers
Get rid of the unnecessary c(...) construction: recode(green_2004_2$french, 50:100=0; 0:49.99=1) -Peter Ehlers On 2010-04-14 1:56, Simon Kiss wrote: Dear colleagues, in the help archive there was a previous person who encountered a problem with the recode command in the car library. I'm

Re: [R] Problem trying to plot Vennerable object

2010-04-14 Thread Peter Ehlers
you anything: do.call(c, list('a', 'b')) [1] a b c - 3 do.call(c, list('a', 'b')) Then try rm(c) and run your Venn code again. -Peter Ehlers What's frustrating is that a colleague with different versions of R (2.8.x) and some of the libraries gets the above function to work fine. I

Re: [R] Error: could not find function tsts tradesys package

2010-04-14 Thread Peter Ehlers
I think that this package is very much in the early stages of development. It may be that the tsts function is still just a gleam in the eyes of the developers. The paper that you cite may be ahead of code development. -Peter Ehlers On 2010-04-14 10:20, dbonneau wrote: Thank you so much

Re: [R] source(,echo=T) doesn't echo final comments

2010-04-13 Thread Peter Ehlers
) for n %in% 1:7 -Peter Ehlers Specific context: This problem arises e.g. in the context of help files (.Rd) whose example section contains only code that is not to be run (\dontrun markup). Running the function example() (that itself calls source(,echo=TRUE)) on such a file will not display

Re: [R] Interpreting factor*numeric interaction coefficients

2010-04-12 Thread Peter Ehlers
variables. -Peter Ehlers Any help with this would be much appreciated, Matthew Carroll ### example code resp- rpois(30, 5) cat- factor(rep(c(1:3), 10)) var1- rnorm(30, 10, 3) mod- glm(resp ~ var1 * cat, family=poisson) summary(mod) Call: glm(formula = resp ~ var1 * cat, family = poisson

Re: [R] Peculiar behaviour with MatchIt and a function

2010-04-12 Thread Peter Ehlers
you a more definitive solution, but this works: Make a copy of the function (rename it) and replace that line with: data - eval(object$call$data, envir = parent.frame()) Then call your new function instead of match.data. -Peter Ehlers The object ex follows: ex- structure(list(treatment = c

Re: [R] SAS like Macro variable substituion?

2010-04-12 Thread Peter Ehlers
the suffix 1. The second part requires text so it can use the paste function. save((paste(unislopes,master.i,sep=),file=paste(unislopes,master.i,.Rdata,sep=)) Any ideas? -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https

Re: [R] lattice garphs: combining multiple scatterplots and addinglegend

2010-04-12 Thread Peter Ehlers
, pch=20, col=cols, cex=1.2) }, key = list(space=right, text=list(labels=c('test1','test2','test3')), points=list(pch=20, cex=1.2, col=cols)) ) print(all, position=c(0,0,1,.7)) -Peter Ehlers Thanks for your help Jannis

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-04-11 Thread Peter Ehlers
and may be unlawful. -Original Message- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Wednesday, March 31, 2010 2:03 PM To: Czerminski, Ryszard Cc: R-help@r-project.org; David Meyer Subject: Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works Ryszard

Re: [R] Read data in sequences

2010-04-10 Thread Peter Ehlers
... dm - melt(wide) # replace dm$variable with appropriate factor dm$variable - gl(2, 2, nrow(dm), c('x1','x2')) # choose names for columns names(dm) - c('Treat', 'x', 'value') I agree that this 'long' format is usually most useful for further analysis. -Peter -- Peter Ehlers University

Re: [R] Using read.table to read file created with read.table and qmethod = escape

2010-04-08 Thread Peter Ehlers
This worked for me in R 2.11.0 alpha: df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) -Peter Ehlers On 2010-04-07 19:09, Hadley Wickham wrote: df- data.frame(a = a\b) write.table(df, test.csv, sep = ,, row

Re: [R] Question about simple.median.test

2010-04-08 Thread Peter Ehlers
, due to simply doubling the one-sided p-value. -Peter Ehlers Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented

Re: [R] Strange csv parsing problem

2010-04-08 Thread Peter Ehlers
for all rows. From your other post(s) on escaped quotes, I assume that this won't solve your problem with the existing files. (: Try this: create a text file with the lines a,a \bc\ d\e,f\g count.fields(file, sep = ,). [1] 1 1 2 -Peter Ehlers On 2010-04-07 19:26, Hadley Wickham wrote: url

Re: [R] Strange csv parsing problem

2010-04-08 Thread Peter Ehlers
On 2010-04-08 9:10, Hadley Wickham wrote: Remove the comma and count.fields gives 11 for all rows. From your other post(s) on escaped quotes, I assume that this won't solve your problem with the existing files. (: Right - but assuming I'm not crazy, that should cause an error in read.csv,

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-04-07 Thread Peter Ehlers
base other attached packages: [1] sets_1.0-4 -Peter Ehlers On 2010-04-07 6:54, Czerminski, Ryszard wrote: Thank you for looking into it! There is still something I do not understand (despite different numerics on different machines, etc.) On my system plain p == p (where p's are from runif

Re: [R] Specifying parameters for use in plyr / ddply

2010-04-07 Thread Peter Ehlers
ddply on a bunch of variables? Thank you very much for your advise! Yes, there is: colwise() f - function(x) x / mean(x, na.rm = TRUE) ddply(x, group, colwise(f, c(a, b))) -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list

Re: [R] combn with factors

2010-04-07 Thread Peter Ehlers
for combinations, or integer n for x - seq(n). and factors are not vectors. Two things will work with factors: 1. use combn(as.character(yourfactor), m) 2. use combn(yourfactor, m, simplify = FALSE) which will return a list. -Peter This occurs in R 2.10.1 Thanks, Greg -- Peter Ehlers

Re: [R] lattice package: line end style

2010-04-06 Thread Peter Ehlers
, panel = mypanel.cloud, lineend = square) Your choice are round (default), butt and square. -Peter Ehlers Thanks in advance Dan P.S. the reason for this is that the round end looks bad at lwd=3 or more Daniel Alcock Malaria Genetics (T112) Wellcome Trust Sanger Institute Cambridge CB10 1SA UK

Re: [R] lattice package: line end style

2010-04-06 Thread Peter Ehlers
What a dummy I am. It just occurred to me that you can set grid graphical parameters with par.settings. cloud(your stuff, par.settings = list(grid.pars = list(lineend = butt))) -Peter Ehlers On 2010-04-06 14:53, Peter Ehlers wrote: On 2010-04-06 7:28, Daniel Alcock wrote: First

Re: [R] A questionb about the Wilcoxon signed rank test

2010-04-05 Thread Peter Ehlers
Since this may be homework, I'll confine myself to a hint (which may or may not be the problem; I haven't checked): The formula you use for z is strongly dependent on the value of 'n'. -Peter Ehlers On 2010-04-05 6:06, hix li wrote: Hi guys, I have two data sets of prices: endprice0

Re: [R] find the next non-NA value within each row of a data-frame

2010-04-05 Thread Peter Ehlers
If I understand correctly what you want (according to your loop), you could use the na.locf function in pkg:zoo. library(zoo) mat - t(apply(mydata, 1, na.locf, fromLast=TRUE, na.rm=FALSE)) dat - as.data.frame(mat) ## since apply returns a matrix -Peter Ehlers On 2010-04-05 10:52, Anna

Re: [R] ggplot2 geom_rect(): What am I missing here

2010-04-04 Thread Peter Ehlers
Marsh, Your rectangles won't be very tall with ymax=ymin! (I hope that wasn't the cause of the 5 hours.) -Peter Ehlers On 2010-04-04 14:18, Marshall Feldman wrote: Hi R fans, As a newbie following the five-hour rule (after hitting my head against the wall for five hours, post to this list

Re: [R] R abrupt exit

2010-04-02 Thread Peter Ehlers
Google leads to some discussion on the Intel Sofware Network: http://software.intel.com/en-us/forums/showthread.php?t=64585 Be warned: I haven't read the discussion. -Peter Ehlers On 2010-04-02 9:30, jacob wrote: Dear Lists: I recently ran quite annoyance problem while running R on Ubuntu

Re: [R] Adding regression lines to each factor on a plot when using ANCOVA

2010-04-02 Thread Peter Ehlers
~ species, data=dataset) ## Rich [[alternative HTML version deleted]] -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org

Re: [R] Stack with factors

2010-04-01 Thread Peter Ehlers
here x- db1[[1]] is.vector(x) [1] FALSE so I think that this at least explains why it doesn't work as you expected. db2 - stack(lapply(db1, as.character)) will do it. -Peter Ehlers Thank you for your help. Kenneth -- Peter Ehlers University of Calgary

Re: [R] How to get the scale limits in lattice plot

2010-04-01 Thread Peter Ehlers
I can put the text at the correct position in the panel.function? You probably want current.panel.limits(). -Peter Ehlers Thanks, Jim Rome __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] Adding regression lines to each factor on a plot when using ANCOVA

2010-04-01 Thread Peter Ehlers
and 12 slopes as the remaining coefs. Then you can use cof - coef(mod) for(i in 1:12) abline(a=cof[i], b=cof[12 + i]) to plot the 12 lines. -Peter Ehlers On 2010-04-01 16:21, Steven Worthington wrote: Dear R users, i'm using a custom function to fit ancova models to a dataset. The data

Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Peter Ehlers
(a)) print(r- lm(a[ ,i] ~ b) ) #Note the comma! -Peter Ehlers On 2010-03-31 7:42, David Winsemius wrote: On Mar 31, 2010, at 9:13 AM, Driss Agramelal wrote: Hello and thank you both for your answers! Dennis, I tried to simply run lm(a ~ b) after re-importing a as a matrix, but I get

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers
Unless I'm missing something, I don't see any method in pkg:sets for intersection other than gset_intersection. So you're using the base R function `` whose help page tells you that its arguments should be vectors. Yours aren't. -Peter Ehlers On 2010-03-31 8:50, Czerminski, Ryszard wrote

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers
On 2010-03-31 9:30, Peter Ehlers wrote: Unless I'm missing something, I don't see any method in pkg:sets for intersection other than gset_intersection. Whoops, a bit quick on the draw. There are of course also set_intersection and cset_intersection, but not AFAICS any method for ``. -Peter

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers
to call the relevant 'Ops' function: class(A) #[1] gset cset class(B) #[1] gset cset class(E - A - A) #[1] set gset cset If you re-order the class vector, function Ops.gset will be called to handle A and E: class(E) - class(E)[c(2,3,1)] A E #{} I've cc'd David Meyer. -Peter Ehlers On 2010-03-31

Re: [R] simple loop iteration

2010-03-30 Thread Peter Ehlers
Perhaps you're just looking for the diff() function? See ?diff. -Peter Ehlers On 2010-03-30 7:15, Niklaus Hurlimann wrote: Hi R mailing list, probably a very basic problem here, I try to do the following: Q-c(1,2,3) P-c(4,5,6) A- data.frame(Q,P) A Q P 1 1 4 2 2 5 3 3 6 this is my

Re: [R] use logical in cor.test

2010-03-30 Thread Peter Ehlers
replace the line is.na(tBoth[tBoth 2.5]) - TRUE with tBoth[tBoth 2.5] - NA and the rest should work. Thanks again, Paul -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Multivariate hypergeometric distribution version of phyper()

2010-03-30 Thread Peter Ehlers
Karl, I strongly support Chuck's recommendations. If you do still want to compute such probabilities 'by hand', you could consider the lchoose() function which does work for your example. -Peter Ehlers On 2010-03-30 9:55, Charles C. Berry wrote: On Tue, 30 Mar 2010, Karl Brand wrote: Dear

Re: [R] Trouble loading package

2010-03-28 Thread Peter Ehlers
(and others): get used to using TRUE and FALSE. The few characters saved by using T/F are not worth it! -Peter Ehlers On 2010-03-26 15:40, Glenn E Stauffer wrote: I am trying to load a package called Rmark, but when I run library(Rmark) I get the following: library(RMark) Error

Re: [R] Matching pairs of values

2010-03-27 Thread Peter Ehlers
vtest(ma,c(3,7)) [1] TRUE vtest(ma,c(1,7)) [1] FALSE Berend -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

Re: [R] Matching pairs of values

2010-03-27 Thread Peter Ehlers
) or to sort before testing: vtest - function(x, lookfor){ any(apply(x, 1, function(v) {identical(sort(v), sort(lookfor))}))} -Peter Ehlers On 2010-03-27 2:46, Berend Hasselman wrote: David Scott-6 wrote: I am sure someone can come up with a clever way of doing

Re: [R] how can I look at .Internal(model.matrix(t, data))?

2010-03-09 Thread Peter Ehlers
I imagine it's in https://svn.r-project.org/R/trunk/src/main/model.c -Peter Ehlers On 2010-03-05 12:43, Werner W. wrote: Hi, I would like to see how model.matrix expands factor column to a set of dummy columns. I think that is done int .Internal(model.matrix(t, data)) which is called

<    4   5   6   7   8   9   10   11   12   13   >