Re: [R] Tracing the top border of a histogram

2013-08-01 Thread Levi Waldron
Very nice - thank you, I didn't know about type='s'. On Thu, Aug 1, 2013 at 3:43 PM, Greg Snow <538...@gmail.com> wrote: > lines( tmp$breaks, c(tmp$counts,tail(tmp$counts,1)), type='s', > col='#00ff0077', lwd=5 ) > > > > On Thu, Au

[R] Tracing the top border of a histogram

2013-08-01 Thread Levi Waldron
I want to represent a histogram by the line along its top border, *without* kernel smoothing (to show several histograms in the same plot). This works, but is there simpler recommended way? x <- rnorm(1000) tmp <- hist(x, border="white") for (i in 1:(length(tmp$breaks)-1)){ segments(x0=tmp$bre

Re: [R] Regularized Regressions

2013-04-17 Thread Levi Waldron
Perhaps I am wrong, but I think there are only a few packages supporting Elastic Net, and none of them also perform Best Subsets. On Wed, Apr 17, 2013 at 8:46 AM, Christos Giannoulis wrote: > Merhaba, Hello to you too Mehmet (Yasu ki sena) > > Thank you for your email and especially for sharing

Re: [R] text command - how to get a white background to cover grid lines

2012-09-06 Thread Levi Waldron
For posterity, I found the TeachingDemos::shadowtext option most agreeable for this problem: * legend puts a large box around the text which did not seem possible to shrink, and does not accept vector x, y arguments * plotrix::boxed.labels did not work with pos=4 (this moved the text, but

[R] highlighting clusters in a heatmap

2011-06-30 Thread Levi Waldron
I would like to draw horizontal or vertical lines on a heatmap to highlight the clusters at some specified cut depth of the dendrogram. As a hacked example, the following code would work if I could set the coordinates of the top and bottom of the false color image correctly (ymin and ymax), but the

[R] difference between the meaning of MARGIN in sweep() and apply()

2009-12-16 Thread Levi Waldron
3 [3,]24 Is there a logic to this difference, or is it just a quirk of the history of these functions? I found one discussion on this topic, but without what I thought was a very conclusive end: http://finzi.psych.upenn.edu/Rhelp08/2009-March/191930.html -- Levi Waldron post-doctoral fel

Re: [R] Simple question about error on CSV import

2009-09-01 Thread Levi Waldron
com/Simple-question-about-error-on-CSV-import-tp25242899p25243159.html > Sent from the R help mailing list archive at Nabble.com. > > ______ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the

Re: [R] Two way joining vs heatmap

2009-08-31 Thread Levi Waldron
ve function to use? > > Thanks for the help! > Schalk Heunis > > __ > 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,

Re: [R] setting par(srt) according to plot aspect ratio

2009-08-28 Thread Levi Waldron
quot;) makeplot() #as per example code par(mfrow=c(2,1)) makeplot() makeplot() par(mfrow=c(1,2)) makeplot() makeplot() dev.off() -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (4

Re: [R] setting par(srt) according to plot aspect ratio

2009-08-27 Thread Levi Waldron
ot;mai")[4]) (f_angle <- atan(myasp)*180/pi) (g_angle <- atan(2*myasp)*180/pi) -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (416)581-7453 [[alternative HTML

Re: [R] setting par(srt) according to plot aspect ratio

2009-08-27 Thread Levi Waldron
?plot.window > > which then gets you to ?plot (actually plot.default() ) > > Bert Gunter > Genentech Nonclinical Biostatisics > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On > Behalf Of Levi Waldron > Sen

[R] setting par(srt) according to plot aspect ratio

2009-08-27 Thread Levi Waldron
ar(srt=f_angle) text(xpos,f(xpos),label="y=x",pos=3) par(srt=g_angle) text(xpos,g(xpos),label="y=2x",pos=3) -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (416)581-

[R] multiple annotations on a heatmap

2009-04-02 Thread Levi Waldron
heatmap annotates the columns by the first of the three annotations with a colored bar along the top of the heatmap, but ideally I would like to put all three annotations on the heatmap by putting three rows of +/- values between the top of the heatmap and the dendrogram, or even three colored bars.

Re: [R] memory space

2009-03-18 Thread Levi Waldron
Perhaps: gc() On Wed, Mar 18, 2009 at 8:26 AM, Abelian wrote: > Dear all > when the program is runing, we can realize that the memory size will > be asked more and more.. > Therefore, we could meet the significant problem, such as out off > memory size. > However, even if i rm() some variable

Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Levi Waldron
compared to the direct replacement it sounds like you've figured out. cheers, Levi -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Discovery Centre TMDT 9-304D 101 College Street Toronto, Ontario M

Re: [R] breaking ties in order() based on many vectors

2009-03-17 Thread Levi Waldron
On Tue, Mar 17, 2009 at 12:56 PM, Patrick Burns wrote: > Use 'do.call' as discussed in 'The R Inferno' > and elsewhere. Perfect, thanks. -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Di

[R] breaking ties in order() based on many vectors

2009-03-17 Thread Levi Waldron
()? -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Discovery Centre TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 [[alternative HTML version deleted]] __ R

Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Levi Waldron
Your first example that works would just repeat the atomic vector to the length of the row. To replace a row with another data frame, you could use rbind: avGain <- rbind(avGain[-j,],b) Or if the positioning is important, 2) avGain <- rbind(avGain[1:(j-1),],b,avGain[(j+1):nrow(avGain),]) I didn

Re: [R] Looping multiple output values to dataframe

2009-02-12 Thread Levi Waldron
<- x[2]*y[1] result.B <- y[2]-x[1] result.C <- x[3]+y[1] results <- c(result.A, result.B, result.C) # concatenate result vectors names(results) <- c("ResultA", "ResultB", "ResultC") return(results) } variables <- sapply(filenames,doc

Re: [R] getting all pairwise combinations of elements in a character string

2009-02-12 Thread Levi Waldron
I like both of these solutions much better - thank you! -Levi -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Discovery Centre TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7

[R] getting all pairwise combinations of elements in a character string

2009-02-12 Thread Levi Waldron
nction(x) paste(x,mystring[(grep(x,mystring)+1):length(mystring)],sep=""))) a1 a2 a3 a4 b1 b2 b3 c1 c2 d "ab" "ac" "ad" "ae" "bc" "bd" "be" "cd" "ce" "de" > --

