[R] R Error: wrong result size (...), expected ... or 1 (minimal example provided)

2015-05-01 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I am reposting my question with a reproducible example/minimal dataset (6 rows) this time. I have written a user-defined function (myFunc below) with ten arguments. When calling the function, I get the following message: �Error: wrong result size (0), expected 2 or 1�. I am not getting

[R] R Error: wrong result size (...), expected ... or 1”

2015-04-28 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I have written a user-defined function (myFunc below) with ten arguments. When calling the function, I get the following message: �Error: wrong result size (816841), expected 52939 or 1�. myFunc involves a data frame (named xanloid_set), which has 816841 rows. R is correct to say that I

Re: [R] R example codes for direct standardization of rates

2015-01-07 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
PM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@R-project.org Subject: Re: R example codes for direct standardization of rates The pyears() and survexp() routines in the survival package are designed for these calculations. See the technical report #63 of the Mayo Biostat group for examples http

Re: [R] R function to convert person-level observations to person-period observations

2015-01-03 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
240-276-1260 -Original Message- From: David Barron [mailto:dnbar...@gmail.com] Sent: Saturday, January 03, 2015 10:19 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] R function to convert person-level observations to person-period observations Your data are wron

[R] R function to convert person-level observations to person-period observations

2015-01-03 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I was trying to convert person-level observations to person-period observations using an R custom function obtained from the UCLA web site (http://www.ats.ucla.edu/stat/r/faq/person_period.htm). Please see my reproducible example below. The function (PLPP) in the R script takes five a

Re: [R] R example codes for direct standardization of rates (Reference: Thoma's Lumley's survey package)

2014-12-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 From: Anthony Damico [mailto:ajdam...@gmail.com] Sent: Tuesday, December 30, 2014 3:01 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] R example codes for direct standardization of rates (Reference: Thoma's Lum

[R] R example codes for direct standardization of rates (Reference: Thoma's Lumley's survey package)

2014-12-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I am looking for R example codes to compute age-standardized death rates by smoking and psychological distress status using person-years of observation created from the National Health Interview Survey Linked Mortality Files. Any help with the example codes or references will be apprec

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-12-04 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: Thursday, December 04, 2014 1:20 PM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org Subject: Re: [R] Getting the most recent dates in a new column from dates

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-12-03 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ntical(new1, new2) table(new1$oiddate) table(new2$oiddate) # print records print (new1); print(new2) Pradip K. Muhuri, PhD SAMHSA/CBHSQ 1 Choke Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Chel Hee Lee [mailto:chl...@mail

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-12-03 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
;cocdate', 'inhdate', 'haldate')]), na.rm = TRUE) } max_d}), origin = "1970-01-01") identical(new1, new2) # print records print (new1); print(new2) Pradip K. Muhuri SAMHSA/CBHSQ 1 Choke Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 24

Re: [R] R dplyr solution vs. Base R solution for the slect column total

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
, November 30, 2014 9:42 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] R dplyr solution vs. Base R solution for the slect column total What do you think should be in the empty cells? Zero? NA? Empty strings? There can't just be nothing... Here's an example

Re: [R] R dplyr solution vs. Base R solution for the slect column total

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
rdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, November 30, 2014 9:16 PM To: Muhuri, Pradip (SAMHSA/CBHSQ); 'Boris Steipe' Cc: r-help@r-project.org Subject: Re: [R] R dplyr solution vs. Base R solution for the slect column total On 30/11/2014, 8:45 PM, Muhuri, Pradip (SAMHSA/CB

Re: [R] R dplyr solution vs. Base R solution for the slect column total

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
rry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Boris Steipe [mailto:boris.ste...@utoronto.ca] Sent: Sunday, November 30, 2014 5:51 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] R dplyr solution vs. Base R s

Re: [R] R dplyr solution vs. Base R solution for the slect column total

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
(SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] R dplyr solution vs. Base R solution for the slect column total try: sum(test$count) B. On Nov 30, 2014, at 12:01 PM, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hello, > > I am looking for a dplyr or base R solution for the col

[R] R dplyr solution vs. Base R solution for the slect column total

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I am looking for a dplyr or base R solution for the column total - JUST FOR THE LAST COLUMN in the example below. The following code works, giving me the total for each column - This is not exactly what I want. rbind(test, colSums(test)) I only want the total for the very last column. I

