[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

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

2017-06-30 Thread Jun Shen
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, 53L, 100L, 52L, 9L, 6

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

2016-09-25 Thread Jun Shen
=-0.5, label="very > interesting")) > >> > >> xyplot(y ~ x, data=tmp, main="outside text displayed", > >>par.settings=list(clip=list(panel=FALSE)) ## permit text > >> outside the panel > >> ) + > >> ##

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

2016-09-25 Thread Jun Shen
ut best fitting coordinates. > > > > Via 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

[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

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

2016-09-09 Thread Jun Shen
, '3.mg.kg.>110.kg.P05' > , '240.m.g.>50-70.kg.geo.mean' > ) > # based on your literal idea > suggested.pattern1 <- > "(240\\.m\\.g|3\\.mg\\.kg)\\.(>50-70\\.kg|>70-90\\.kg|>90-11 > 0\\.kg|50\\.kg\\.or\\.less|>110\\.kg)\\.(.*)&

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

2016-09-08 Thread Jun Shen
read. 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 <istaz...@gmail.com> wrote: > On Tue, Sep 6, 2016 at 11:59 PM, Jun Shen <jun.shen...@gmail.co

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

2016-09-06 Thread Jun Shen
) 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, Se

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

2016-09-06 Thread Jun Shen
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 in his

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

2016-09-06 Thread Jun Shen
ooks 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 in his "Bloom County&q

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 > > [1] &qu

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

2016-09-05 Thread Jun Shen
On Sun, Sep 4, 2016 at 9:30 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> > wrote: > > Your opening assertion is false. > > > > Provide a reproducible example and someone will demonstrate. > > -- > > Sent from my phone. Please excuse my brevity. > > > >

