583 search results for "sql"

Split, apply, and combine in R using PLYR

November 4, 2009
By

While flirting around with previously mentioned ggplot2 I came across an incredibly useful set of functions in the plyr package, made by Hadley Wickham, the same guy behind ggplot2.  If you've ever used MySQL before, think of "GROUP BY", but here you can arbitrarily apply any R function to splits of the data, or write one yourself. Imagine you have...

Read more »

Public opinion on health care reform

October 12, 2009
By
Public opinion on health care reform

hc_appattach(hc_app) hc_fit.o1hc_fit.f1hc_fit.o2hc_fit.f2plot(as.Date(Dates),Oppose,main="Public opinion and health care reform",ylim=c(0,80),pch=16,xlim=c(as.Date("2009-01-01"),as.Date("2009-11-01")),cex.axis=.85, col="#E6ADD8",xlab="",ylab="Percentage approving or opposing") points(as.Date(Dates),Favor,pch=16,col="#ADD8E6") lines(hc_fit.f1,col="blue",lwd=2)lines(hc_fit.o1,col="red",lwd=2)lines(hc_fit.f2,col="blue",lwd=2,lty=3)lines(hc_fit.o2,col="red",lwd=2,lty=3) abline(h=50,lwd=.5,lty=3,col="#555555")

Read more »

Public opinion on health care reform

October 12, 2009
By
Public opinion on health care reform

hc_appattach(hc_app) hc_fit.o1hc_fit.f1hc_fit.o2hc_fit.f2plot(as.Date(Dates),Oppose,main="Public opinion and health care reform",ylim=c(0,80),pch=16,xlim=c(as.Date("2009-01-01"),as.Date("2009-11-01")),cex.axis=.85, col="#E6ADD8",xlab="",ylab="Percentage approving or opposing") points(as.Date(Dates),Favor,pch=16,col="#ADD8E6") lines(hc_fit.f1,col="blue",lwd=2)lines(hc_fit.o1,col="red",lwd=2)lines(hc_fit.f2,col="blue",lwd=2,lty=3)lines(hc_fit.o2,col="red",lwd=2,lty=3) abline(h=50,lwd=.5,lty=3,col="#555555")

Read more »

Delete rows from R data frame

October 8, 2009
By
Delete rows from R data frame

Deleting rows from a data frame in R is easy by combining simple operations. Let’s say you are working with the built-in data set airquality and need to remove rows where the ozona is NA (also called null, blank or missing). The method is a conce...

Read more »

Export Data Frames To Multi-worksheet Excel File

October 6, 2009
By
Export Data Frames To Multi-worksheet Excel File

A few weeks ago I needed to export a number of data frames to separate worksheets in an Excel file. Although one could output csv-files from R and then import them manually or with the help of VBA into Excel, I was after a more streamlined solution, as I would need to repeat this process

Read more »

Survive R

September 29, 2009
By

New PDF slides version (presented at the Bay Area R Users Meetup October 13, 2009). We at Win-Vector LLC appear to like R a bit more than some of our, perhaps wiser, colleagues ( see: Choose your weapon: Matlab, R or something else? and R and data ). While we do like R (see: Exciting Related posts:

Read more »

How to Import MS Excel Data into R

September 26, 2009
By
How to Import MS Excel Data into R

s Sir Francis Bacon said, “Histories make men wise; poets witty; the mathematics subtile; natural philosophy deep; moral grave; logic and rhetoric able to contend.” And Windows stupid. He should have added the last sentence if he were a Windows user in this age. 1. Avoid Using M$ Excel A lot of R users often ask this question:

Read more »

SAS: “The query requires remerging summary statistics back with the original data”

September 22, 2009
By
SAS: “The query requires remerging summary statistics back with the original data”

Coming from a background writing SQL code directly for “real” RDBMS (Microsoft SQL Server, MySQL, and SQLite), I was initially confused when SAS would give me the following ‘note’ for a simple summary PROC SQL query: 429 proc sql; 430 create table undel_monthly as 431 select 432 year(date) as year, 433 month(date) as month, 434

Read more »

Aggregating SSURGO Data in R

September 10, 2009
By
Aggregating SSURGO Data in R

  Premise SSURGO is a digital, high-resolution (1:24,000), soil survey database produced by the USDA-NRCS. It is one of the largest and most complete spatial databases in the world; and is available for nearly the entire USA at no cost. These data are distributed as a combination of geographic and text data, representing soil map units and their...

Read more »

ClipPath copies filename and path from windows for loading into R

September 4, 2009
By

I wish I would have discovered this long ago.  Loading data into R or MySQL requires you to specify the full path to the file.  If you do this on a Windows machine there are two annoyances.  First, if you save something to your desktop the path to your desktop is really long.  Second, windows by default uses backslashes...

Read more »