[R] no non-missing arguments to max; returning -Inf [2(dplyr/mutate()]

2014-11-30 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
A_real_, na.rm = TRUE) : no non-missing arguments to max; returning -Inf 2 -Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Muhuri, Pradip (SAMHSA/CBHSQ) Sent: Monday, November 10, 2014 1:09 PM To: 'Mark Sharp' Cc: r-help@r-proj

Re: [R] file.copy

2014-11-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello Duncan, Jeff's tweaks to my code has worked. Now I am trying your way. Below are the R script and console. The issue is that the object (list.of.files) has not been created. Any thoughts? Thanks, ### R script ## #file.copy.dm.way.R #identify th

Re: [R] file.copy

2014-11-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Jeff, Thank you so much for your help. Below are the revised code (done with your hints) that has worked and the console. I have just added - overwrite=TRUE) to file.copy(). Pradip ### #file.copy.jn.way.R #identify the folders fromFolder <- "H:/R/cis

[R] file.copy

2014-11-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, Here is something (file.copy) trivial but does not seem to work. I could not figure out what I am doing wrong. The R script below creates folders (fromFolder and toFolder) and finds the list of files (list.of.files) to be copied to the toFolder, which I have verified using the print

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 From: William Dunlap [mailto:wdun...@tibco.com] Sent: Monday, November 10, 2014 1:30 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: Mark Sharp; r-help@r-project.org Subject: Re: [R] range () does not remove NA's with complete.cases() for dates (

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ad, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Mark Sharp [mailto:msh...@txbiomed.org] Sent: Monday, November 10, 2014 12:23 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] range () does not remove NA's with

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
:30 AM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org Subject: Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate) Try range(data2$oiddate[complete.cases(data2$oiddate) & is.finite(data2$oiddate)]) #[1] "2006-09-01" "2011-11-0

