Re: [R] get latest dates for different people in a dataset

2015-01-25 Thread Göran Broström
On 2015-01-24 01:14, William Dunlap wrote: Here is one way. Sort the data.frame, first by Name then break ties with CheckInDate. Then choose the rows that are the last in a run of identical Name values. I do it by sorting by the reverse order of CheckinDate (last date first) within Name,

Re: [R] extracting significance test for individual lm() parameters after using by

2015-01-25 Thread Michael Dewey
Dear Jerad I may have completely misunderstood your question but you do know that you can write your own function and use it in sapply where you have summary? You could incorporate calls to summary or to coef or somet other extractor or you could use the $ tool. On 25/01/2015 02:01, Moxley,

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

2015-01-25 Thread Bert Gunter
Jun: Call a custom panel function that adds horizontal lines at the means of your groups. Something like (for vertical boxes, i.e.horiz=FALSE; make appropriate change for horizontal boxes) e.g. panel.mn - function(x,y,box.width=.5,horiz=FALSE,...){ panel.bwplot(x,y,box.width,horiz=horiz,...)

Re: [R] get latest dates for different people in a dataset

2015-01-25 Thread William Dunlap
dLatestVisit - dSorted[!duplicated(dSorted$Name), ] I guess it is faster, but who knows? You can find out by making a function that generates datasets of various sizes and timing the suggested algorithms. E.g., makeData - function(nPatients, aveVisitsPerPatient, uniqueNameDate = TRUE){

[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

Re: [R] extracting significance test for individual lm() parameters after using by

2015-01-25 Thread David Winsemius
On Jan 24, 2015, at 11:02 PM, Moxley, Jerad wrote: Sorry I was not clearer, but I was asking an R programming question not a theory question. Copying back the original text which appears to have been omitted: On 25/01/2015 02:01, Moxley, Jerad wrote: I’m trying to test what growth

Re: [R] plot in one unique x,y axis

2015-01-25 Thread Duncan Murdoch
On 25/01/2015 2:38 PM, Dr. Alireza Zolfaghari wrote: Hi there, does any one know how to plot the both d1 and d2 data in one unique x and y axis? Use plot() for the first call, and points() for the second one. You may need to specify xlim and/or ylim explicitly in the first call to be sure

Re: [R] plot in one unique x,y axis

2015-01-25 Thread Jim Lemon
Hi Dr. Zolfaghari, Given that the probability of practically the same unusual question coming from two people in quick succession is tiny unless it is about a homework question, I was probably conned into answering a homework question a day or two ago. Of course by the time I had decoded your

Re: [R] Sum function and missing values --- need to mimic SAS sum function

2015-01-25 Thread Jim Lemon
Hi Allen, How about this: sum_w_NA-function(x) ifelse(all(is.na(x)),NA,sum(x,na.rm=TRUE)) Jim On Mon, Jan 26, 2015 at 10:21 AM, Allen Bingham aebingh...@gmail.com wrote: I understand that in order to get the sum function to ignore missing values I need to supply the argument na.rm=TRUE.

Re: [R] Looking for an R package for Set Cover Problem

2015-01-25 Thread Hans W Borchers
As the Wikipedia page you took your example problem from explains, the sets cover problem can be formulated as an integer linear programming problem. In R, such problems will be solved effectively applying one of the available MILP packages, for example LPsolve or Rsymphony. Kumar Mainali

[R] Sum function and missing values --- need to mimic SAS sum function

2015-01-25 Thread Allen Bingham
I understand that in order to get the sum function to ignore missing values I need to supply the argument na.rm=TRUE. However, when summing numeric values in which ALL components are NA ... the result is 0.0 ... instead of (what I would get from SAS) of NA (or in the case of SAS .). Accordingly,

Re: [R] Sum function and missing values --- need to mimic SAS sum function

2015-01-25 Thread John Fox
Dear Allen, This seems reasonably straightforward to me, suggesting that I might not properly understand what you want to do. How about something like the following? mysum - function(...){ + x - c(...) + if (all(is.na(x))) NA else sum(x, na.rm=TRUE) + } mysum(1, 2, 3, NA) [1] 6

[R] plot in one unique x,y axis

2015-01-25 Thread Dr. Alireza Zolfaghari
Hi there, does any one know how to plot the both d1 and d2 data in one unique x and y axis? thanks Alireza convertToRadius-function(x){return(sqrt(x/pi))} myd=data.frame(x=c(84390255386 ,74390255386, 78028317380 ,53594648044,422) ,y=c(949849442 ,941645043, 840135292, 74,

Re: [R] get latest dates for different people in a dataset

2015-01-25 Thread Göran Broström
See inline; On 2015-01-25 20:27, William Dunlap wrote: dLatestVisit - dSorted[!duplicated(dSorted$__Name), ] I guess it is faster, but who knows? You can find out by making a function that generates datasets of various sizes and timing the suggested algorithms. E.g., makeData -