Re: [R] Help with transpose please.

2018-06-22 Thread Ramesh YAPALPARVI
Please check out tidyr package and use commands like spread/ gather which would 
make data wide or long



> On Jun 22, 2018, at 07:43, Bill Poling  wrote:
> 
> Good morning.
> 
> 
> I have data in the form:
> 
> head(Edit041IA, n=25)
>   ClaimServiceID  ClaimID DiagnosisCode
> 1   183056004 78044473  C562
> 2   183056004 78044473  C778
> 3   183056004 78044473  C784
> 4   183056004 78044473  C786
> 5   183056004 78044473 C7961
> 6   183056004 78044473 C7982
> 7   183056004 78044473 C7989
> 8   183056008 78044473  C562
> 9   183056008 78044473  C778
> 10  183056008 78044473  C784
> 11  183056008 78044473  C786
> 12  183056008 78044473 C7961
> 13  183056008 78044473 C7982
> 14  183056008 78044473 C7989
> 15  183139945 78078925M79606
> 16  183139945 78078925 M7989
> 17  183139945 78078925  R600
> 18  183236728 78119632H02831
> 19  183236728 78119632H02832
> 20  183236728 78119632H02834
> 21  183236728 78119632H02835
> 22  183236728 78119632H04123
> 23  183236728 78119632  Z411
> 24  183236728 78119632 H2513
> 25  183236728 78119632H43813
> 
> And wish to transpose to single record for single claimServiceID, ClaimID, 
> and Dx1,Dx2,Dx3, etc:
> 
> There can be multiple claimServiceIDs for a ClaimID so I want the unique 
> ClaimServiceID as the identifier when I join this data back into a longer 
> single record length file by that column.
> 
>claimServiceID ClaimID  Dx1   Dx2Dx3  ...etc
> 1 18305600478044473 C562 C778 C784 C786 C7961 ...etc
> 2 18305600878044473 C562 C778 C784 C786 C7961 ...etc
> 
> 
> (If you would prefer the complete  dput of the 1272 records I will gladly 
> provide .Names = c("ClaimServiceID",
> 
> "ClaimID", "DiagnosisCode"), class = "data.frame", row.names = c(NA,
> 
> -1272L))
> 
> 
> 
> At the moment the classes are:
> 
> classes <- as.character(sapply(Edit041IA, class))
> 
> classes
> 
> # [1] "integer"   "integer"   "character" <---but do not have to be if that 
> helps its just that's how the csv load pulled them in
> 
> The max number of columns based on this transpose of the DiagnosisCode column 
> (in this dataset) is 12 if that is important to know.
> 
> I have looked at a variety of webpages and cannot get this right,
> 
> dta2 <- melt(dta1, id=c("ClaimServiceID","ClaimID"))
> View(dta2)
> # https://www.r-bloggers.com/pivot-tables-in-r/
> 
> # 
> https://stackoverflow.com/questions/18449938/pivot-on-data-table-similar-to-rehape-melt-function
> 
> 
> dta3 <- cast(Edit041IA, ClaimServiceID ~ DiagnosisCode, ClaimID)
> View(dta3)
> dta3 <- cast(Edit041IA, DiagnosisCode ~ ClaimServiceID, ClaimID)
> View(dta3)
> 
> dta3 <- melt(Edit041IA, id=c("ClaimServiceID"))
> View(dta3)
> 
> dta3 <- aggregate(Edit041IA, by=list(ClaimServiceID, ClaimID, DiagnosisCode))
> View(dta3)
> 
> 
> dta3 <- aggregate(Edit041IA, by=list(ClaimServiceID))
> View(dta3)
> # https://www.r-statistics.com/tag/transpose/
> 
> dta3 <- aggregate(Edit041IA, by=list(DiagnosisCode, ClaimServiceID, ClaimID))
> View(dta3)
> 
> 
> I am sure it's a basic,  simple procedure, but I am pressed for time on this 
> one, any support will be greatly appreciated, thank you.
> 
> WHP
> 
> 
> 
> 
> 
> Confidentiality Notice This message is sent from Zelis. ...{{dropped:15}}
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Medical risk package calculation RSI

2018-03-25 Thread Ramesh YAPALPARVI

Hi all,



I'm using the medical risk package to determine the risk stratification Index 
based on the ICD9 codes. Although, I have been successful in using it, I'm 
unable to interpret the output.



here is the sample code



# Calculate RSI for each patient ("id") in dataframe


cases <- data.frame(id=c(1,1,1,2,2,2,2,2),
+ 
icd9cm=c("D4019","D25000","DV707","D71945","DV4365","D78079","D70909","D1958"))


library(plyr)
ddply(cases, .(id), function(x) { icd9cm_sessler_rsi(x$icd9cm) } )