[R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The range() with complete.cases() removes NA's for the date variables that are read from a data frame. However, the issue is that the same function does not remove NA's for the other date variable that is created using the dplyr/mutate(). The console and the reproducible example are gi

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
...@txbiomed.org] Sent: Sunday, November 09, 2014 3:01 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb) Pradip, mutate() works on the entire column as a

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-09 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ends here Pradip K. Muhuri, PhD SAMHSA/CBHSQ 1 Choke Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Sunday, November 09, 2014 10:18 AM To: Muhuri, Pradip (SAMHSA/C

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-09 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
hoke Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Sunday, November 09, 2014 7:00 AM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org Subject: Re: [R] Getting the most recent dates in a

Re: [R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-09 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
tting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb) On 11/8/2014 8:40 PM, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hello, > > > > The example data frame in the reproducible code below has 5 columns (1 column > for id and 4 col

[R] Getting the most recent dates in a new column from dates in four columns using the dplyr package (mutate verb)

2014-11-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The example data frame in the reproducible code below has 5 columns (1 column for id and 4 columns for dates), and there are 7 observations. I would like to insert the most recent date from those 4 date columns into a new column (oiddate) using the mutate() function in the dplyr packa

[R] Adding labels to ColSums

2014-10-28 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I was trying to add labels to the colSums of the "integers" variable corresponding to a "factor". Below are the warning message and the reproducible code. How would I tweak the code to replace the "NA" with the "Total" in the output? Your advice toward resolving the issue would be

Re: [R] Error Reading from Connection

2014-09-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ta", mode=4) heroin.rdata 0 > load("heroin.rdata") Error: error reading from connection ____ From: Jeff Newmiller [jdnew...@dcn.davis.ca.us] Sent: Tuesday, September 23, 2014 9:20 PM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-proje

[R] Error Reading from Connection

2014-09-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I am running Rx64 3.03 under Windows 8 environment. I have been getting the following error. when running some of my old R applications. Below is a mock-up example. Could someone please help me resolve the issue? Thanks, Pradip Muhuri setwd ("D:/") > > > #load Rdata f

Re: [R] Regression Tolerance Intervals - Dr. Young's Code

2013-06-09 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
_ From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Sunday, June 09, 2013 11:54 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: "R help ‎[r-help@r-project.org]‎"; mridulb...@aol.com Subject: Re: [R] Regression Tolerance Intervals - Dr. Young's Code On 08.06.2013 05:17,

[R] Regression Tolerance Intervals - Dr. Young's Code

2013-06-07 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, Below is a reproducible example to generate the output by using Dr. Young's R code on the above subject . As commented below, the issue is that part of the code (regtol.int and plottol) does not seem to work. I would appreciate receiving your advice toward resolving the issue. Thanks

Re: [R] Applying a user-defined function

2013-01-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, Last time, Arun's following solution worked to create 3 new columns (1,3,5). Now how would I tweak this function to create corresponding (additional) columns (7,8,9) of mode factor (levels = 1,2,3,4,5)? Thanks for your continued support. Pradip ### cut and paste from the rep

[R] Applying a user-defined function

2013-01-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, My goal is to apply a user-defined function on several columns of a data frame. When testing the code on a reproducible example below, I get the following error message. > #now Write a new function using the above cut ()/quantile function to apply > on different columns of the data

Re: [R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
From: Neal H. Walfield [n...@walfield.org] Sent: Monday, December 31, 2012 5:42 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R] cut () At Mon, 31 Dec 2012 22:25:25 +0000, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > The issue is that, for Utah, I am getting an instead of (42,48.7

Re: [R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Dear David, Thank you so much for catching the mistake that is kind of careless. Sorry about that. Happy New Year. Pradip From: David L Carlson [dcarl...@tamu.edu] Sent: Monday, December 31, 2012 6:18 PM To: Muhuri, Pradip (SAMHSA/CBHSQ); 'R

[R] cut ()

2012-12-31 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, My goal is to create a 5 category variable (p1_st_data$ob_mrj_cat), based on the p1_st_data$obt_mrj_p variable, using the following code for 50 States and District of Columbia (N=51). p1_st_data$ob_mrj_cat <- cut (p1_st_data$obt_mrj_p, quantile (p1_st_data$obt_mrj_p, (0:5/5), incl

Re: [R] format.pval () and printCoefmat ()

2012-12-15 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
arun [mailto:smartpink...@yahoo.com] Sent: Saturday, December 15, 2012 11:04 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help; David Winsemius Subject: Re: [R] format.pval () and printCoefmat () Hi Pradip, It this is just formatting issue, it is possible to do that with ?formatC() or ?sprintf(), bu

Re: [R] format.pval () and printCoefmat ()

2012-12-15 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
9 6 whcsam18.77.931.363 0 0.279 From: arun [smartpink...@yahoo.com] Sent: Friday, December 14, 2012 10:12 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help; David Winsemius Subject: Re: [R] format.pval

Re: [R] format.pval () and printCoefmat ()

2012-12-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
  The Center for Behavioral Health Statistics and Quality your feedback.  Please click on the following link to complete a brief customer survey:  http://cbhsqsurvey.samhsa.gov -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Friday, December 14, 2012 3:22 P

[R] format.pval () and printCoefmat ()

2012-12-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi List, My goal is to force R not to print in scientific notation in the sixth column (rel_diff - for the p-value) of my data frame (not a matrix). I have used the format.pval () and printCoefmat () functions on the data frame. The R script is appended below. This issue is that use of the for

Re: [R] read. table()

2012-12-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
click on the following link to complete a brief customer survey: http://cbhsqsurvey.samhsa.gov -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Saturday, December 08, 2012 8:45 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: dcarl...@tamu.edu; R help Subject: Re: [R] read

Re: [R] read. table()

2012-12-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
of 1 variable: # $ raceage...percent..sepercent..flag_var: Factor w/ 195 levels "C-S American 12-17 0.2399 0.15804 coc",..: 50 170 20 5 35 185 65 155 110 80 ... A.K. - Original Message - From: "Muhuri, Pradip (SAMHSA/CBHSQ)" To: 'Prof Bri

Re: [R] read. table()

2012-12-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
amhsa.gov -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Prof Brian Ripley Sent: Saturday, December 08, 2012 2:29 PM To: r-help@r-project.org Subject: Re: [R] read.table() On 08/12/2012 19:10, Muhuri, Pradip (SAMHSA/CBHSQ) wro

[R] read.table()

2012-12-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi List, I have spent more than 30 minutes, but failed to read in this file using the read.table() function. I could not figure out how to fix the following error. Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 6 elements Any help would be

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
] I agree - Arun has also suggested the same. Thanks and regards, Pradip From: Peter Ehlers [ehl...@ucalgary.ca] Sent: Friday, November 23, 2012 10:47 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] subsetting - questions O

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Jorge, I could use subset(). But, I wanted to minimize coding. Thanks, Pradip From: Jorge I Velez [jorgeivanve...@gmail.com] Sent: Friday, November 23, 2012 10:02 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R

Re: [R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Arun, Thank you so much for your help. Pradip From: arun [smartpink...@yahoo.com] Sent: Friday, November 23, 2012 10:15 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R] subsetting - questions HI, This should work: df[df$X1>=8,][-wh

[R] subsetting - questions

2012-11-23 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I have two very basic questions (console attached): 1) What am I getting an error message for # 5 and # 7 ? 2) How to fix the code? I would appreciate receiving your help. Thanks, Pradip Muhuri ## Reproducible Example # N <- 100 set.seed(13) df<-data.frame(matrix(sample(c

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] Data Extraction - benchmark() On 22-11-2012, at 18:20, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > Hi Berend, > > I see you are one of the contributors to the rbecnhmark package. > > I am sorry that I am bothering you

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
columns=c("test","elapsed", "relative", "replications") ) identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), identical (d1,d6) ________ From: Berend Hasselman [b...@xs4all.nl] Sent: Th

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Sarah, I am glad you have precisely caught where I made the mistake. Thank you so much. regards, Pradip Muhuri From: Sarah Goslee [sarah.gos...@gmail.com] Sent: Thursday, November 22, 2012 9:21 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Berend, You have compared all 3 ways. ... very nicely evaluated. Thanks and regards, Pradip Muhuri Beginner UseR From: Berend Hasselman [b...@xs4all.nl] Sent: Thursday, November 22, 2012 9:49 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Bert, Your solution is similar to Petr's. Thanks and regards, Pradip Muhuri BeginneR UseR From: Bert Gunter [gunter.ber...@gene.com] Sent: Thursday, November 22, 2012 10:20 AM To: Berend Hasselman Cc: Muhuri, Pradip (SAMHSA/CBHSQ); r-h

Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Petr, You have shown a solution that is the simplest. Thanks and regards, Pradip Muhuri Beginner useR From: PIKAL Petr [petr.pi...@precheza.cz] Sent: Thursday, November 22, 2012 9:33 AM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org Subject: RE

[R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I would appreciate if someone could help me resolve the following: 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work 2. Is these message harmful? The following object(s) are masked from 'df1 (position 3)': X1, X2, X3, X4, X5 Thanks, Pradip Muhuri #Reproducible

Re: [R] kinitr

2012-11-20 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ey.samhsa.gov/> From: Mark Lamias [mailto:mlam...@yahoo.com] Sent: Tuesday, November 20, 2012 4:45 PM To: Muhuri, Pradip (SAMHSA/CBHSQ); 'R. Michael Weylandt' Cc: r-help@r-project.org Subject: Re: [R] kinitr This is how I learned everything about knitr: http://yihui.name/knitr/ Yihui i

Re: [R] kinitr

2012-11-20 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
stics and Quality your feedback.  Please click on the following link to complete a brief customer survey:  http://cbhsqsurvey.samhsa.gov -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Tuesday, November 20, 2012 8:36 AM To: Muhuri, Pradip (SAMHSA/CBH

Re: [R] github

2012-11-20 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
eyla...@gmail.com] Sent: Tuesday, November 20, 2012 8:41 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] github On Tue, Nov 20, 2012 at 2:07 AM, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: > > Hello, > > I would like to learn how to set up Github/repository and upl