[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
skip the > tapply 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 "

[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

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 <dwinsem...@comcast.net> wrote: > > > On Jul 29, 2016, at 5:52 PM, David Winsemius <dwinsem...@comcast.net> > wrote: > > > > > >> On Jul 29, 2016, at 5:

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

2016-07-29 Thread Jun Shen
gt; > On Jul 28, 2016, at 7:37 PM, Jun Shen <jun.shen...@gmail.com> wrote: > > > > Because in reality the NA may appear in one variable but not others. For > > example for ID=1, CL may be NA but not for others, For ID=2, V1 may be NA > > etc. To keep all the IDs and al

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

2016-07-28 Thread Jun Shen
<jdnew...@dcn.davis.ca.us> 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 <jun.shen...@gmail.com> wrote: > >Dear list, > > > >I

[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)

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 <ulrik.ster...@gmail.com> wrote: > use gsub() > > On Fri, 27 May 2016 at 17:12 Jun

[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

[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

Re: [R] string split problem

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

[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
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 [[alternative HTML version deleted

[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

[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.

[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

[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] 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 e...@enricoschumann.net wrote: On Thu, 28 Aug 2014, Jun Shen jun.shen...@gmail.com writes: Hi everyone, I believe I am not the first one to have this problem

[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

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

2014-08-21 Thread Jun Shen
Nominal Relative Time $ TIME:Class 'labelled' atomic [1:1991] -1.1 0.8 1.5 3 4 ... .. ..- attr(*, label)= chr Actual Relative Time On Thu, Aug 21, 2014 at 11:53 AM, David Winsemius dwinsem...@comcast.net wrote: On Aug 21, 2014, at 7:20 AM, Jun Shen wrote: Dear list, I used sasxport.get

[R] Data extraction and assembly from a data frame

2014-06-20 Thread Jun Shen
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/mailman/listinfo/r-help

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

2014-06-20 Thread Jun Shen
:43 PM, Jun Shen jun.shen...@gmail.com 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),VAR3=10*rnorm(100)) Basically, I want to extract

[R] How to draw a transparent polygon

2014-05-21 Thread Jun Shen
() 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-project.org

Re: [R] How to draw a transparent polygon

2014-05-21 Thread Jun Shen
of Anthropology Texas AM University College Station, TX 77840-4352 -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 draw a transparent

[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,

[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

[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

[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

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

2013-12-05 Thread Jun Shen
: ... or, more simply lm(z ~ polym(x,y, degree=2) ) ?polym Cheers, Bert On Wed, Dec 4, 2013 at 10:30 AM, David Winsemius dwinsem...@comcast.net wrote: On Dec 4, 2013, at 8:56 AM, Duncan Murdoch wrote: On 04/12/2013 11:36 AM, Jun Shen wrote: Hi, I have a dataset with two independent

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 murdoch.dun...@gmail.comwrote: On 05/12/2013 10:33 AM, Jun Shen wrote: Hi Federico/Duncan/David

[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

[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

[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

[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

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

2013-08-09 Thread Jun Shen
%H:%M')) The result is in seconds. On Fri, Aug 9, 2013 at 1:55 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 9, 2013, at 10:37 AM, Jun Shen wrote: Hi all, I used strptime() to convert character strings to time and did some subtraction calculation. a-'2012-07-17T07:50

[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

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

2012-05-11 Thread Jun Shen
. 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 http://www.R-project.org/posting-guide.html and provide commented

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

2012-05-09 Thread Jun Shen
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 list https

[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 ==

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

2012-04-16 Thread Jun Shen
Ehlers ehl...@ucalgary.ca 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 adjust the distance between the legend and the plot? The default setting

[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

[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] 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.

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

2012-02-14 Thread Jun Shen
#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Jun Shen jun.shen...@gmail.com wrote: Dear all, In a plot command like xyplot(Y~X|ID

[R] Put names in the elements of lapply result

2011-05-27 Thread Jun Shen
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.3477, 4.9429, 4.495, 3.4988, 3.7722, 3.6962, 4.1295, 3.7326, 3.1477, 4.0665, 4.9775, 3.9306

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

2011-05-27 Thread Jun Shen
'),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 jun.shen...@gmail.com wrote: Dear list, I am running some linear regressions through lapply, lapply(c('EMAX','EC50','KOUT','GAMMA'),function(x)confint(lm(get

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

[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] 3 Y axis possible?

2011-05-26 Thread Jun Shen
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 Shen jun.shen...@gmail.com wrote: Dear list, We have three time course profiles with very

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
, 2011 at 12:11 PM, Jun Shen jun.shen...@gmail.com wrote: Hi, Jim, Thanks for the information. But I am still not clear how to show the 3 separated Y axis. If I just call par(new=TRUE), the three axes are overlapped. attached some test data. Thanks. Jun

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 jun.shen...@gmail.com 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. Jun On Thu, May

Re: [R] 3 Y axis possible?

2011-05-26 Thread Jun Shen
, May 26, 2011 at 12:11 PM, Jun Shen jun.shen...@gmail.com wrote: Hi, Jim, Thanks for the information. But I am still not clear how to show the 3 separated Y axis. If I just call par(new=TRUE), the three axes are overlapped. attached some test data. Thanks. Jun

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 dwinsem...@comcast.netwrote: On May 26, 2011, at 1:25 PM, Jun Shen wrote: Jim, One more question

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 walmeszevi...@gmail.comwrote: You can use mtext()

Re: [R] Weird read.xls behavior

2011-05-10 Thread Jun Shen
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, I have this character value ng/ml. When reading in, read.xls seems to add a space at the end of it, became

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 jun.shen...@gmail.com wrote: Kenneth, Thanks

[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 doing

Re: [R] Weird read.xls behavior

2011-05-09 Thread Jun Shen
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. Everything seems fine except in the last column, I have this character value ng/ml. When reading

[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 second column is

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

2011-04-30 Thread Jun Shen
, 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: package 'mvtnorm' is not installed for 'arch=i386' What does that mean? Thanks. You can see from Dennis' console

[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:

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

2011-04-29 Thread Jun Shen
, Dennis On Fri, Apr 29, 2011 at 2:49 PM, Jun Shen jun.shen...@gmail.com wrote: 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

[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

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

2011-04-15 Thread Jun Shen
)[match.call()[[2]][[3]]]) On Fri, Apr 15, 2011 at 3:14 PM, Jun Shen jun.shen...@gmail.com 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 to carry the names

[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()

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 fis...@plessthan.com wrote: Colleagues, I am using nls successfully (2.11.1, OS X) but I am having difficulties retrieving part of the

Re: [R] Exporting nlme summary

2010-08-05 Thread Jun Shen
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 rnldwe...@gmail.com wrote: I'm trying to export the results of my summary data for the object horton.nlme, but failing

[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

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 wdun...@tibco.com 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, 2010 10:30 AM

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

2010-07-15 Thread Jun Shen
Hi, Juliet, Something like this? mymat[mymat0]-min(mymat[mymat0]) Jun On Thu, Jul 15, 2010 at 10:55 AM, Juliet Hannah juliet.han...@gmail.com 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

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

2010-07-12 Thread Jun Shen
)), .Names = c(ID, CP, RESP), class = data.frame, row.names = c(NA, -125L)) == On Mon, Jul 12, 2010 at 1:05 AM, Deepayan Sarkar deepayan.sar...@gmail.com wrote: On Mon, Jul 12, 2010 at 2:51 AM, Jun Shen jun.shen...@gmail.com wrote: Dear

[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. Jun Shen Some

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

2010-07-11 Thread Jun Shen
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-help@r-project.org mailing

[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. Jun

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 somnath700...@gmail.comwrote: 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

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,

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

2010-05-17 Thread Jun Shen
because 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? Thanks! On Mon, May 17, 2010 at 12:52 PM, Jun Shen jun.shen...@gmail.com

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

2010-05-17 Thread Jun Shen
, windows(width=5, height=5) which shouldn't be there. HTH, baptiste On 17 May 2010 22:23, Jun Shen jun.shen...@gmail.com 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 at 3:02 PM, Shirley Bao baoxi...@gmail.com wrote

[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
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) stop('coef' must not be negative

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
(stats = stats, n = n, conf = conf, out = if (do.out) x[out nna] else numeric(0L)) } environment: namespace:grDevices On Fri, May 7, 2010 at 3:09 PM, David Winsemius dwinsem...@comcast.netwrote: On May 7, 2010, at 3:30 PM, Jun Shen wrote: Dear all, I constructed this function

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
7, 2010 at 7:51 PM, David Winsemius dwinsem...@comcast.netwrote: On May 7, 2010, at 5:05 PM, David Winsemius wrote: On May 7, 2010, at 4:18 PM, Jun Shen wrote: David, my.boxplot.stats is modified from boxplot.stats (package grDevices) as follows. x is the original argument, I guess it's

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-24 Thread Jun Shen
it a little bit? Jun On Sat, Apr 24, 2010 at 4:14 PM, David Winsemius dwinsem...@comcast.netwrote: 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 line to Deepayan's code but it didn't work. I am not sure how to use

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 deepayan.sar...@gmail.com wrote:

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

2010-04-21 Thread Jun Shen
Dear all, How do stamp my graphs with date and time somewhere like left corner of the graph (not the plotting area). I know date() and Sys.time(), but where to? Thanks. Jun [[alternative HTML version deleted]] __ R-help@r-project.org mailing

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

2010-04-21 Thread Jun Shen
Thanks, David. mtext is for graphics. Is there an equivalent function for lattice? Jun On Wed, Apr 21, 2010 at 4:44 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 21, 2010, at 5:41 PM, Jun Shen wrote: Dear all, How do stamp my graphs with date and time somewhere like left

  1   2   >