[R] using MAP and PURR to compute characteristic roots

2021-03-31 Thread Veerappa Chetty
I have to compute characteristic roots for 100s of U.S.counties. I got help using " lapply". I prefer using MAP and PURR if that is possible. I am using them to compute linear regressions. Here is my test problem and the output. I would appreciate any help. Thanks V.K.Chetty test.dat<-

[R] using eigen function in MAP and purr

2021-03-29 Thread Veerappa Chetty
I want to use map and purr functions to compute eigen values for 3000 matrices. Each matrix has 2 rows and 2 columns. The following code does not work. test.dat<- tibble(ID=c(1,2),a=c(1,1),b=c(1,1),c=c(2,2),d=c(4,3)) test.out<-test.dat %>% nest(-ID) %>% mutate(fit = purrr::map(data,~ function(x)

[R] Using MAP with a function returning a vector

2018-06-11 Thread Veerappa Chetty
Hi Experts, The following codes work when the return value is a scalar. But I like to get the whole vector instead of one element of the vector x using map as a data frame instead getting one element of the vector using of map_dbl. In other words, I would like a data frame with one row for each

[R] stat_function with data frames in ggplot2

2018-06-07 Thread Veerappa Chetty
I use solve(A,b) inside my function, myfun2; it works fine when I return one value or a list. I want use the return values in ggplot as below: ggplot(data.frame( x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.2,geom="line") I get a blank graph. Would greatly appreciate help! Thanks. Here are my

[R] using myfunction in stat_function

2018-06-06 Thread Veerappa Chetty
HI, I use solve(A,b) inside my function, myfun2; it works fine when I return one value or a list. I want use the return values in ggplot as below: ggplot(data.frame( x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.2,geom="line") I get a blank graph. Would greatly appreciate help! Thanks. --

[R] using factor variable in the "DO" function

2016-03-07 Thread Veerappa Chetty
Hi, The following call does not work: dfhosp=dat.2.wide.sub %>% group_by(HOSP_NRD)%>% do(fitHosp=lm(log(y)~ log(x)+I(log(x)^2)+NCHRONIC+AGE+sex ,data=.)) Error in `$<-.data.frame`(`*tmp*`, "sex", value = integer(0)) : replacement has 0 rows, data has 25174 When I use "sex" as a binary

[R] date

2012-08-24 Thread Veerappa Chetty
Hi, I have dates as follows: 1/4/2006 0:00:00 AM It is a factor at present. How do I find out the day of the week from this? How do I convert to Julian date format? Thanks. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails:

[R] Date object

2012-04-21 Thread Veerappa Chetty
HI, I have to work with data objects. I have trouble. I would like to convert date to a integer of Julian dates omitting hours, minutes etc. I tried as. Date and also as.POSIXlt, ct etc. Please help me to compute the following difference. I get an NA for output. 1/14/2006 0:00:00 AM -1/9/2006

[R] large numbers

2011-10-12 Thread Veerappa Chetty
Hi, When I import an excel CSV file, large numbers such as 43988014.3 is imported as 43988014, leaving out the decimal .4. How to import keeping the fraction? Thanks. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails:

[R] reading large numbers

2011-10-12 Thread Veerappa Chetty
Hi, This happens when I read in large numbers; as.numeric(4398801.3) [1] 4398801 as.numeric(439880.3) [1] 439880.3 Please help to read in numbers with more than 8 characters! Thanks. Chetty -- Professor of Family

[R] dotplot

2010-03-22 Thread Veerappa Chetty
Hi, I am trying to make a dot plot in increasing order of the values. It does not work. How do I do it? Here are the codes I used. I am also attaching the data. I use lattice library. Thanks. Chetty --

[R] using reorder in dotplot

2010-03-22 Thread Veerappa Chetty
Hi , Name rate HEALTHALLIANCE HOSPITALS, INC -1.06211747 MOUNT AUBURN HOSPITAL 0.50960291 STURDY MEMORIAL HOSPITAL2.64233232 LAWRENCE GENERAL HOSPITAL

[R] using reorder in dotplot

2010-03-22 Thread Veerappa Chetty
Hi, Please help to correct my error in the following. I want to plot the values of 'x in increasing order. --- library(lattice) Name-c(A,B,C) x-c(15,20,10) test-data.frame(Name,x) dotplot(Name~x,test) dotplot(reorder(Name,x)~x,test) reorder has no effect! Thanks.

[R] Lattice barchart-reordered

2009-10-12 Thread Veerappa Chetty
Hi,Can I use reorder function with barchart as in dotchart? Here are some codes which do not work for me. Thanks Chetty ___ a1c.cast$bmi.cat.reordered[a1c.cast$eth!=Other] -with(a1c.cast[a1c.cast$eth!=Other,],reorder(bmi.cat.ordered[a1c.cast$eth!=Other], BP.FN.RATE,median

[R] barchart

2009-10-11 Thread Veerappa Chetty
Hi,In Lattice graphs, can I use reorder function in a barchart as in the case of dotchart? Or it can be used only with dotcharts? Thanks Chetty Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative HTML

[R] summarize-plyr package

2009-09-25 Thread Veerappa Chetty
Hi,I am using the amazing package 'plyr. I have one problem. I would appreciate help to fix the following error: Thanks. __ library(plyr) data(baseball) summarise(baseball, + duration = max(year) - min(year), + nteams = length(unique(team))) Error: could not find

[R] exporting interactive rggobi plots

2009-07-03 Thread Veerappa Chetty
Hi , I have created a parallel coordinate plot using rrgobi. I like to make a powerpoint slide. I am not able to copy and paste. Is there any way to do this? Thanks for any help. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails:

[R] dotplot

2009-03-04 Thread Veerappa Chetty
Hi,I would like to fill the dots in this graph. I would appreciate help to do that if possible. If fill is not possible, can I make it bright? I do NOT want to increase the size. __ dotplot(hu.event~fitted.adj.cat,data=risk.benefit.cast,groups=treat, auto.key=list(space=right))

[R] xy-plot alb font size

2009-03-02 Thread Veerappa Chetty
I would appreciate any help for the following question. How to increase the font size of labels for the x and y axes in the following code? - xyplot(lbxglu~lbxgh|eth,reg.dat.5, panel = p, col = 1:2, par.strip.text = list(cex = 1.25,col=brown),

[R] reshape from wide to long

2009-02-25 Thread Veerappa Chetty
Hi,I would like to reshape the following wide data set to long form. I would appreciate help with the correct code for reshape. I tried a few unsuccessfully. Thanks. Chetty __ dat.1 GrpX0X3 X6 X12

[R] loading mgcv package

2009-02-15 Thread Veerappa Chetty
Hi ,When I try to load the 'mgcv package, often, but not always, get this error message. What am I doing wrong? I even tried reinstalling a few times. __ This is mgcv 1.4-1.1 Error in runif(1) : .Random.seed is not an integer vector but of type 'list' Error : .onAttach failed in

[R] Adding abline in Lattice graph

2009-02-12 Thread Veerappa Chetty
Hi,I would like add a horizontal line at 126 (col=red) and a vertical line at 6.5 ( col= blue) in each panel .How should I use the panel.abline function in the following code I am using: -- library(lattice) with(reg.dat.5,coplot(lbxglu~lbxgh|eth,panel=panel.smooth,xlab=ABC,

[R] cluster function to use with GLM

2009-02-01 Thread Veerappa Chetty
Hi,In SPlus, I use the function 'cluster' with GLM to adjust for correlated errors within a cluster ( e.g. cluster(ID)) as a covariate. Is there a similar function in R to use with GLM ? I am new to R. Thanks. V.K. Chetty -- Professor of Family Medicine Boston University Tel: 617-414-6221,