[R] github

2012-11-19 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I would like to learn how to set up Github/repository and upload/update files and am looking for "Github for Dummies". Any help will be appreciated. Thanks, Pradip __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinf

[R] kinitr

2012-11-19 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I am an Intro-level R and ggplot2 user and looking for resources to self teach dynamic report generation in R using knitr. Any advice would be highly appreciated. Thanks, Pradip __ R-help@r-project.org mailing list https://stat.ethz.ch/mailma

Re: [R] Saving R Graph to a file

2012-11-04 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, #Example 1: The following code to save svyboxplots works for me pdf("boxplots_dthage.pdf", width = 1020) # 4 boxplots in 2 columns and 2 rows par(mfrow=c(2,2), oma=c(0,0,0,0)) # svyboxplot commands not shown dev.off() #Example 2: The following code to save a ggplot graph works for me:

[R] Logical vector-based extraction

2012-11-03 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The most part of the program works except that the following logical variable does not get created although the second logical variable-based extraction works. I don't understand what I am doing wrong here. state_pflt200 <- df$p_fatal <200 df[state_pflt200, c("state.name","p_fatal")]

Re: [R] How generate random numbers from given vector???

2012-10-25 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The other options is to use the sample() function. test2 <- matrix (rep(sample(number1, size = 5), times=3), nrow=3) Pradip Muhuri From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Rui Barradas [ruipbarra...@sapo.pt

Re: [R] svyboxplot - library (survey)

2012-10-18 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
From: Muhuri, Pradip (SAMHSA/CBHSQ) Sent: Thursday, October 18, 2012 4:45 PM To: 'Thomas Lumley' Cc: Anthony Damico; R help; Muhuri, Pradip (SAMHSA/CBHSQ) Subject: RE: [R] svyboxplot - library (survey) Hello Dr. Lumley, Thank you for y

Re: [R] svyboxplot - library (survey)

2012-10-18 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ke Cherry Road, Room 2-1071 Rockville, MD 20857   Tel: 240-276-1070 Fax: 240-276-1260 e-mail: pradip.muh...@samhsa.hhs.gov   The Center for Behavioral Health Statistics and Quality your feedback.  Please click on the following link to complete a brief customer survey:  http://cbhsqsurvey.s

Re: [R] svyboxplot - library (survey)

2012-10-17 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
w (SPD Category)" ) lines (svysmooth(~age_p, bandwidth=5,subset(nhis, xspd2=='SPD')), lwd=2) From: Anthony Damico [ajdam...@gmail.com] Sent: Monday, October 01, 2012 10:07 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R

Re: [R] svyhist and svyboxplot

2012-10-13 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Anthony, I now can't afford to forget that R is case-sensitive! Thank you so much! Pradip Muhuri From: Anthony Damico [ajdam...@gmail.com] Sent: Saturday, October 13, 2012 10:10 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: Thomas Lumley; R help Subjec

[R] svyhist and svyboxplot

2012-10-13 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The following code is expected to produce 4 charts. But, I only get charts 1,2 ,& 4, NOT CHART # 3. For Chart# 3, I am getting the following error message: Error in tapply(1:NROW(x), list(factor(strata)), function(index) { : arguments must have same length I would appreciate if som

Re: [R] svyplot

2012-10-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
https://stat.ethz.ch/pipermail/r-help/2012-October/324944.html On Wed, Oct 10, 2012 at 5:05 PM, Muhuri, Pradip (SAMHSA/CBHSQ) mailto: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 l

[R] svyplot

2012-10-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, Using the svyplot () function, I have plotted four graphs that are saved in four different .png files. I am looking for examples how to redraw the same four graphs within grid viewports so that they stay together on a page. The goal is to create one .png file that will include all four

Re: [R] svyhist

2012-10-08 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
clarification regarding the kernel density estimator. Pradip Muhuri From: Thomas Lumley [tlum...@uw.edu] Sent: Monday, October 08, 2012 8:40 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: Anthony Damico; R help Subject: Re: [R] svyhist The line isn't a theore

Re: [R] svyhist

2012-10-06 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
uot; ) lines (svysmooth(~dthage, bandwidth=5,subset(nhis, xspd2=='No SPD')), lwd=2) dev.off () From: Anthony Damico [ajdam...@gmail.com] Sent: Saturday, October 06, 2012 6:56 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: David Winsemius; R hel

