[R] Any way to get read.table.ffdf() (in the ff package) to pass colClasses or comment.char parameters through to read.fwf() ?

2012-09-14 Thread Anthony Damico
ble(). I'm using R 2.15.1 x86_64-pc-mingw32/x64 (64-bit) on Windows 7. Thanks!! Anthony Damico Kaiser Family Foundation library(ff) # create a simple temporary file.. fwffile <- tempfile() # steal some example code from the documentation -- cat(file=fwffile, "123456", &quo

[R] Exactly Replicating Stata's Survey Data Confidence Intervals in R

2012-09-21 Thread Anthony Damico
more importantly) the output it generates. Below that, I've pasted some commented R code that shows how everything matches exactly except for the confidence intervals, and then displays a number of my failed attempts at hitting the numbers right on the nose. Thanks!! Anthony Damico Kais

Re: [R] Exactly Replicating Stata's Survey Data Confidence Intervals in R

2012-09-24 Thread Anthony Damico
- Male | 47.96.585346.8149.11 Female | 52.04.5853 50.8953.19 On Sun, Sep 23, 2012 at 4:30 PM, Thomas Lumley wrote: > On Sat, Sep 22, 2012 at 2:51 AM, Anthony Damico > wrote: > > > Survey: Me

Re: [R] svyboxplot - library (survey)

2012-10-01 Thread Anthony Damico
using a slight modification of the example shown in ?svyboxplot # load survey library library(survey) # load example data data(api) # create an example svydesign dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc) # set the plot window to display 1 plo

Re: [R] svyboxplot - library (survey)

2012-10-01 Thread Anthony Damico
cs and Quality > > Division of Population Surveys > > 1 Choke Cherry Road, Room 2-1071 > > Rockville, MD 20857 > > > > Tel: 240-276-1070 > > Fax: 240-276-1260**** > > e-mail: pradip.muh...@samhsa.hhs.gov > > > &g

Re: [R] svyby and make.formula

2012-10-02 Thread Anthony Damico
please double-check that you've got all of your parameters correct by typing ?svymean ?svyby and ?make.formula before you send questions to r-help :) # you spelled design wrong and probably need to throw out your NA values. try this # percentile by SPD status svyby(~dthage, ~xspd2, design=nhis

Re: [R] Failure of sas7bdat package

2012-10-04 Thread Anthony Damico
I can't help troubleshoot the read.sas7bdat function, but if you have the fixed-width data and a SAS importation script, the SAScii package might help you work around this issue. :) On Thu, Oct 4, 2012 at 11:55 AM, Fisher Dennis wrote: > R 2.15.1 > OS 10.7 > > Colleagues > > I have been an ent

Re: [R] svyhist

2012-10-05 Thread Anthony Damico
this worked for me -- and doesn't require removing the PSUs from the design :) options( survey.lonely.psu = "adjust" ) svyhist (~dthage, subset (nhis, xspd2=='No SPD'), breaks=MyBreaks, main= " ", col="grey80", xlab="Age at Death Distribution" ) lin

Re: [R] svyhist

2012-10-06 Thread Anthony Damico
> > Sorry- the earlier-sent plots were mislabeled, which I have corrected and > attached. But, the y-lim issue is yet to be resolved. > > Thanks, > > Pradip Muhuri > > > > From: Anthony Damico [ajdam...@gmail.com] > Sent:

Re: [R] svyplot

2012-10-10 Thread Anthony Damico
https://stat.ethz.ch/pipermail/r-help/2012-October/324944.html On Wed, Oct 10, 2012 at 5:05 PM, Muhuri, Pradip (SAMHSA/CBHSQ) < pradip.muh...@samhsa.hhs.gov> wrote: > Hello, > > Using the svyplot () function, I have plotted four graphs that are saved > in four different .png files. > > I am look

Re: [R] svyhist and svyboxplot

