[R] Fwd: How to retain the NA as a value for splitting a dataframe

2019-05-23 Thread Jun Shen
Dear list, Say I have a data frame with NA in the variable which I want to use as a sorting variable for splitting the data frame. df <- data.frame(A=1:10, B=c(rep(99,5), rep(100,5)), C=c(rep(NA,3), rep(1,3), rep(2,4))) split(df, f=df[c('C')], drop=FALSE), I got the output as follows. I was hopi

[R] Multiple "scale_color_manual" statements in one plot (ggplot2, flexible legend challenge)

2017-06-30 Thread Jun Shen
o separate the color schemes for lines and points, but I can't use multiple scale_color_manual statement in one ggplot. Jun Shen sample data# df1 <- structure(list(Y2 = c(0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L), X = c(27L, 8L, 33L, 5

Re: [R] Add annotation text outside of an xyplot (lattice package)

2016-09-25 Thread Jun Shen
plot(y ~ x, data=tmp, main="outside text displayed", > >>par.settings=list(clip=list(panel=FALSE)) ## permit text > >> outside the panel > >> ) + > >> ## "+" must be on same line as first statement. > >

Re: [R] Add annotation text outside of an xyplot (lattice package)

2016-09-25 Thread Jun Shen
ia adj you can control, if the text should adjust left, center or right > > to the coords, and above, center or bottom of them. > > > > HTH, > > Rainer Hurling > > > > > > Am 22.09.2016 um 16:04 schrieb Jun Sh

[R] Add annotation text outside of an xyplot (lattice package)

2016-09-22 Thread Jun Shen
Dear list, Just wonder if there is a way to add annotation text outside an xyplot, (e.g. the bottom of the plot). the panel.text seems only add text within the plot. Thanks. Jun [[alternative HTML version deleted]] __ R-help@r-project.org mail

Re: [R] element wise pattern recognition and string substitution

2016-09-09 Thread Jun Shen
ewmiller wrote: > Here are some suggestions: > > test.string <- c( '240.m.g.>110.kg.geo.mean' > , '3.mg.kg.>110.kg.P05' > , '240.m.g.>50-70.kg.geo.mean' > ) > # based on your literal id

Re: [R] element wise pattern recognition and string substitution

2016-09-08 Thread Jun Shen
sted in this thread. Now I need to figure out a way to match the patterns to the strings so each string can be parsed correctly. I have made some progress... Jun On Wed, Sep 7, 2016 at 9:34 AM, Ista Zahn wrote: > On Tue, Sep 6, 2016 at 11:59 PM, Jun Shen wrote: > > Hi Ista, >

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
ings)) print(sub(patterns[i], "\\2", strings[i])) > > mapply(sub, pattern = patterns, x = strings, MoreArgs=list(replacement = > "\\2")) > > library(stringi) > stri_replace_all_regex(strings, patterns, "$2") > > Best, > Ista > On Tue, Sep

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
can find someone locally to > >help you if you do not receive a satisfactory reply from the list. > >There are many people here who are pretty good at this sort of thing, > >but I don't know if they'll reply. Regex's are certainly complex. PERL > >people t

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
are numerous > web sites and books on them if you need to acquire expertise for your > work. > > Cheers, > Bert > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed

Re: [R] element wise pattern recognition and string substitution

2016-09-06 Thread Jun Shen
..dd.ef.tgf.", "foo...b.bbb.tgy") > > > >> pat1 <- "a+\\.*a+" > >> pat2 <-"b+\\.*b+" > >> pat <- c(pat1,pat2) > > > >> pat <- do.call(paste,c(as.list(pat), sep="|")) > >> pat > > [

Re: [R] element wise pattern recognition and string substitution

2016-09-05 Thread Jun Shen
016 at 9:30 PM, Jeff Newmiller > wrote: > > Your opening assertion is false. > > > > Provide a reproducible example and someone will demonstrate. > > -- > > Sent from my phone. Please excuse my brevity. > > > > On September 4, 2016 9:06:59 PM PDT, Jun Shen

[R] element wise pattern recognition and string substitution

2016-09-04 Thread Jun Shen
Dear list, I have a vector of strings that cannot be described by one pattern. So let's say I construct a vector of patterns in the same length as the vector of strings, can I do the element wise pattern recognition and string substitution. For example, pattern1 <- "([^.]*)\\.([^.]*\\.[^.]*)\\.(

Re: [R] Improve code efficient with do.call, rbind and split contruction