Re: [R] svyhist

2012-10-05 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
:29 PM To: David Winsemius Cc: Muhuri, Pradip (SAMHSA/CBHSQ); R help Subject: Re: [R] svyhist 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'

Re: [R] svyhist

2012-10-05 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
quot;grey80", xlab="Age at Death among those Who had no SPD Distribution" ) lines (svysmooth(~dthage, bandwidth=5,subset(nhis, xspd2=='No SPD')), lwd=2) dev.off () ############## From: Anthony Damico [ajdam...@gmail.com] Sent: Friday, October 05, 2012 7:29 PM To: David W

[R] svyhist

2012-10-05 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I was trying to draw histograms of age at death and got the following 2 error messages: 1) Error in tapply(1:NROW(x), list(factor(strata)), function(index) { : arguments must have same length 2) Error in findInterval(mm[, i], gx) : 'vec' contains NAs In addition: Warn

Re: [R] svyby and make.formula

2012-10-02 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
is, mortstat==1), na.rm=TRUE) # all of the variables in vars are NA whenever mortstat isn't 1, so they give the same results On Tue, Oct 2, 2012 at 7:51 PM, Muhuri, Pradip (SAMHSA/CBHSQ) mailto:pradip.muh...@samhsa.hhs.gov>> wrote: Hello, Although my R code for the svymean ()