2012-10-13 Thread Anthony Damico
R is case sensitive either change subset (nhis, xsmoke=='Never SMK') to subset (nhis, xsmoke=='Never Smk') or change labels=c('Current SMK','Former SMK', 'Never Smk') to labels=c('Current SMK','Former SMK', 'Never SMK') but not both :) On Sat, Oct 13, 2012 at 10:02 PM, Muhuri, Pradip (SAMHSA/

Re: [R] svyplot and svysmooth with hexbin

2012-10-18 Thread Anthony Damico
try adding legend = 0 to your svyplot() On Thu, Oct 18, 2012 at 1:49 PM, Durant, James T. (ATSDR/DCHI/SSB) < h...@cdc.gov> wrote: > Hi all- > > So sorry to bother you all with something pretty basic. > > I am trying to add the lines method output from svysmooth to a svyplot > with style="grayhex"

Re: [R] Survey

2014-04-06 Thread Anthony Damico
hi leandro, in case you're already familiar with ibge's pnad, you might find these examples useful-- http://www.asdfree.com/search/label/pesquisa%20nacional%20por%20amostra%20de%20domicilios%20%28pnad%29 https://github.com/ajdamico/usgsd/tree/master/Pesquisa%20Nacional%20por%20Amostra%20de%20Domi

Re: [R] What is SE and how do you calculate it in svymean()?

2014-06-06 Thread Anthony Damico
it is the survey design-adjusted standard error. you can view what's going on by typing `survey:::svymean.survey.design` and `survey:::svyCprod` :) On Fri, Jun 6, 2014 at 10:03 AM, Ryan de Vera wrote: > Hello all, > > I have been experimenting with svymean() and I am confused on what the > ou

Re: [R] rake() error message

2014-06-08 Thread Anthony Damico
could you provide a reproducible example ?dput is your friend http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example On Sat, Jun 7, 2014 at 11:22 AM, Michael Willmorth < mwillmo...@clearwater-research.com> wrote: > I'm teaching myself how to use rake() in the R "

Re: [R] rake() error message

2014-06-08 Thread Anthony Damico
(1) you hit a memory error, because you are including too many variable levels. even if you narrowed your 16 variables down to these four, the `rake` function would need room for matricies containing as much data as a 6-million record table: nrow( expand.grid( data473t[ , c( 'm11' , 'm12c' , 'm13

Re: [R] (no subject)

2014-06-24 Thread Anthony Damico
the loop is 1 thru 9 but the manual is just 1, 2, 3, 4? change the loop from 1:dim(mydata)[2] to 1:4 and it works :) On Tue, Jun 24, 2014 at 9:43 AM, Zayd Farah wrote: > I hope the following script is reproducible enough to highlight my issue, > which is to automatically (in this case by loop

Re: [R] Generating Patient Data

2014-06-25 Thread Anthony Damico
# build off of david's suggestion x <- data.frame( patient= 1:20 , disease = sapply( pmin( 2 + rpois( 20 , 2 ) , 6 ) , function( n ) paste0( sample( c('A','B','C','D','E','F'), n), collapse="+" ) ) ) # break the diseas

Re: [R] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread Anthony Damico
Hi Andrew, to work with the Current Population Survey with R, your best best is to use a variant of my SAScii package that works with a SQLite database (and therefore doesn't overload RAM). I have written obsessively-documented code about how to work with the CPS in R here.. http://usgsd.blogspot

Re: [R] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-14 Thread Anthony Damico
Hi Andrew, great to hear from you :) You really ought to review the (100% R-specific) US Government Survey Datasets already available at http://usgsd.blogspot.com/ and contact me directly if you hit a problem -- I am furiously working on a few right now (ACS, SIPP, BSAPUFs, BRFSS, MEPS) , and am

Re: [R] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-15 Thread Anthony Damico
> What I do not understand is how SAS knows where the variables begin and > end. > I managed to break off a little hunk of the beginning of my file and look > at > it in an editor, and it is numbers without any obvious delimiters. Is the > delimiter a particular numeric string? I thought the SAS co

Re: [R] Joining two files

2012-11-23 Thread Anthony Damico
library(reshape) ?rbind.fill On Fri, Nov 23, 2012 at 10:57 AM, Virgile Capo-Chichi wrote: > Thanks Jim for your help. Your results are not what I wanted. I would like > to see something like the matrix below. This is what I would get if I used > the ADD Files command in SPSS. V > > r1 r2 r3 >

Re: [R] read.csv.sql() to select from a large csv file

2012-11-23 Thread Anthony Damico
you need to construct the character string. here's what you want to give to the sql argument -- paste( 'select * from file where ID = ' , Name ) so try Name <- "Bobby" read.csv.sql("filename",sql = paste( 'select * from file where ID = ' , Name ) ) On Fri, Nov 23, 2012 at 11:12 AM, Juliane St

Re: [R] Problems with weight

2012-11-23 Thread Anthony Damico
from your stata output, it looks like you need to use the survey package in R for step-by-step instructions about how to do this (and comparisons to stata), see http://journal.r-project.org/archive/2009-2/RJournal_2009-2_Damico.pdf once you're ready to run the regression, use svyglm() instead of

Re: [R] Results displayed in Console

2012-11-24 Thread Anthony Damico
# load example linear model from ?lm ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2,10,20, labels=c("Ctl","Trt")) weight <- c(ctl, trt) lm.D90 <- lm(weight ~ group - 1) # omitting intercept # store the summary()

Re: [R] Ceiling function gives me wrong answer

2012-11-28 Thread Anthony Damico
not sure ceiling() is behaving inappropriately.. > b <- 1000^( 1/3 ) > b [1] 10 > options( digits = 22 ) > b [1] 9.998223643 check out http://blog.revolutionanalytics.com/2009/11/floatingpoint-errors-explained.htmlfor more detail On Wed, Nov 28, 2012 at 9:10 PM, Ying Zheng wro

Re: [R] simple subset question

2012-12-02 Thread Anthony Damico
shouldn't you just change b to x and winter to fish? :) On Sun, Dec 2, 2012 at 12:21 PM, Felipe Carrillo wrote: > Hi, > Consider the small dataset below, I want to subset by two variables in > one line but it wont work...it works though if I subset separately. I have > to be missing something

Re: [R] Renaming column names according to another dataframe

2012-12-11 Thread Anthony Damico
df <- data.frame(A=(1:10),B=(1:10),C=(1:10)) # my changes to show that order doesn't matter df_names <- data.frame(code=c("C","A","D","E","B"),name=c("Col C","Col A","Col D","Col E","Col B")) names( df ) <- df_names[ match( names( df ) , df_names[ , 'code' ] ) , 'name' ] for more detail see ?mat

Re: [R] how to grep in r

2012-12-12 Thread Anthony Damico
assuming you want more than just the first four rows tpb <- read.table( text = " Trade_Price_Band x 1 0-30 0.6237240 2 101-150 0.6743857 3 151-200 0.6778513 4 201-300 0.6640293 5 301-400 0.6630991 6 31-50 0.6314547 7

Re: [R] data download

2012-12-12 Thread Anthony Damico
download.file( url = filename , destfile = location.to.save.locally , mode = 'wb' ) On Wed, Dec 12, 2012 at 2:48 PM, Alemu Tadesse wrote: > I am trying to download the tar files on the website below > > filename<-" > http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2010/SolarAnywhere/x.tar"; > wh

Re: [R] remove NA in df results in NA, NA.1 ... rows

2012-12-13 Thread Anthony Damico
df2 <- df2[!is.na(df2),] isn't doing what you want it to do because df2 is a data.frame and not a vector to solve your problem, review http://stackoverflow.com/questions/4862178/r-remove-rows-with-nas-in-data-frame On Thu, Dec 13, 2012 at 3:20 AM, wrote: > Good morning! > > I have the f

Re: [R] How to create multiple country's data into multiple sheets of one excel

2012-12-13 Thread Anthony Damico
use append = TRUE inside your write.xlsx() function On Thu, Dec 13, 2012 at 7:52 AM, Tammy Ma wrote: > > HI, > > > I have large dataset of many countries. I have written the program to run > through each country to generate one output for each country. I want to put > the output like this: > >

Re: [R] how to handle NA values in aggregate()

2012-12-15 Thread Anthony Damico
check the help file. ?aggregate says that it ignores missing values by default ;) df <- read.table( header = TRUE , text = "FID MID IID EW_INCU EW_17.5 EMWEEratio 1 4621 TWF2H545.26NA 15.61 NA 1 4621 TWF2H648.0244.09

Re: [R] automation of an R script to run

2013-10-11 Thread Anthony Damico
if you want to use R itself, you could try -- # check your time zone's abbreviation Sys.time() # subtract the time you want the program to run from the current time, # including your time zone..mine is EDT Sys.sleep( as.POSIXct( "2013-10-11 06:30:00 EDT" ) - Sys.time() ) -- at the very top of

[R] reading in stata file with read.dta works in R x64 3.0.1 and crashes R x64 3.0.2

2013-11-07 Thread Anthony Damico
this file http://www.electionstudies.org/studypages/data/anes_mergedfile_1992to1997/anes_mergedfile_1992to1997_dta.zip can be downloaded after free registration on this page http://electionstudies.org/studypages/download/registration_form.php imports properly in windows R x64 3.0.1 but ca

Re: [R] reading in stata file with read.dta works in R x64 3.0.1 and crashes R x64 3.0.2

2013-11-07 Thread Anthony Damico
x.html . > > Please update your packages and try again. (This looks very like a bug in > recently contributed code that has already been fixed.) > > > On 07/11/2013 13:40, Anthony Damico wrote: > >> this file >> >> >> http:/

[R] How to Read a Large CSV into a Database with R

2010-11-15 Thread Anthony Damico
ld, five-row CSV file. library(RSQLite) setwd("R:\\American Community Survey\\Data\\2009") in_csv <- file("test.csv") out_db <- dbConnect(SQLite(), dbname="sqlite.db") dbGetQuery(out_db , "create table test (hello integer, world te

Re: [R] How to Read a Large CSV into a Database with R

2010-11-15 Thread Anthony Damico
() function, but I was hoping there might be a way to accomplish this task entirely within R? Thanks again! On Mon, Nov 15, 2010 at 10:41 AM, Gabor Grothendieck < ggrothendi...@gmail.com> wrote: > On Mon, Nov 15, 2010 at 10:07 AM, Anthony Damico > wrote: > > Hi, I'm work

Re: [R] How to Read a Large CSV into a Database with R

2010-11-15 Thread Anthony Damico
and display what we have read > > k <- 4 # no of records to read at once > for(i in seq(0, N-1, k)) { +s <- sprintf("select * from mytab limit %d, %d", i, k) +print(sqldf(s, dbname = "mydb")) + } Error in seq.default(0, N - 1, k) : wrong sign in

[R] Could concurrent R sessions mix up variables?

2010-12-10 Thread Anthony Damico
ld cause a variable conflict like this? I have no idea where to start troubleshooting this error, so any advice would be appreciated. Thanks! Anthony Damico Kaiser Family Foundation __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listin

Re: [R] simple plotting question

2010-12-13 Thread Anthony Damico
to add to Michael's response: http://www.statmethods.net/advgraphs/parameters.html On Mon, Dec 13, 2010 at 2:23 AM, Michael Bedward wrote: > Hello Erin, > > Try this... > > plot(x, y, type="b", pch=16) > > Michael > > On 13 December 2010 18:11, Erin Hodgess wrote: >> Dear R People: >> >> When

[R] binary operators that never return missing values

2012-06-20 Thread Anthony Damico
that deals with this sort of thing? All I want are a group of functions like the ones I've posted below, but I'm worried I'm re-inventing the wheel.. If they're not already on CRAN, I feel like I should add them. Any pointers to work already completed on this subject would be

Re: [R] binary operators that never return missing values

2012-06-20 Thread Anthony Damico
t this hopefully gives you a start. You > might, e.g., think about setting this as something more like: > > Ops.damico <- function(e1, e2 = NULL){ >    if(.Generic %in% c("==","!=","<","<=",">=",">")){ >        e1[i

[R] Recoding Multiple Variables in a Data Frame in One Step

2011-07-21 Thread Anthony Damico
pi00" , "sch.wide" ) ] <- c( 100 , NA , "Maybe" ) #the results replace downward instead of across apiclus1[ apiclus1$meals > 98 , c( "pcttest" , "api00" , "sch.wide" ) ] I know I can do this with a few more steps (like one variable at a

[R] Direct Method Age-Adjustment to Complex Survey Data

2012-08-10 Thread Anthony Damico
uidance about how to perform this age-adjustment would be appreciated! Thanks!! Anthony Damico Kaiser Family Foundation require(foreign) require(survey) # download the NHANES 2009-2010 demographics and total cholesterol files ## tf <- tempfile() download.file(

Re: [R] Obtaining census tract data from addresses

2012-08-15 Thread Anthony Damico
Zack Almquist has written an excellent "UScensus2000" package.. but what you probably need is a batch conversion from https://webgis.usc.edu/Services/Geocode/Default.aspx or a census tract to zip code map from http://mcdc.missouri.edu/websas/geocorr12.html On Wed, Aug 15, 2012 at 9:59 AM, Mi

[R] Reading a Fixed-Width File with SAS import instructions directly into an R data frame

2012-02-07 Thread Anthony Damico
Hi everyone, I'm wondering if anyone has written (or knows of) an R function that takes the SAS import code to read in an ASCII / fixed-width data file.. and then parses out the SAS code to figure out how to structure a (foreign package) read.fwf command so that fixed-width data file can be read

<    1   2