Output:

id rsi_1yrpod rsi_30dlos rsi_30dpod rsi_inhosp
1  1 -0.2860474  1.2481208 -0.5722244 -0.2612804
2  2  0.1417417  0.9779779 -1.0318395  0.000

Could anyone please help me?

Thanks,
Ramesh
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help with SQLsave

2018-01-24 Thread Ramesh YAPALPARVI

Hi all,



I'm using RODBC library to connect to a database.

I'm trying to read a table from a database and after manipulating it would like 
to write to the same database but with a different table



P<-data.frame(sqlQuery(myconn,'select  *  from Demographics'))
sqlSave(myconn,p,tablename="trial",rownames=FALSE)




I'm gettng this error







Version:1.0 StartHTML:000107 EndHTML:001014 StartFragment:000127 
EndFragment:000996
Error in sqlSave(myconn, p, tablename = "trial", rownames = FALSE) : 
 [RODBC] Failed exec in Update

22018 0 [Microsoft][ODBC Driver 11 for SQL Server]Invalid character value for 
cast specification


Thanks,

Ramesh
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] Help with dates

2017-12-28 Thread Ramesh YAPALPARVI
Hi all,

I’m struggling to get the dates in proper format.
I have dates as factors and is in the form 02/27/34( 34 means 1934). If I use

as.Date with format %d%m%y it gets converted to 2034-02-27. I tried changing 
the origin in the as.Date command but nothing worked. Any help is appreciated.

Thanks,
Ramesh
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] Data Import to R

2014-11-13 Thread Ramesh Gautam
While importing .csv files into R, all data are converted to factor-by
default. But, how can I preserve the original format of the data like
numeric to numeric, integer to integer, character to character etc while
importing from csv to R environment.

I tried several ways, no thing helps. I used 'stringsAsFactor = FALSE'
command, it did convert all data to characters. But, I wanted to preserve
the numeric data to be in integer or double.

Any idea? examples?

Thanks

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Kindly help me

2014-04-30 Thread Ramesh Das
Thanks lot again to all.


On Wed, Apr 30, 2014 at 2:32 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 The package is Zelig, not zelig, R is case sensitive.
 Try

 install.packages(Zelig, dependencies = TRUE)


 And can't you update your version of R? It's now R 3.1.0.

 Hope this helps,

 Rui Barradas

 Em 29-04-2014 19:30, Ramesh Das escreveu:

 Dear all,
 I have a problem in installing the the package zelig. I have window 32
 bit operating system and R- 3.0.1 version.  zelig' package is not
 compatible with R-3.0.1 version. Please help me how to install the package
 zelig . If any other package is available in replace of zelig', kindly
 suggest me.

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/
 posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] systemfit package is not compatible with R-3.0.2 version.

2014-04-30 Thread Ramesh Das
Dear all,
I am in problem for installing the package systemfit in R-3.0.2 version.
The error message is showing is as mentioned below. Now there is R-3.0.2
version is there. so kindly anyone help me to solve this problem.


Warning in install.packages :
  package ‘systemfit ’ is not available (for R version 3.0.2)
Loading required package: Matrix
Error in loadNamespace(j - i[[1L]], c(lib.loc, .libPaths()), versionCheck
= vI[[j]]) :
  there is no package called ‘lattice’
In addition: Warning messages:
1: package ‘systemfit’ was built under R version 3.0.3
2: package ‘Matrix’ was built under R version 3.0.3
Error: package ‘Matrix’ could not be loaded

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Kindly help me

2014-04-29 Thread Ramesh Das
Dear all,
I have a problem in installing the the package zelig. I have window 32
bit operating system and R- 3.0.1 version.  zelig' package is not
compatible with R-3.0.1 version. Please help me how to install the package
zelig . If any other package is available in replace of zelig', kindly
suggest me.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Kindly help me

2014-04-29 Thread Ramesh Das
Dear all,
I have a problem in installing the the package zelig. I have window 32
bit operating system and R- 3.0.1 version.  zelig' package is not
compatible with R-3.0.1 version. Please help me how to install the package
zelig . If any other package is available in replace of zelig', kindly
suggest me.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Kindly help me

2014-04-29 Thread Ramesh Das
Dear all,
I have a problem in installing the the package zelig. I have window 32
bit operating system and R- 3.0.1 version.  zelig' package is not
compatible with R-3.0.1 version. Please help me how to install the package
zelig . If any other package is available in replace of zelig', kindly
suggest me.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] need help to convert in to panel data format

2014-02-16 Thread Ramesh Chandra Das
Dear All,
The data format is like this
  Company  2001 2001 2001 2002 2002 2002 2003 2003 2003 2004 2004 2004  3M