Re: [R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Levi Waldron
Perfect, thanks all. Unlist and ave will both be very handy functions to know. -levi -- Levi Waldron, PhD Treated Wood Research Group Faculty of Forestry, University of Toronto 33 Willcocks Street, Toronto ON, M5S 3B3 CANADA Tel 647-866-5384 Fax 416-978-3834 [[alternative HTML

[R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Levi Waldron
This one should be easy but it's giving me a hard time mostly because tapply puts the results in a list. I want to calculate the cumulative sum of a variable in a dataframe, but with the accumulation only within each level of a factor. For a very simple example, take: > df <- data.frame(x=c(rep(

Re: [R] choosing an appropriate linear model

2008-06-06 Thread Levi Waldron
use a bootstrap method, or something else? ps. the data is attached to the end of this email. On Thu, Jun 5, 2008 at 6:25 PM, Levi Waldron <[EMAIL PROTECTED]> wrote: > I am trying to model the observed leaching of wood preservative chemicals > from treated wood during an outdoor experiment

[R] lw in legend also changes thickness of characters in the legend??

2008-05-14 Thread Levi Waldron
Here's a simple example: x <- 1:5 plot(x,x^2) lines(x,x^2) points(x,x,cex=2) lines(x,x,lw=3) legend("topleft",legend=c("y=x^2","y=x"),pch=1,pt.cex=1:2,lw=c(1,3)) The thickness of the circles in the legend changes with lw. If you change the lw argument in legend to lw=c(1,1) then the thickness of

[R] customization of pairwise comparison plots

2008-05-01 Thread Levi Waldron
I am wondering how to customize a pairwise comparisons plot of a factorial ANOVA, without doing a lot of manual manipulation of a TukeyHSD object. The customizations I'd like are: 1. The aov used log-transformed response data, but I'd like to plot the intervals on their original, untransformed s

[R] restricting pairwise comparisons of interaction effects

2008-04-28 Thread Levi Waldron
I'm interested in restricting the pairwise comparisons of interaction effects in a multi-way factorial ANOVA, because I find comparisons of interactions between all different variables different to interpret. For example (supposing a p<0.10 cutoff just to be able to use this example): > summary(fm

Re: [R] adding device size-independent y=0 line to a lattice plot

2008-03-31 Thread Levi Waldron
On Mon, Mar 31, 2008 at 4:04 PM, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > The obvious thing to try would be > > dotplot(y~x|fac, > panel = function(...) { > panel.abline(h = 0) > panel.dotplot(...) > }) > > Does this not work? > > -Deepayan > Yes t

[R] adding device size-independent y=0 line to a lattice plot

2008-03-31 Thread Levi Waldron
Using the following lattice plot as an example, I would like to add horizontal lines where y=0: library(lattice) library(grid) fac <- gl(4,12) x <- letters[rep(1:3,16)] y <- runif(48,min=0.0) dotplot(y~x|fac) I've tried it with grid.lines using npc and native units, which works fine unless I chan

Re: [R] "spreading out" a numeric vector

2008-03-24 Thread Levi Waldron
Would this function be worth submitting to some existing cran library? I'd be willing to document it and add error-checking if there is somewhere that it belongs (with credit to Greg of course, unless Greg wants to submit it himself). I am using it in conjunction with a function I wrote which dra

Re: [R] "spreading out" a numeric vector

2008-03-24 Thread Levi Waldron
*Thank you* Greg, this function works perfectly! I had imagined that the ideal solution would iteratively modify the vector to fix new violations of mindiff created by each subsequent spreading of tight clusters, but couldn't figure how to do it. A small note, the vector x must be sorted before u

Re: [R] "spreading out" a numeric vector

2008-03-22 Thread Levi Waldron
On Sat, Mar 22, 2008 at 9:58 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Is this close to what you want? > > > spread <- function(x, mindiff=0.5){ > + unique(as.integer(x / mindiff) * mindiff) > + } > > > > > x <- c(1,2,seq(2.1,2.3,0.1),3,4) > > x > [1] 1.0 2.0 2.1 2.2 2.3 3.0 4.0 > > s

[R] "spreading out" a numeric vector

2008-03-22 Thread Levi Waldron
I am creating a timeline plot, but running into a problem in positions where the values to plot are too close together to print the text without overlap. The simplest way I can think of to solve this (although there may be other ways?) is to create a new numeric vector whose values are as close as

Re: [R] differentiating a numeric vector

2008-03-06 Thread Levi Waldron
Thanks for all the ideas. splinefun looks like the simplest way to achieve what I need: > x <- 1:10 > y <- x^2 > f <- splinefun(x,y) > f(3,deriv=0) [1] 9 > f(3,deriv=1) [1] 6 > f(3,2) [1] 2 > f(3,3) [1] -3.330669e-16 The fda package has a function bsplineS which does nearly the same thing, and t

[R] differentiating a numeric vector

2008-03-05 Thread Levi Waldron
What functions exist for differentiating a numeric vector (in my case spectral data)? That is, experimental data without an analytical function. ie, > x <- seq(1,10,0.1) > y=x^3+rnorm(length(x),sd=0.01) #although the real function would be > nothing simple like x^3... > derivy <- I kn

Re: [R] summarizing replicates with multiple treatments

2008-03-04 Thread Levi Waldron
On Tue, Mar 4, 2008 at 5:32 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > > library(doBy) > summaryBy(. ~ day + treat, exampledata, FUN = c(mean, sd)) Outstanding, so much better. Thanks. __ R-help@r-project.org mailing list https:/

[R] summarizing replicates with multiple treatments

2008-03-04 Thread Levi Waldron
I have a dataframe with several different treatment variables, and would like to calculate the mean and standard deviation of the replicates for each day and treatment variable. It seems like it should be easy, but I've only managed to do it for one treatment at a time using subset and tapply. He