[R] Subscripting

2010-02-10 Thread GL
Dataframe1 contains a list of specific dates. Dataframe2 contains a large dataset, one element of which is Date. How do I create a subset of Dataframe2 that excludes the dates from Dataframe1? I know how to do it with a left outer join vs null in SQL, but I can't figure out how to do it more direc

[R] AHRQ Patient Quality Indicators

2010-03-31 Thread GL
Is anyone aware of R code that mimic's AHRQ's SAS code for their Prevention Quality Indicators (PQI)? Don't see it anywhere, but wanted to see if anyone else knew of anything. Many thanks -- View this message in context: http://n4.nabble.com/AHRQ-Patient-Quality-Indicators-tp1747243p1747243.

[R] Correcting for missing data combinations

2009-12-11 Thread GL
I can think of many brute-force ways to do this outside of R, but was wondering if there was a simple/elegant solution within R instead. I have a table that looks something like the following: Factor1 Factor2 Value A 11/11/2009 5 A 11/12/2009 4 B 11/11/2009

[R] Limiting number of tickmarks in lattice bwplot

2010-01-11 Thread GL
Have a simple bwplot with 24 ordered factors across the x axis. I would like to only label every 4th tick mark so that the labels fit. I tried scales=list(x=list(tick.number=6)), but I still seem to get 24 tickmarks and 24 labels. Full code is below: bwplot(SumOfIn.Use ~ Hour | Period, scales=li

[R] Question on Merge/Lookup

2010-01-22 Thread GL
I need to merge three datasets and don't know how. If I were using SQL, I would use df3, look up the characteristics of each date in df1 and the value for each observation in df2. df1 - unique list of Dates and characteristics of those dates Date, MM, WW, DOW df2 - the raw data Date,

[R] question on sqldf syntax

2010-01-25 Thread GL
trying to structure sql to merge two datasets. structure follows: dbs.possible.combos (all possible combinations of dates and places) Date Place 1/1/10 N-01 1/1/10 S-02 1/2/10 N-01 1/2/10 S-02 etc... dbs.aggregate (the raw data aggregated by date and location) Date Place Days 1/1/10 N-01 6 1/1/1

Re: [R] question on sqldf syntax

2010-01-25 Thread GL
Actually, better sql would likely be: dbs.final <- sqldf("select * from dbs.possible.combos left join dbs.aggregate using (Date,Place)") but this still doesn't work -- View this message in context: http://n4.nabble.com/question-on-sqldf-syntax-tp1289707p1289718.html Sent from the R help maili

[R] Print lattice output to table?

2010-01-28 Thread GL
I have beautiful box and whisker charts formatted with lattice, which is obviously calculating summary statistics internally in order to draw the charts. Is there a way to dump the associated summary tables that are being used to generate the charts? Realize I could use tapply or such to get somet

[R] tapply on multiple groups

2010-01-28 Thread GL
Can you make tapply break down groups similar to bwplot or such? Example: Data frame has one measure (Days) and two Dimensions (MM and Place). All have the same length. > length(dbs.final$Days) [1] 3306 > length(dbs.final$Place) [1] 3306 > length(dbs.final$MM) [1] 3306 Doing the followi

Re: [R] Print lattice output to table?

2010-01-28 Thread GL
That works great. Thanks! -- View this message in context: http://n4.nabble.com/Print-lattice-output-to-table-tp1375040p1380862.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mai

[R] Are any values in one list contained within a second list

2010-06-13 Thread GL
Silly question, but, can I test to see if any value of list a is contained in list b without doing a loop? A loop is easy enough, but wanted to see if there was a cleaner way. By way of example: List 1: a, b, c, d, e, f, g List 2: z, y, x, w, v, u, b Return true, since both lists contain b Lis

[R] Question about user define function

2010-06-15 Thread GL
Have the following function that is called by the statement below. Trying to return the two dataframes, but instead get one large list including both tables. ReadInputDataFrames <- function() { dbs.this= read.delim("this.txt", header = TRUE, sep = "\t", quote="\"", dec=".") dbs.that= read.

[R] Return value associated with a factor

2010-06-21 Thread GL
I am using the code below to extract census tract information. save.tract$state, save.tract$county and save.tract$tract are returned as factors. In the last three statements, I need to save the actual value of the factor, but, instead, the code is yielding the position of the factor. How do I inst

Re: [R] Return value associated with a factor

2010-06-21 Thread GL
Works great. Thanks much! -- View this message in context: http://r.789695.n4.nabble.com/Return-value-associated-with-a-factor-tp2262605p2262656.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:

[R] Basic question - more efficient method than loop?

2010-06-28 Thread GL
I'm guessing there's a more efficient way to do the following using the index features of R. Appreciate any thoughts for (i in 1:nrow(dbs1)){ if(dbs1$Payor[i] %in% Payor.Group.Medicaid) dbs1$Payor.Group[i] = "Medicaid" if(dbs1$Payor[i] %in% Payor.Group.Medicare) dbs1$Payor.Group[i] =

Re: [R] Basic question - more efficient method than loop?

2010-06-28 Thread GL
Perfect. Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Basic-question-more-efficient-method-than-loop-tp2271096p2271153.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:/

[R] Remove observations deemed influential by influential.measure

2010-06-29 Thread GL
dbs is an existing dataframe. I fit a lm and looked at influential observations. I want now to delete the influential observations from dbs, fit another lm, and see how different the results are. What is the syntax to remove the influential observations from dbs? fit <- lm(NI ~ PG + log(TG), data

Re: [R] Remove observations deemed influential by influential.measure

2010-06-29 Thread GL
dbs_influential_obs <- which(apply(fit.influential.observations$is.inf, 1, any)) dbs_sans_influential_obs <- dbs1[-dbs_influential_obs,] -- View this message in context: http://r.789695.n4.nabble.com/Remove-observations-deemed-influential-by-influential-measure-tp2272474p2272524.html Sent from

[R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL
Have a long script that runs fine on windows (32 bit). When I try to run in on two different macs (64 bit), however, it hangs with identical behavior. I start with: library(sqldf) This results in messages: Loading required package: DBI Loading required package: RSQLite Loading required package:

Re: [R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL
added library(RH2) Still get message: Loading required package: tcltk Loading Tcl/Tk interface + directly after sqldf statement > df.final <- sqldf('select Date, Hour, x as RoomsInUse from > "df.possible.combos" + left join "df.aggregate" using (Hour, Date)') There is no progress s

Re: [R] sqldf hanging on macintosh - works on windows

2010-11-01 Thread GL
> > library(sqldf) Loading required package: DBI Loading required package: RSQLite Loading required package: RSQLite.extfuns Loading required package: gsubfn Loading required package: proto Loading required package: chron > debug(sqldf) > df.final <- sqldf('select Date, Hour, x as RoomsInUse

Re: [R] sqldf hanging on macintosh - works on windows

2010-11-02 Thread GL
Marc: Installing Simon's package worked perfectly. Thanks so much! -- View this message in context: http://r.789695.n4.nabble.com/sqldf-hanging-on-macintosh-works-on-windows-tp3022193p3023736.html Sent from the R help mailing list archive at Nabble.com.

[R] class changed after execution with sqldf

2010-11-02 Thread GL
When I run sqldf to merge two datasets, it's changing the Date (class date) to a numeric value (class factor). Not sure why. Appreciate any insight. Console output for two datasets and the merged dataset (via sqldf) listed below. > summary(df.aggregate) Date Hour

Re: [R] class changed after execution with sqldf

2010-11-02 Thread GL
Forgot to mention. This works in the PC implementation of R. The results I'm seeing here are in Mac OS X with X11 and tcl/tk installed. -- View this message in context: http://r.789695.n4.nabble.com/class-changed-after-execution-with-sqldf-tp3024592p3024602.html Sent from the R help mailing lis

[R] REmove level with zero observations

2010-08-03 Thread GL
If I have a column with 2 levels, but one level has no remaining observations. Can I remove the level? Had intended to do it as listed below, but soon realized that even though there are no observations, the level is still there. For instance summary(dbs3.train.sans.influential.obs$HAC) yie

Re: [R] REmove level with zero observations

2010-08-03 Thread GL
Ended up working as follows: dbs3.train.sans.influential.obs <- drop.levels(dbs3.train.sans.influential.obs) drop.list <- NULL for (i in 4:ncol(dbs3.train.sans.influential.obs)) { if (nlevels(dbs3.train.sans.influential.obs[,i]) < 2) {drop.list <- cbind(drop.list,i)}} dbs3.train.san

[R] sapply/lapply instead of loop

2010-08-10 Thread GL
Using the input below, can I do something more elegant (and more efficient) than the loop also listed below to pad strings to a width of 5? The true matrix is about 300K rows and 31 columns. ### #INPUT ### > temp DX1 DX2 DX3 1 13761 8125 49178 2 6

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread GL
Both of those approaches seem to return (" v75") instead of ("v75 "). -- View this message in context: http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320305.html Sent from the R help mailing list archive at Nabble.com. __ R-

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread GL
That works great, and is ever so much simpler. Thanks much! -- View this message in context: http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320317.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-projec

[R] Intersecting list vs rows in matrix

2010-08-10 Thread GL
Know that if I have List_1 and List_2 that I can check to see if the intersect via the code below: List _1: a, b, c, d, e, f, g List_2: z, y, x, w, v, u, b length(intersect(List_1, List_2)) > 0 return = true If instead I wanted to check a dataframe that is a "list of lists," how would I do t

Re: [R] Intersecting list vs rows in matrix

2010-08-10 Thread GL
Very cool. Thanks! -Original Message- From: "Henrique Dallazuanna [via R]" To: Lipori, Gigi Sent: 08/10/2010 05:18:25 PM Subject: Re: Intersecting list vs rows in matrix Try this: colSums(apply(List_2, 1, is.element, List_1)) > 0 On Tue, Aug 10, 2010 at 5:42

[R] AHRQ - Creation of Comorbidity Variables

2010-09-07 Thread GL
If there are any other users who use AHRQ's SAS code comoanaly2010 and comformat2010 to create comorbidity variables, I thought you might be interested in the following PRELIM code we wrote to mimic its functionality in R. It seems to yield similar results, but may contain errors. Please feel free

[R] bwplot in loop

2010-05-17 Thread GL
I have the two loops listed below. The first executes perfectly and creates a series of density plots. The second does not produce any output, however, if I enter the exact bwplot command after the loop executes, I get output for the last value in the list of services. Why am I not getting output

Re: [R] bwplot in loop

2010-05-17 Thread GL
Subsequently saw this in FAQs See FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f -- View this message in context: http://r.789695.n4.nabble.com/bwplot-in-loop-tp2220020p2220034.html Sent from the R help mailing list archive at Nabble.com. __

[R] SQL Changing Data Type

2011-06-24 Thread GL
Passing in two dates to a sql statement (sqldf). Is returning a factor. Tried setting back to a Date via as.Date, but get an error the error: character string is not in a standard unambiguous format. Any thoughts appreciated. Code/Results listed below: > summary(df.possible.combos) Date