India Ltd. 1160.2 2082.7 67.1 1094.3 1069.9 221.6 1160.2 2082.7 67.1 1094.3
1069.9 221.6  A B B India Ltd. 7758 7932.8 698.2 7205.4 7617.3 1272.5 7758
7932.8 698.2 7205.4 7617.3 1272.5  Aditya Birla Nuvo Ltd. 11871.4 15259.5
1571.9 10834.1 18851.3 7430.7 11871.4 15259.5 1571.9 10834.1 18851.3
7430.7  Alstom
T  D India Ltd. 4182.5 4035.3 -25.4 4279.5 3812.1 770.2 4182.5 4035.3 -25.4
4279.5 3812.1 770.2  B A S F India Ltd. 3799.9 4194.6 416.1 3420.5 3557.7
1406.3 3799.9 4194.6 416.1 3420.5 3557.7 1406.3  Balmer Lawrie  Co. Ltd.
6987.2 7445.8 4.1 7215.4 5750.5 1695.6 6987.2 7445.8 4.1 7215.4 5750.5
1695.6  Bhilai Engineering Corpn. Ltd. 1501.1 1378.1 152.3 1370.6 1227.4
175.1 1501.1 1378.1 152.3 1370.6 1227.4 175.1  Bombay Burmah Trdg. Corpn.
Ltd. 1846.9 1607.6 3.8 1947.5 2411.3 683.4 1846.9 1607.6 3.8 1947.5 2411.3
683.4  Clariant Chemicals (India) Ltd.
3346.5 3520.1 512.2 2951.3 2691.9 901.6 3346.5 3520.1 512.2 2951.3 2691.9
901.6 would some one help to convert into panel data format.
Thanks and regards

Ramesh Chandra Das
Doctoral Student
Vinod Gupta School of Management
Indian Institute of Technology, Kharagpur,
West Bengal, India, PIN - 721 302
Phone: 91+ 9002883115

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] why warnings message is there after running the plm regression

2014-02-14 Thread Ramesh Chandra Das
 beer - read.csv(C:/Users/Administrator/Desktop/beer.csv)
View(beer) attach(beer)The following objects are masked from chem_1:

C_SALE, CFO, Company, DISEX, PPE, REV, ROA, SALE, TA, TAC, Year
library(plm) y-cbind(TAC) x-cbind(TA,REV,PPE,ROA)
pdata-plm.data(beer,index=c(Company,Year))
pooling-plm(y~x,data=pdata,model=pooling) summary(pooling)Oneway
(individual) effect Pooling Model

Call:
plm(formula = y ~ x, data = pdata, model = pooling)

Balanced Panel: n=14, T=10, N=140

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-3.7 -0.20500 -0.00497  0.19400  1.16000

Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
(Intercept)  -0.048250   0.094661 -0.5097 0.6110848
xTA -68.865413  25.424371 -2.7086 0.0076314 **
xREV  0.363786   0.092291  3.9417 0.0001293 ***
xPPE  0.551753   0.202364  2.7265 0.0072501 **
xROA  0.953009   0.031102 30.6414  2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:426.26
Residual Sum of Squares: 32.02
R-Squared  :  0.92488
  Adj. R-Squared :  0.89185
F-statistic: 415.539 on 4 and 135 DF, p-value:  2.22e-16Warning
messages:1: In if (is.na(le)) { :
  the condition has length  1 and only the first element will be
used2: In if (is.na(le))  __no length(.)__  else if (give.length) {
:
  the condition has length  1 and only the first element will be
used3: In if (le  0) paste0([1:, paste(le), ]) else (0) :
  the condition has length  1 and only the first element will be used

 After running I found this warnings message. would some help me to find
out this problem.

Ramesh Chandra Das
Doctoral Student
Vinod Gupta School of Management
Indian Institute of Technology, Kharagpur,
West Bengal, India, PIN - 721 302
Phone: 91+ 9002883115

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] duplicate couples (time-id) Error in pdim.default(index[[1]], index[[2]]) :

2014-02-14 Thread Ramesh Chandra Das
Sir,
can you solve my problem. I did not get why this type of problem is there.
duplicate couples (time-id)Error in pdim.default(index[[1]], index[[2]]) :

Thanks and regards

Ramesh Chandra Das
Doctoral Student
Vinod Gupta School of Management
Indian Institute of Technology, Kharagpur,
West Bengal, India, PIN - 721 302
Phone: 91+ 9002883115

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] assigning cluster id in cluster package-reg.

2013-04-23 Thread Ramesh krishnan Ramasamy
Dear Sir,
  Thanks a lot for your reply. I have some doubts as follows, please