2016-09-02 Thread Jun Shen
y business.I'm assuming this is not the case... Again, no data... > > > > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom Count

[R] Improve code efficient with do.call, rbind and split contruction

2016-09-02 Thread Jun Shen
Dear list, I have the following line of code to extract the last line of the split data and put them back together. do.call(rbind,lapply(split(simout.s1,simout.s1[c('SID','DOSENO')]),function(x)x[nrow(x),])) the problem is when have a huge dataset, it takes too long to run. (actually it's > 3 h

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread Jun Shen
Thanks David.This is working perfectly! On Fri, Jul 29, 2016 at 9:00 PM, David Winsemius wrote: > > > On Jul 29, 2016, at 5:52 PM, David Winsemius > wrote: > > > > > >> On Jul 29, 2016, at 5:08 PM, Jun Shen wrote: > >> > >> Thanks Jeff/

Re: [R] How to pass na.rm=T to a user defined function

2016-07-29 Thread Jun Shen
2','ALPHA')) gives meansd median min max N CL-0.0232 0.918 -0.0786 -2.14 3.14 99 V1-0.0410 0.936 -0.1160 -2.86 2.67 99 V2-0.1760 0.978 -0.1490 -2.31 2.15 99 ALPHA -0.1380 0.960 -0.2160 -2.41 2.20 99 there is one non-missing value in V1,V2 and ALPHA is o

Re: [R] How to pass na.rm=T to a user defined function

2016-07-28 Thread Jun Shen
iller wrote: > Why not remove it yourself before passing it to those functions? > -- > Sent from my phone. Please excuse my brevity. > > On July 28, 2016 5:51:47 PM PDT, Jun Shen wrote: > >Dear list, > > > >I write a small function to calculate multiple stats on mu

[R] How to pass na.rm=T to a user defined function

2016-07-28 Thread Jun Shen
Dear list, I write a small function to calculate multiple stats on multiple variables and export in a format exactly the way I want. Everything seems fine until NA appears in the data. Here is my function: do.stats <- function(data, stats.func, summary.var) as.data.frame(signif(sappl

Re: [R] How to replace all commas with semicolon in a string

2016-05-27 Thread Jun Shen
Thanks Ulrik and Bob for your reply. gsub worked for one column! If I want to replace the whole data frame, gsub doesn't seem to work. Any idea On Fri, May 27, 2016 at 11:14 AM, Ulrik Stervbo wrote: > use gsub() > > On Fri, 27 May 2016 at 17:12 Jun Shen wrote: > >>

[R] How to replace all commas with semicolon in a string

2016-05-27 Thread Jun Shen
Dear list, Say I have a data frame test <- data.frame(C1=c('a,b,c,d'),C2=c('g,h,f')) I want to replace the commas with semicolons sub(',',';',test$C1) -> test$C1 will only replace the first comma of a string. How do I replace them all in one run? Thanks. Jun [[alternative HTML versio

[R] Dimension of quantile function output

2016-01-22 Thread Jun Shen
Dear list, Say I have some quantile operation like this data.frame(ID=rep(1:10,each=10),CONC=runif(100)) -> test lapply(c('mean','sd','quantile'), function(x) aggregate(test['CONC'],by=test['ID'],FUN=x)) -> temp The output temp is a list of three elements. I would like to merge the three elemen

Re: [R] string split problem

2015-10-23 Thread Jun Shen
.*)", "\\1", test) > [1] "aaa" "aaa" "aaa" "aaa" """" > > sub("([^.]*)(.*)", "\\2", test) > [1] ".bb.cc" ".dd""" "." ".eee"

[R] string split problem

2015-10-23 Thread Jun Shen
Dear list, Say I have a vector that has two different types of string test <- c('aaa.bb.cc','aaa.dd') I want to extract the first part of the string (aaa) as a name and save the rest of the string as another name. I was thinking something like sub('(.*)\\.(.*)','\\1',test) but doesn't give me

[R] How to assign value to a variable dynamically constructed

2015-07-07 Thread Jun Shen
" is dynamically constructed through paste() id <- 1:4 # I can get the element by doing get(test)[2] # Now I want to assign a value to the second element of this dynamical variable. get(test)[2] <- 5 # doesn't work. Thanks a lot. Jun Shen

[R] How to feed graphic device (png, jpeg etc) with different files names

2015-07-03 Thread Jun Shen
Dear list, I define a function to export a bunch of plots. A sample code is something like the follow export.plots<-function(export.type='pdf',...){ match.fun(export.type) (...) print(plot.func1(...)) print(plot.func2(...)) print(plot.func3(...)) ... print(plot.funcn(...)) dev.off() } If I d

[R] How to add error bars to a line xyplot (lattice package)

2015-01-26 Thread Jun Shen
Dear list, I have a couple of lines (superimposed) in an xyplot and just want to add error bars to each of the data point. It's been a while since this question was asked last time. But the segplot from latticeExtra is not straight forward. Just wonder if there is a better way to do this. Apprecia

[R] How to add a line of "mean" to the bwplot (lattice package)

2015-01-25 Thread Jun Shen
Dear list, The bwplot generates box plots with a dot in median. How do I add a line of "mean" to the boxes? Thanks a lot. Jun [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://sta

Re: [R] split a string a keep the last part

2014-08-28 Thread Jun Shen
Thanks for everyone who replied with those wonderful solutions! Jun On Thu, Aug 28, 2014 at 2:11 PM, Enrico Schumann wrote: > On Thu, 28 Aug 2014, Jun Shen writes: > > > Hi everyone, > > > > I believe I am not the first one to have this problem but couldn't find

[R] split a string a keep the last part

2014-08-28 Thread Jun Shen
Hi everyone, I believe I am not the first one to have this problem but couldn't find a relevant thread on the list. Say I have a string (actually it is the whole column in a data frame) in a format like this: test<- 'AF14-485-502-89-00235' I would like to split the test string and keep the last

Re: [R] How to view the whole dataset that is imported through sasxport.get

2014-08-21 Thread Jun Shen
ot; $ NRT :Class 'labelled' atomic [1:1991] 0 0.75 1.5 3 4 6 9 12 24 0 ... .. ..- attr(*, "label")= chr "Nominal Relative Time" $ TIME:Class 'labelled' atomic [1:1991] -1.1 0.8 1.5 3 4 ... .. ..- attr(*, "label")= chr "Actual Rel

[R] How to view the whole dataset that is imported through sasxport.get

2014-08-21 Thread Jun Shen
Dear list, I used sasxport.get to import a SAS xpt file. Although it is a data frame but i can't view it through the "fix" command. Also when I see its structure, it brings up attributes I am not really interested in (which seems part of the SAS labels) and it doesn't seem to tell me the mode of e

Re: [R] Data extraction and assembly from a data frame

2014-06-20 Thread Jun Shen
gt; > > On Friday, June 20, 2014 3:43 PM, Jun Shen wrote: > Hi all, > > Here is my situation. I have a dataframe, the structure would be something > like this, > > > TestData<-data.frame(ID=rep(1:10,each=10),TIME=rep(seq(0.1,1,0.1),10),VAR1=rnorm(100),VAR2=5*rnorm(100),

[R] Data extraction and assembly from a data frame

2014-06-20 Thread Jun Shen
13.39844 16.965365 8 2.7447862 10.21613 22.545131 9 3.490395 10.83543 25.744662 10 0.4719087 11.73021 7.226687 Thanks for any help. Jun Shen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

Re: [R] How to draw a transparent polygon

2014-05-21 Thread Jun Shen
; > >> > >> -Original Message- > >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Jun Shen > >> Sent: Wednesday, May 21, 2014 10:32 AM > >> To: R-help > >> Subject: [R] How to

[R] How to draw a transparent polygon

2014-05-21 Thread Jun Shen
ygon() for such a feature. Is there another way to do it? Thanks. Jun Shen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-p

[R] level for confint (nls)

2014-05-19 Thread Jun Shen
. The strange thing is if I use level=0.8, it is working again. Why is that? How do I get an CI value for any level? Thanks. Jun Shen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

[R] How to examine the parameter values during iteration (nls)

2014-05-09 Thread Jun Shen
Hi everyone, I am using nls() to run a simple sigmoid curve type of regression and would like to see how the parameter values change through iterations. How can I see those values? Or ideally, can I even extract those values? For example, nls(Response~E0+Emax*Conc/(EC50+Conc), data=data, start=

[R] How to change the label size in axis

2014-02-28 Thread Jun Shen
Hi everyone, I am using the axis command to draw extra axis on the right. How do I change the text size of the labels as in axis (4, at=c(1:9), labels='some text', las=1). I can't find an argument to change the text size for the labels. Thanks. Jun [[alternative HTML version deleted]]

[R] How to ask a function to continuously print intermediate results

2013-12-31 Thread Jun Shen
Dear all, I have a print command to export some intermediate results from a user-defined function. It takes a while to run the function and I found I have to press a key to see the printed results on the screen. How can I ask the function to continuously print results on the screen without pressin

[R] How to plug in characters as object names in a formula (recast from package reshape2 specifically)

2013-12-16 Thread Jun Shen
Hi everyone, This may be very simple but I couldn't figure it out. I have this function rsm.lm<-function(data,xvar='xCmin',yvar='yCmin') { #some calculation.. recast(df, xvar~yvar, id.var=1:2, measure.var=3) #some other operations } df is a dataframe defined internally within the functi

Re: [R] How to generate a smoothed surface for a three dimensional dataset?

2013-12-05 Thread Jun Shen
Thanks again, Duncan. Please allow me to ask one more question. Is it possible to generate a contour plot overlaying with the plot3d() plot? Jun On Thu, Dec 5, 2013 at 11:08 AM, Duncan Murdoch wrote: > On 05/12/2013 10:33 AM, Jun Shen wrote: > >> Hi Federico/Duncan/David/Bert, >

Re: [R] How to generate a smoothed surface for a three dimensional dataset?

2013-12-05 Thread Jun Shen
d, Dec 4, 2013 at 4:37 PM, Bert Gunter wrote: > ... or, more simply > > lm(z ~ polym(x,y, degree=2) ) > > ?polym > > Cheers, > Bert > > > > > > On Wed, Dec 4, 2013 at 10:30 AM, David Winsemius > wrote: > > > > On Dec 4, 2013, at 8:56 AM,

[R] How to generate a smoothed surface for a three dimensional dataset?

2013-12-04 Thread Jun Shen
Hi, I have a dataset with two independent variables (x, y) and a response variable (z). I was hoping to generate a response surface by plotting x, y, z on a three dimensional plot. I can plot the data with rgl.points(x, y, z). I understand I may not have enough data to generate a surface. Is there

[R] multiple pages with ggplot2 possible?

2013-11-21 Thread Jun Shen
Dear all, This question was asked a few years ago. Back then, the answer was NO. Just wonder if the package has been updated to make it possible. An example (Theoph is a dataset coming with R) ggplot(data=Theoph, aes(x=Time, y=conc)) + geom_point() + facet_wrap(~Subject) gives me all 12 subject

[R] Draw two separate legends in xyplot

2013-09-16 Thread Jun Shen
Hi all, I wonder if there is a way to draw two separate legends in xyplot as I would like to separate the legend for data and the legend for reference lines I add. I can use key argument to draw one legend with everything together. What I really want is to put one legend at the bottom and the othe

Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread Jun Shen
NA, 5L), class = "data.frame") Here is the calculation I did originally. >with(test,strptime(SPDTC,format='%Y-%m-%dT%H:%M')-strptime(TimeBL,format='%Y-%m-%dT%H:%M')) The result is in seconds. On Fri, Aug 9, 2013 at 1:55 PM, David Winsemius wrote: > > On Aug 9, 2

[R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread Jun Shen
Hi all, I used strptime() to convert character strings to time and did some subtraction calculation. a<-'2012-07-17T07:50' b<-'2012-08-27T09:30' strptime(a,format='%Y-%m-%dT%H:%M')-strptime(b,format='%Y-%m-%dT%H:%M') The result shows Time difference of -41.06944 days. However when these opera

[R] Is there a limit on the number of code line in .Rhistory

2013-07-21 Thread Jun Shen
Dear list, Just wonder if there is a limit on the number of code line in .Rhistory. When I check the .Rhistory, some code I enter at earlier time disappeared. If there is limit, how do I change it? Thanks. Jun [[alternative HTML version deleted]]

[R] Subsetting rows by multiple levels of selected values

2012-08-14 Thread Jun Shen
Dear list, Let's say we have a data frame as follows, >expand.grid(a=1:5,b=c(1,5,10,20),DV=c(0.1,0.2,0.3))->df1 >df1$DV<-rgamma(60,shape=10) columns a and b are two levels. DV is the column with values we are interested in. Then another data frame df2 with values as follows data.frame(a=c(2,2,

[R] How to specify multiple regular expressions for pattern argument

2012-05-11 Thread Jun Shen
;^d'&'[[:digit:]]$') is not working. Appreciate any comment. Jun Shen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide h

[R] the degrees of freedom in rtmvt {tmvtnorm}

2012-05-09 Thread Jun Shen
et with 46 subjects. Now I want to simulate 100 subjects. So the degrees of freedom should be 46-6=40 or 100-6=94 or some other value? Thanks a lot. Jun Shen Seventh Wave Labs [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] How to adjust the distance between legend and the plot (xyplot)

2012-04-16 Thread Jun Shen
Ehlers wrote: > On 2012-04-16 08:51, David Winsemius wrote: > >> >> On Apr 16, 2012, at 11:43 AM, Jun Shen wrote: >> >> Dear list, >>> >>> As the title indicates if I draw the legend outside of the plot, how >>> do I >>>

[R] How to adjust the distance between legend and the plot (xyplot)

2012-04-16 Thread Jun Shen
Dear list, As the title indicates if I draw the legend outside of the plot, how do I adjust the distance between the legend and the plot? The default setting is too close. Thanks. Here is the sample code I have == xyplot(1~1,key=list(space=

[R] Calculation of standard error for a function

2012-03-02 Thread Jun Shen
Dear list, If I know the standard error for k1 and k2, is there anything I can call in R to calculate the standard error of k1/k2? Thanks. Jun [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

[R] Wilcoxon test p value with one decimal place

2012-02-16 Thread Jun Shen
Dear list, Let's say I have data a=c(37.961,38.214,57.68) b=c(77.56,61.875,67.683) wilcox.test(a,b) the wilcoxon test only gives me a p value with one decimal place. Is this normal? Thanks. Jun [[alternative HTML version deleted]] __ R-he

Re: [R] How to suppress the empty plots in xyplot (lattice)

2012-02-14 Thread Jun Shen
lar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > ------- > Sent from my phone. Please excuse my brevity. > > Jun Shen wrote: > > >Dea

[R] How to suppress the empty plots in xyplot (lattice)

2012-02-14 Thread Jun Shen
Dear all, In a plot command like xyplot(Y~X|ID*PERIOD,data=...) xyplot will generate all the possible ID*PERIOD combinations. But not all of them have data in there. So I have a lot of empty plots. How can I suppress those empty plots and ask xyplot only to generate plots actually with data. Tha

Re: [R] 3 Y axis possible?

2011-05-27 Thread Jun Shen
Thanks for sharing the idea, Walmes. I am also trying to add err bars to the plots. So instead of using plot(), I use errbar() from Hmisc package. Everything seems to work fine except I couldn't find the argument to control the color of error bars. If I specify col='red' in the errbar() it only co

Re: [R] Put names in the elements of lapply result

2011-05-27 Thread Jun Shen
7;,'KOUT','GAMMA'),function(x)confint(lm(get(x)~RR0,dataset2))) > names(dat) <- c('EMAX','EC50','KOUT','GAMMA') > > On Fri, May 27, 2011 at 10:03 AM, Jun Shen wrote: > > Dear list, > > > > I am running

[R] Put names in the elements of lapply result

2011-05-27 Thread Jun Shen
(Intercept) -7.75121986 15.20827567 RR0 -0.01174097 0.02220318 Thanks a lot. Jun Shen = structure(list(ID = c(50, 51, 52, 53, 55, 56, 57, 59, 60, 61, 100, 101, 104, 107, 108, 110, 112, 114), KOUT = c(3.8336, 3.7519, 3.7136, 3.

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
Thanks a bunch, Walmes. One more concern, the new Y axes added do not extend all the way down to cross with x axis. Is there anyway to make them look like the very first Y axis on the left? Jun On Thu, May 26, 2011 at 1:24 PM, Walmes Zeviani wrote: > You can use mtext() > > par(mar=c(5.1,4.1,4.

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
David, I surely tried the labels argument. But it seems for tick marks not for a text label. Did you see a different outcome? Thanks. Jun On Thu, May 26, 2011 at 12:38 PM, David Winsemius wrote: > > On May 26, 2011, at 1:25 PM, Jun Shen wrote: > > Jim, >> >> One more

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
= '', col = > 'blue') > axis(4, col='blue', line = -3) > > > You have to not plot the axises on the secondary plots. > > On Thu, May 26, 2011 at 12:11 PM, Jun Shen wrote: > > Hi, Jim, > > > > Thanks fo

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
I just found out by setting bty='l' to get rid of the border line on the top. On Thu, May 26, 2011 at 11:41 AM, Jun Shen wrote: > Hi, jim > > That's exactly what I wanted. One more trivial thing. How do I get rid the > border line on the top? Thanks again. > >

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
#x27;', col = > 'blue') > axis(4, col='blue', line = -3) > > > You have to not plot the axises on the secondary plots. > > On Thu, May 26, 2011 at 12:11 PM, Jun Shen wrote: > > Hi, Jim, > > > > Thanks fo

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
confusing, but it can be done. What have you tried and why > do you say "guess not"? With the use of par(new=TRUE) or by doing > your own scaling, you can use 'axis' to put as many axises as you want > on your graph. > > On Thu, May 26, 2011 at 11:35 AM, Jun

[R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
Dear list, We have three time course profiles with very different scales, and we want to show them in one plot. Is it possible to have three y axis? I guess not, then what would be other options? something like two 2-y axis plots on a three dimensional view? Appreciate any comment. Jun Shen

Re: [R] Weird read.xls behavior

2011-05-10 Thread Jun Shen
Hi, Gabor, The interim fix solved the problem! Now it's working perfectly. And thanks for everyone's input. Jun On Tue, May 10, 2011 at 10:39 AM, Gabor Grothendieck < ggrothendi...@gmail.com> wrote: > On Tue, May 10, 2011 at 12:12 AM, Jun Shen wrote: > > Kenneth, >

Re: [R] Weird read.xls behavior

2011-05-10 Thread Jun Shen
sub > function. > > HTH > > Kenneth > El lun, 09-05-2011 a las 22:44 -0500, Jun Shen escribió: > > Dear list, > > > > I used read.xls to read in an excel file, which has both character and > > numeric columns. Everything seems fine except in the last column,

Re: [R] Weird read.xls behavior

2011-05-09 Thread Jun Shen
e first and the last white spaces with gsub > function. > > HTH > > Kenneth > El lun, 09-05-2011 a las 22:44 -0500, Jun Shen escribió: > > Dear list, > > > > I used read.xls to read in an excel file, which has both character and > > numeric columns. Every

[R] Weird read.xls behavior

2011-05-09 Thread Jun Shen
Dear list, I used read.xls to read in an excel file, which has both character and numeric columns. Everything seems fine except in the last column, I have this character value "ng/ml". When reading in, read.xls seems to add a space at the end of it, became "ng/ml ". How can I prevent read.xls doin

[R] Change the names of a dataframe

2011-05-03 Thread Jun Shen
Dear list, This may sound silly. What is the right way to change the names of a dataframe? Let's say I have this data frame (dose) with four columns with names "ID", "DOSE", "TIME" "CMT". I want to change "DOSE" to "AMT". So I did names(dose[2])<-'AMT' But nothing happened. The name of the secon

Re: [R] Use nparcomp function from nparcomp library to run post hoc

2011-04-30 Thread Jun Shen
Apr 30, 2011 at 6:12 AM, David Winsemius wrote: > > On Apr 29, 2011, at 7:17 PM, Jun Shen wrote: > > Hi, Dennis, >> >> Thanks for the reply. I tried to upgrade to R 2.13.0. Then when I tried to >> load the library(nparcomp), I got an error >> >> Error: pack

Re: [R] Use nparcomp function from nparcomp library to run post hoc

2011-04-29 Thread Jun Shen
] base > > other attached packages: > [1] nparcomp_1.0-1 multcomp_1.2-5 survival_2.36-9 mvtnorm_0.9-999 > [5] sos_1.3-0 brew_1.0-6 plyr_1.5.2 > > loaded via a namespace (and not attached): > [1] tcltk_2.13.0 tools_2.13.0 > > Check your version of R and the npar

[R] Use nparcomp function from nparcomp library to run post hoc

2011-04-29 Thread Jun Shen
Dear list, I tried to use the nparcomp to run some post hoc non-parametric comparison and got and error. Error in uniroot(pfct, interval = interval) : f() values at end points not of opposite sign Appreciate any comments. the command line: >nparcomp(Ulceration~Group,data=test,type='Dunnett'

Re: [R] Extract information from the names of a list within lapply

2011-04-15 Thread Jun Shen
call()[[2]][[3]]]) > > On Fri, Apr 15, 2011 at 3:14 PM, Jun Shen wrote: > > Dear list, > > > > I want to loop over a list through lapply and at the same time I want to > > extract some information from the names of the list elements. lapply does > > not seem

[R] Extract information from the names of a list within lapply

2011-04-15 Thread Jun Shen
Dear list, I want to loop over a list through lapply and at the same time I want to extract some information from the names of the list elements. lapply does not seem to carry the names. Is there anyway to access the names of a list within lapply? Thanks. Jun [[alternative HTML version d

[R] is this matrix symmetric

2010-11-06 Thread Jun Shen
Hi, I have this symmetric matrix, at least I think so. col1 col2 col3 [1,] 0.20 0.05 0.06 [2,] 0.05 0.10 0.03 [3,] 0.06 0.03 0.08 or structure(c(0.2, 0.05, 0.06, 0.05, 0.1, 0.03, 0.06, 0.03, 0.08 ), .Dim = c(3L, 3L), .Dimnames = list(NULL, c("var1", "var2", "var3"))) But isSymmetric() d

Re: [R] Unable to retrieve residual sum of squares from nls output

2010-08-13 Thread Jun Shen
Hi, Dennis, Does this give what you want? >sum(resid(FIT)^2) Jun Senior Pharmacokineticist Seventh Wave Labs On Fri, Aug 13, 2010 at 4:21 PM, Dennis Fisher wrote: > Colleagues, > > I am using "nls" successfully (2.11.1, OS X) but I am having difficulties > retrieving part of the output - resi

Re: [R] Exporting nlme summary

2010-08-05 Thread Jun Shen
;t see it on the screen. Say >summary(horton.nlme) give the output back to console >sink() Hope this helps. Jun Shen Senior Pharmacokineticist Seventh Wave Labs On Thu, Aug 5, 2010 at 2:30 PM, Ronald Wendt wrote: > I'm trying to export the results of my summary data for the o

Re: [R] How to fix slope and estimate intercept

2010-07-22 Thread Jun Shen
Hi, Bill, Thanks. This is what I am looking for. Jun On Thu, Jul 22, 2010 at 1:54 PM, William Dunlap wrote: >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of Jun Shen >> Sent: Thursday, July 22, 201

[R] How to fix slope and estimate intercept

2010-07-22 Thread Jun Shen
Dear all, Is there anyway I can fix slope in some value and only estimate intercept for a linear regression? I understand lm(y~1, data) will NOT have a slope at all. This is not what I want. Thanks. Jun __ R-help@r-project.org mailing list https://stat

Re: [R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Jun Shen
Hi, Juliet, Something like this? mymat[mymat<0]<-min(mymat[mymat>0]) Jun On Thu, Jul 15, 2010 at 10:55 AM, Juliet Hannah wrote: > Hi Group, > > I have a matrix, and I would like to replace numbers less than 0 by > the smallest minimum number. Below is an > small matrix, and the loop I used. I

Re: [R] What is the degrees of freedom in an nlme model

2010-07-12 Thread Jun Shen
issues. > > Bottom line: there may be no good way to do what you want. > > Note to experts: Please view this post as an invitation to correct my errors > and provide authoritative info. > > Cheers to all, > > Bert > > Bert Gunter > Genentech Nonclinical Biostatist

[R] What is the degrees of freedom in an nlme model

2010-07-12 Thread Jun Shen
Dear all, I want to do a F test, which involves calculation of the degrees of freedom for the residuals. Now say, I have a nlme object "mod.nlme". I have two questions 1.How do I extract the degrees of freedom? 2.How is this degrees of freedom calculated in an nlme model? Thanks.

Re: [R] make an model object (e.g. nlme) available in a user defined function (xyplot related)

2010-07-12 Thread Jun Shen
6, 2.99, 3.75, 3.02, 5.44, 3.08, 8.31, 10.85, 13.79, 32.06, 50.22, 63.7, 81.34, 89.59, 93.06, 92.47, 3.32, 1.14, 2.43, 2.75, 3.02, 5.4, 8.49, 7.91, 15.17, 35.01, 53.91, 68.51, 83.12, 86.85, 92.17, 95.72, 3.58, 0.02, 3.69, 4.34, 6.32, 5.15, 9.7, 11.39, 23.38, 42.9, 61.91, 71.82, 87.83)), .Names

[R] make an model object (e.g. nlme) available in a user defined function (xyplot related)

2010-07-11 Thread Jun Shen
efined function. It seems the "mod.nlme" created in a user defined function can not be called in xyplot(). Why is that? Appreciate any comment. (The error message says " Error in using packet 1, object "model" not found") Thanks. Jun Shen ___

[R] How to automatically restart nlme in a user-defined function

2010-07-10 Thread Jun Shen
in a positive definite diagonal matrix by: random = list(pdDiag(a+b~1)) My question is how I can restart nlme within my function. If random = a+b~1 fails, it won't quit and will go back to try random = list(pdDiag(a+b~1)) automatically. Currently I just have to do this manually. Thanks a lot.

Re: [R] Sampling with replacement

2010-06-16 Thread Jun Shen
sample(1:20,4,replace=TRUE) should do it. Jun On Wed, Jun 16, 2010 at 9:20 AM, Somnath Somnath wrote: > Dear all, good morning, > > I have a population, let say members are tagged with some simple number > like > 1,2,3,...20. I want to draw a sample with replacement of size 4 (say, can > be > mo

Re: [R] how to save multiple plots in one PDF file?

2010-05-17 Thread Jun Shen
width=5, height=5) > > which shouldn't be there. > > HTH, > > baptiste > > On 17 May 2010 22:23, Jun Shen wrote: >> If you do plotting in a loop, then you need to print it to the device. >> >> print(plot(xj,y)) >> >> On Mon, May 17, 2010

Re: [R] how to save multiple plots in one PDF file?

2010-05-17 Thread Jun Shen
ause it has no pages." > > Here is what I did in plotting and saving the file: > > pdf(file="C:/figure.pdf") > for (j in 1:numColumns) > { > windows(width=5, height=5) > > plot(xj,y) > } > dev.off() > > Any ideas what might cause the problem? Th

Re: [R] how to save multiple plots in one PDF file?

2010-05-17 Thread Jun Shen
1.Open pdf device >pdf() 2.Do your plotting as many as you want, you won't see the plots on the screen because they go directly to the pdf() device. 3.Turn off the pdf() >dev.off() Then you can review your plots in the pdf file. For more details see ?pdf Jun On Mon, May 17, 2010 at 2:41 PM, Shirl

Re: [R] How to pass value to an argument in a function which is an argument to the main function

2010-05-07 Thread Jun Shen
, 7L, 12L, 15L, 21L, 27L, 33L, 39L, 45L, 48L, 54L, 60L, 65L, 67L, 71L, 76L, 81L, 86L, 91L, 93L, 98L, 103L, 108L, 112L), class = "data.frame") On Fri, May 7, 2010 at 7:51 PM, David Winsemius wrote: > > On May 7, 2010, at 5:05 PM, David Winsemius wrote: > > >> On May 7, 2010

Re: [R] How to pass value to an argument in a function which is an argument to the main function

2010-05-07 Thread Jun Shen
} conf <- if (do.conf) stats[3L] + c(-1.58, 1.58) * iqr/sqrt(n) list(stats = stats, n = n, conf = conf, out = if (do.out) x[out & nna] else numeric(0L)) } On Fri, May 7, 2010 at 3:09 PM, David Winsemius wrote: > > On May 7, 2010, at 3:30 PM, Jun Shen w

[R] How to pass value to an argument in a function which is an argument to the main function

2010-05-07 Thread Jun Shen
; the part of the args list of 'is.na' being evaluated was: (x) Thanks a lot. Jun Shen from Millipore Corporation my.boxplot.stats<-function (x, coef = 1.5, *type=6*, do.conf = TRUE, do.out = TRUE) { if (coef < 0)

Re: [R] How to stamp my graphs with date and time

2010-04-24 Thread Jun Shen
ny other letter. Can anyone explain it a little bit? Jun On Sat, Apr 24, 2010 at 4:14 PM, David Winsemius wrote: > > On Apr 24, 2010, at 4:52 PM, Jun Shen wrote: > > Hi, >> >> I also want to show user's name at the lower-left corner. So I added one >> more

Re: [R] How to stamp my graphs with date and time

2010-04-24 Thread Jun Shen
Hi, I also want to show user's name at the lower-left corner. So I added one more line to Deepayan's code but it didn't work. I am not sure how to use the "page" argument here. Appreciate any comment. lattice.options(default.args = list(page = function(n) { panel.text(lab = sprintf("%s", date(

Re: [R] How to stamp my graphs with date and time

2010-04-23 Thread Jun Shen
Hi, Deepayan, This is exactly what I want. However I couldn't find "page" argument or "default.args" when I look up the documentation. I just want to learn a bit more how to use these arguments. Thanks again. Jun On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar wrote: > On Wed, Apr 21, 2010 a

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread Jun Shen
David, Duncan, Thanks. I didn't realize the functions in "graphic" also work in "lattice". I thought they didn't work with each other. Jun On Wed, Apr 21, 2010 at 6:51 PM, Duncan Murdoch wrote: > On 21/04/2010 5:41 PM, Jun Shen wrote: > >> Dear all,

  1   2   >