Re: [R] svyboxplot - library (survey)

2012-10-02 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Thomas, Thank you so much for your help. Pradip From: Thomas Lumley [tlum...@uw.edu] Sent: Monday, October 01, 2012 6:45 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: Anthony Damico; R help Subject: Re: [R] svyboxplot - library (survey) The documentation

[R] svyby and make.formula

2012-10-02 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, Although my R code for the svymean () and svyquantile () functions works fine, I am stuck with the svyby () and make.formula () functions. I got the following error messages. - Error: object of type 'closure' is not subsettable # svyby () - Error in xx[[1]] : subscript out of bound

Re: [R] svyboxplot - library (survey)

2012-10-01 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ief customer survey: http://cbhsqsurvey.samhsa.gov<http://cbhsqsurvey.samhsa.gov/> From: Anthony Damico [mailto:ajdam...@gmail.com] Sent: Monday, October 01, 2012 10:07 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R help Subject: Re: [R] svyboxplot - library (survey) using a slight modification of the exa

[R] svyboxplot - library (survey)

2012-10-01 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, I have used the library (survey) package for boxplots using the following code. Could anyone please tell me why I am getting only 1 boxplot instead of 2 boxplots (1-SPD, 2-No SPD). What changes in the following code would be required to get 2 boxplots in the same plot frame? Thank

[R] Bar chart in ascending order for each level of X

2011-07-14 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, The question is how to plot a bar chart in which bars are sorted in ascending order for each level of X. I would appreciate receiving your advice and help. Thanks, Pradip Muhuri ** The following codes work when producing the chart in which bars are NOT sorted. Please see

Re: [R] Asymmetrical Confidence Interval

2011-06-20 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
the following link to complete a brief customer survey: http://cbhsqsurvey.samhsa.gov -Original Message- From: Patrick Connolly [mailto:p_conno...@slingshot.co.nz] Sent: Sunday, June 19, 2011 1:57 AM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org; 'tlum...@u.washi

[R] Asymetrical Confidence Interval

2011-06-16 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Dear List, I wanted to calculate the asymmetrical confidence interval based on the sample statistic and standard error that available from the published report (complex survey-based). The calculation details can be seen from pages 17-18 of the document at the following link: http://www.oas.sa

[R] Contributed Packages - Hmisc & survey

2011-06-01 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello List, Could someone tell why I can't install the Himsc and survey packages for R version 2.13.0 (2011-04-13)? What am I doing wrong here? Thanks, Pradip > install.packages ("Hmisc", dependencies=TRUE) --- Please select a CRAN mirror for use in this session --- Warning: unable to access

Re: [R] R in batch mode

2011-05-24 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ge- From: Jonathan Daily [mailto:biomathjda...@gmail.com] Sent: Tuesday, May 24, 2011 1:18 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: R-help@r-project.org Subject: Re: [R] R in batch mode Save it anywhere that is on your search path, which can be seen by typing path into the command line. On Tue, May 24,

[R] R in batch mode

2011-05-24 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Everyone, I am a new R user and trying to run R jobs in batch mode. Robert Muenchen (2009), in his book "R for SAS and SPSS Users", has suggested writing a small batch file like mR.bat as shown below: "C:\Program File\R\R-2.10.0\bin\Rterm.exe" --no-restore --no-save < %1 > %1.Rout 2>&