clarify me...
I am using codes from your reply
(ck3 - cutree(ag.ag, k = 3)) ##  In this step we are cutting the tress and
getting cluster assignments, on what basis you assigned k=3?
(ch6 - cutree(as.hclust(ag.ag), h = 6)) ### In this step  what we are
doing? What is h=6?? In what basis you assigned this value?
stopifnot(identical(unname(ch6), ck3))  ## what we are doing here? Moreover
i got the error like this ERROR: identical(unname(ch6), ck3) is not TRUE

I tried lot in 'cluster' user manual but i couldn't able to find any answer
for my doubts. Please suggest good articles or manuals in this area for
more information, please.

Thanks in advance

Thanking you
yours sincerely,
Ramesh




On Wed, Apr 24, 2013 at 2:53 AM, Martin Maechler maech...@stat.math.ethz.ch
 wrote:

 Well, you don't give much of an example
 I'm replying CC to the R mailing list.  Please ask questions there, rather
 than adressing individuals for basic help.


 Here is one;  does it answer your question ?

 data(agriculture)
 ag.ag - agnes(agriculture)
 class(ag.ag)
 pltree(ag.ag) # the dendrogram, if you want to see it

 ## cut the dendrogram - get cluster assignments:
 (ck3 - cutree(ag.ag, k = 3))
 (ch6 - cutree(as.hclust(ag.ag), h = 6))
 stopifnot(identical(unname(ch6), ck3))



 On Tue, Apr 23, 2013 at 6:37 PM, Ramesh krishnan Ramasamy 
 ramesh...@gmail.com wrote:

 Dear sir,
   I have large dataset of around  5,000 entries, so, i cant draw
 hierarchical cluster and see the position of accession in the cluster.  So,
 is it possible to assign cluster id to the acc automatically in the cluster
 package? For example

 cluster Id   no .
 I...
 II
 III
 I am very new to cluster package, so please help me to do this.

 Thanking you

 Regards
 Ramesh

 --
 Ramesh krishnan R
 Junior Research Fellow
 Molecular Biology Lab-1
 Central Sericultural Research  Training Institute
 Ministry of  Textiles, Govt. of India
 Srirampura, Manadavadi road
 Mysore - 570 008

 Mobile: +91 8951696997, +91 7502533038
 Email: ramesh...@gmail.com





-- 
Ramesh krishnan R
Junior Research Fellow
Molecular Biology Lab-1
Central Sericultural Research  Training Institute
Ministry of  Textiles, Govt. of India
Srirampura, Manadavadi road
Mysore - 570 008

Mobile: +91 8951696997, +91 7502533038
Email: ramesh...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] SQL PL/SQL

2011-01-10 Thread Ramesh
Your email client cannot read this email.
To view it online, please go here:
http://email.careermailer.com:2020/display.php?M=161372C=63b37a209d9dced6e8262a1862c616e4S=552L=5N=559


To stop receiving these
emails:http://email.careermailer.com:2020/unsubscribe.php?M=161372C=63b37a209d9dced6e8262a1862c616e4L=5N=552

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to Remove Autocorrelation from Simple Moving Average time series

2010-08-30 Thread Ramesh Kallol
Hi R experts,

 

I am trying to remove autocorrelation from Simple Moving Average time series. I 
know that this can be done by using seasonal ARIMA like,

 

library(TTR)

data - rnorm(252)

n=21

sma_data=SMA(data,n)

sma_data=sma_data[-1:-n]

acf(sma_data,length(sma_data))

arima=arima(sma_data,c(0,0,0),seasonal = list(order = c(0, 
0,n)));tsdiag(arima,100);arima$aic;

 

 

But is there any easy way that we can do in excel?? (Like differencing, dummy 
variable approach etc)

 

 

Thanks and Regards,

Ramesh Kallol | Amba Research

Ph +91 80 3980 8467 | Mob +91 9019720734

Bangalore * Colombo * London * New York * San José * Singapore * 
www.ambaresearch.com http://www.ambaresearch.com/ 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fitting data to Pareto distribution

2009-02-02 Thread Sukriti Ramesh
Dear All,

 

I am trying to fit some data to a Pareto distribution and would like to
estimate the parameters with the fitting. I have come across some options so
far. Unfortunately I haven't managed to get any of them to make the right
fits (as is evident when I check with the goodness of fit). One such option
is:

 

library(VGAM)

b1 - read.table(file(FitPareto_Values.txt, encoding=latin1))

b2 - as.vector(t((b1[2])))

fit = vglm(b2 ~ 1, pareto1, trace=TRUE)

 

With this code, R returns a coefficient for the intercept in the Pareto
distribution as (-1.434) and this doesn't make any practical sense for the
scenario that I am trying to model.

 

Could anyone tell me where I could be going wrong? Or could you suggest
alternative ways of fitting such data? Any help would be deeply appreciated!

 

Thanks in advance!


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.