[R] unable to run JGR in windows 7

2009-12-17 Thread Krishna
Hi,

I installed JGR as decribed on website along with all supporting packages. But 
when i start R-software JGR doesnt start. if i type "library(JGR)" in front r 
prompt, the following error is displayed.

> library(JGR)
Loading required package: iplots
Error in .jinit() : unable to find the basic String class
Error: package 'iplots' could not be loaded

I checked and re-installed iplots but still the same message is being 
displayed. i am from a non-it background intend to use for my financial data 
analysis purposes. I am using windows 7 home premium.
request for the attention and support for installin and using JGR
thanks and regards,
krishna
[[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 does ARules in R decide on LHS and RHS??

2015-05-07 Thread Krishna Kanth
I was trying to study arules in R and got stuck on this doubt:

How does arules code decide which column  to be in LHS and which in RHS?? 
  
[[alternative HTML version deleted]]

__
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] CRDW test

2009-08-12 Thread Radha Krishna
Hello All,

Could any one of you kindly let me know , if there is an R package which has
Cointegrated Regression Durbin Watson test ?

lmtest package has a function dwtest but this is not for cointegrated
systems, which uses different critical values

Regards
Radha

[[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] Numbering sequences of non-NAs in a vector

2009-07-07 Thread Krishna Tateneni
Greetings, I have a vector of the form:
[10,8,1,3,0,8,NA,NA,NA,NA,2,1,6,NA,NA,NA,0,5,1,9...]  That is, a combination
of sequences of non-missing values and missing values, with each sequence
possibly of a different length.

I'd like to create another vector which will help me pick out the sequences
of non-missing values.  For the example above, this would be:
[1,1,1,1,1,1,NA,NA,NA,NA,2,2,2,NA,NA,NA,3,3,3,3...].  The goal ultimately is
to calculate means separately for each sequence.

Your help is appreciated.  If I'm making this more complicated than
necessary, I'd appreciate knowing that as well!

Many 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] Numbering sequences of non-NAs in a vector

2009-07-07 Thread Krishna Tateneni
Many thanks to all who responded, and especially for the promptness of your
answers.  The common thread in your solutions is the use of rle, a very
useful function of which I was ignorant.

--Krishna

[[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] 2 x 2 x 10 x 2 binomial setup

2009-07-14 Thread Suresh Krishna


Hello,

I have a hierarchical dataset of this form and am trying to analyze it in  
R.


1 subject
Tested under 2 conditions: A and B
10 sesssions in each condition
In each session, 2 kinds of tests: Test 1 and Test 2
200 independent repetitions of each test-type, with 200 Yes/No answers

So I think this is a 2 x 2 x 10 x 2 setup

What I want to know is whether the difference in percentage of yes answers  
between Test1 and Test2 is different for the 2 conditions A and B. I guess  
I could also state this as looking for an effect at the highest stratum,  
after correctly pooling over all the lower strata... i.e. Is there an  
"interaction" between the Effect of Condition and the Effect of Test.


I looked through Agresti and Pinheiro/Bates and couldn't find an example  
covering this situation. I would be really grateful if you could suggest a  
way to go about this analysis in R, or a place where I could read about  
this.


I considered:

Pool data from all the sessions for a given condition and test together,  
thus getting 2000 repetitions of Test1 and Test 2 in each condition. Now I  
have a 2x2x2 setup, which maps on to something in Agresti, but then I am  
ignoring within-session correlation information.


I could simply get a difference between Test1 and Test2 percentages for  
each session, and then compare the distribution of these differences in  
conditions A and B (with something like a t-test), but then I only have 10  
points (one for each session) and so I guess I am throwing away a lot of  
information.


Very best,

Suresh

__
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] graphs

2009-07-25 Thread Radha Krishna
Hi Mary,

One can use arrows too...

Here is the code :

x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
*arrows(149,0,149,dnorm(149,140,15),length=0)
*par(new=T)
plot(x,dnorm(x,mean=150, sd=15), type='l', col='orange',axes=F)


Regards
Radha


On Sun, Jul 26, 2009 at 5:09 AM, Mary A. Marion  wrote:

> Hello,
>
> I am plotting two distributions and want to draw a vertical line at the
> critical point 149.
> How can I stop it from going further up than the norm(140,15) curve?
>
> x<-seq(75,225,0.1)
> plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
> abline(v = 149, col = "black")
> curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
>
> Thank you.
>
> Sincerely,
> Mary A. Marion
>
> __
> 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] data download from metastock into r-software

2009-12-17 Thread SNV Krishna
Hi All,

is there a way to download data from metastock to R-software. most of my data 
is in date,OHLC format downloaded from reuters to metastock software in my 
local pc. 

many thanks for the help.,

krishna

[[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] Write a blank line to CSV

2010-01-06 Thread Krishna Tateneni
Greetings and happy new year!

I'm attempting to write a series of tables to a CSV file, and would like to
insert a blank line after each table. To do this, I use:
> write.csv(NULL,"tables.csv",append=T)
which appears to work, except that this warning is thrown:
> Warning message:
> In write.table(NULL, "tables.csv", append = T, col.names = NA,  :
> appending column names to file
I tried col.names=F in the write.csv call, but the argument is ignored,
presumably because NULL does not have col.names.

Is there a better way to insert the blank lines?  Many thanks for
enlightening me!

--Krishna

[[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] Write a blank line to CSV

2010-01-06 Thread Krishna Tateneni
Perfect, thanks very much!

On Wed, Jan 6, 2010 at 10:44 AM, Gabor Grothendieck  wrote:

> Try this:
>
> cat("\n", file = "tables.csv", append = TRUE)
>
>
> On Wed, Jan 6, 2010 at 11:36 AM, Krishna Tateneni 
> wrote:
> > Greetings and happy new year!
> >
> > I'm attempting to write a series of tables to a CSV file, and would like
> to
> > insert a blank line after each table. To do this, I use:
> >> write.csv(NULL,"tables.csv",append=T)
> > which appears to work, except that this warning is thrown:
> >> Warning message:
> >> In write.table(NULL, "tables.csv", append = T, col.names = NA,  :
> >> appending column names to file
> > I tried col.names=F in the write.csv call, but the argument is ignored,
> > presumably because NULL does not have col.names.
> >
> > Is there a better way to insert the blank lines?  Many thanks for
> > enlightening me!
> >
> > --Krishna
>

[[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] nls + quasi-poisson distribution

2010-07-05 Thread Suresh Krishna


Hello R-helpers,

I would like to fit a non-linear function to data (Discrete X axis,  
over-dispersed Poisson values on the Y axis).


I found the functions gnlr in the gnlm package from Jim Lindsey: this can  
handle nonlinear regression equations for the parameters of Poisson and  
negative binomial distributions, among others. I also found the function  
nls2 in the software package accompanying the book "Statistical tools for  
nonlinear regression" by Huet et al: this can handle nonlinear regression  
with Poisson distributed Y-axis values.


I was wondering if there was any other option: specifically, any option  
that handled nonlinear fitting with quasi-Poisson distributions (to handle  
the overdispersion).


This is a very new area for me, and I am still trying to figure out the  
best way to do this, so I would appreciate any and all pointers.


Thanks much, Suresh

__
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] glm: formula vs character

2010-09-16 Thread Krishna Tateneni
Hello,

This is a question motivated by curiosity, not a pressing problem.  Any
responses are much appreciated!  In the following code, function reg1 calls
glm with a formula object while reg2 uses a string.  In both cases, glm
works; however, in the second case, the add1 function fails with the
following message: "Error in eval(predvars, data, env) : invalid 'envir'
argument."  Any insight into what is going on "under the hood"?

Many thanks,
--Krishna

x1 = rnorm(100)
x2 = rnorm(100)
x3 = rnorm(100)
y = x1 + 2*x2 + 3*x3 + 0.05*rnorm(100)

d = data.frame(y,x1,x2,x3)
xset = paste("x",1:3,sep="")

reg1<-function(dep,cand,data){
  f = paste(dep,"~1",sep="")
  reg = glm(as.formula(f),family="gaussian",data)
  add = add1(reg,cand,test="F")
}

reg2<-function(dep,cand,data){
  f = paste(dep,"~1",sep="")
  reg = glm(f,family="gaussian",data)
  add = add1(reg,cand,test="F")
}

r1 = reg1("y",xset,d)
r2 = reg2("y",xset,d)

[[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] Hmisc label function applied to data frame

2010-12-02 Thread Krishna Tateneni
Hello,

I'm attempting to create a data frame with correlations between every pair
of variables in a data frame, so that I can then sort by the value of the
correlation coefficient and see which pairs of variables are most strongly
correlated.

The sm2vec function in the corpcor library works very nicely as shown here:

library(Hmisc)
library(corpcor)

# Create example data
x1 = runif(50)
x2 = runif(50)
x3 = runif(50)
d = data.frame(x1=x1,x2=x2,x3=x3)
label(d$x1) = "Variable x1"
label(d$x2) = "Variable x2"
label(d$x3) = "Variable x3"

# Get correlations
cormat = cor(d)

# Get vector form of lower triangular elements
cors = sm2vec(cormat,diag=F)
inds = sm.index(cormat,diag=F)

# Create a data frame
var1 = dimnames(cormat)[[1]][inds[,1]]
var2 = dimnames(cormat)[[2]][inds[,2]]
lbl1 = label(d[,var1])
lbl2 = label(d[,var2])
cor_df = data.frame(Var1=lbl1,Var2=lbl2,Cor=cors)

The issue that I run into is when trying to get the labels in lbl1 and
lbl2.  I get the warning:

In mapply(FUN = label, x = x, default = default, MoreArgs = list(self =
TRUE),  :
  longer argument not a multiple of length of shorter

My usage of label seems ambiguous since the data frame could also a label
attached to it, aside from labels attached to variables within the data
frame.  However, the code above does work, with the warning.  Aside from
using a loop to get the label of one variable at a time, is there any other
way of getting the labels for all variables in the data frame?

Also, if there is a better way to achieve my goal of getting the
correlations between all variable pairs, I'd love to know.

Thanks in advance for any responses!

--Krishna

[[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] Hmisc label function applied to data frame

2010-12-05 Thread Krishna Tateneni
Hello again,

I have found that if I use sapply, I do not get a warning, i.e.,
  lbl1 = sapply(d[,var1],label)
works correctly and gives no warning.

I'm sorry this did not occur to me earlier, my apologies!

--Krishna

On Thu, Dec 2, 2010 at 11:36 AM, Krishna Tateneni wrote:

> Hello,
>
> I'm attempting to create a data frame with correlations between every pair
> of variables in a data frame, so that I can then sort by the value of the
> correlation coefficient and see which pairs of variables are most strongly
> correlated.
>
> The sm2vec function in the corpcor library works very nicely as shown here:
>
> library(Hmisc)
> library(corpcor)
>
> # Create example data
> x1 = runif(50)
> x2 = runif(50)
> x3 = runif(50)
> d = data.frame(x1=x1,x2=x2,x3=x3)
> label(d$x1) = "Variable x1"
> label(d$x2) = "Variable x2"
> label(d$x3) = "Variable x3"
>
> # Get correlations
> cormat = cor(d)
>
> # Get vector form of lower triangular elements
> cors = sm2vec(cormat,diag=F)
> inds = sm.index(cormat,diag=F)
>
> # Create a data frame
> var1 = dimnames(cormat)[[1]][inds[,1]]
> var2 = dimnames(cormat)[[2]][inds[,2]]
> lbl1 = label(d[,var1])
> lbl2 = label(d[,var2])
> cor_df = data.frame(Var1=lbl1,Var2=lbl2,Cor=cors)
>
> The issue that I run into is when trying to get the labels in lbl1 and
> lbl2.  I get the warning:
>
> In mapply(FUN = label, x = x, default = default, MoreArgs = list(self =
> TRUE),  :
>   longer argument not a multiple of length of shorter
>
> My usage of label seems ambiguous since the data frame could also a label
> attached to it, aside from labels attached to variables within the data
> frame.  However, the code above does work, with the warning.  Aside from
> using a loop to get the label of one variable at a time, is there any other
> way of getting the labels for all variables in the data frame?
>
> Also, if there is a better way to achieve my goal of getting the
> correlations between all variable pairs, I'd love to know.
>
> Thanks in advance for any responses!
>
> --Krishna
>

[[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] monthly median in a daily dataset

2010-12-21 Thread SNV Krishna
Hi Dennis,

I am looking for similar function and this post is useful. But a strange
thing is happening when I try which I couldn't figure out (details below).
Could you or anyone help me understand why this is so?

> df = data.frame(date = seq(as.Date("2010-1-1"), by = "days", length =
250))
> df$value = cumsum(rnorm(1:250))

When I use the statement (as given in ?aggregate help file) the following
error is displayed
> aggregate(df$value, by = months(df$date), FUN = median)
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  'by' must be a list

But it works when I use as was suggested 
> aggregate(value~months(date), data = df, FUN = median)
  months(date)  value
1April 15.5721440
2   August -0.1261205
3 February -1.0230631
4  January -0.9277885
5 July -2.1890907
6 June  1.3045260
7March 11.4126371
8  May  2.1625091

The second question, is it possible to have the median across the months and
years. Say I have daily data for last five years the above function will
give me the median of Jan of all the five years, while I want Jan-2010,
Jan-2009 and so... Wish my question is clear.

Any assistance will be greatly appreciated and many thanks for the same.

Regards, 

Krishna


Date: Sun, 19 Dec 2010 15:42:15 -0800
From: Dennis Murphy 
To: HUXTERE 
Cc: r-help@r-project.org
Subject: Re: [R] monthly median in a daily dataset
Message-ID:

Content-Type: text/plain

Hi:

There is a months() function associated with Date objects, so you should be
able to do something like

aggregate(value ~ months(date), data = data$flow$daily, FUN = median)

Here's a toy example because your data are not in a ready form:

df <- data.frame(date = seq(as.Date('2010-01-01'), by = 'days', length =
250),
val =  rnorm(250))
> aggregate(val ~ months(date), data = df, FUN = median)
  months(date) val
1April -0.18864817
2   August -0.16203705
3 February  0.03671700
4  January  0.04500988
5 July -0.12753151
6 June  0.09864811
7March  0.23652105
8  May  0.25879994
9September  0.53570764

HTH,
Dennis

On Sun, Dec 19, 2010 at 2:31 PM, HUXTERE  wrote:

>
> Hello,
>
> I have a multi-year dataset (see below) with date, a data value and a flag
> for the data value. I want to find the monthly median for each month in
> this
> dataset and then plot it. If anyone has suggestions they would be greatly
> apperciated. It should be noted that there are some dates with no values
> and
> they should be removed.
>
> Thanks
> Emily
>
> > print ( str(data$flow$daily) )
> 'data.frame':   16071 obs. of  3 variables:
>  $ date :Class 'Date'  num [1:16071] -1826 -1825 -1824 -1823 -1822 ...
>  $ value: num  NA NA NA NA NA NA NA NA NA NA ...
>  $ flag : chr  "" "" "" "" ...
> NULL
>
> 5202008-11-01 0.034
> 1041   2008-11-02 0.034
> 1562   2008-11-03 0.034
> 2083   2008-11-04 0.038
> 2604   2008-11-05 0.036
> 3125   2008-11-06 0.035
> 3646   2008-11-07 0.036
> 4167   2008-11-08 0.039
> 4688   2008-11-09 0.039
> 5209   2008-11-10 0.039
> 5730   2008-11-11 0.038
> 6251   2008-11-12 0.039
> 6772   2008-11-13 0.039
> 7293   2008-11-14 0.038
> 7814   2008-11-15 0.037
> 8335   2008-11-16 0.037
> 8855   2008-11-17 0.037
> 9375   2008-11-18 0.037
> 9895   2008-11-19 0.034B
> 10415  2008-11-20 0.034B
> 10935  2008-11-21 0.033B
> 11455  2008-11-22 0.034B
> 11975  2008-11-23 0.034B
> 12495  2008-11-24 0.034B
> 13016  2008-11-25 0.034B
> 13537  2008-11-26 0.033B
> 14058  2008-11-27 0.033B
> 14579  2008-11-28 0.033B
> 15068  2008-11-29 0.034B
> 15546  2008-11-30 0.035B
> 5212008-12-01 0.035B
> 1042   2008-12-02 0.034B
> 1563   2008-12-03 0.033B
> 2084   2008-12-04 0.031B
> 2605   2008-12-05 0.031B
> 3126   2008-12-06 0.031B
> 3647   2008-12-07 0.032B
> 4168   2008-12-08 0.032B
> 4689   2008-12-09 0.032B
> 5210   2008-12-10 0.033B
> 5731   2008-12-11 0.033B
> 6252   2008-12-12 0.032B
> 6773   2008-12-13 0.031B
> 7294   2008-12-14 0.030B
> 7815   2008-12-15 0.030B
> 8336   2008-12-16 0.029B
> 8856   2008-12-17 0.028B
> 9376   2008-12-18 0.028B
> 9896   2008-12-19 0.028B
> 10416  2008-12-20 0.027B
> 10936  2008-12-21 0.027B
> 11456  2008-12-22 0.028B
> 11976  2008-12-23 0.028B
> 12496  2008-12-24 0.029B
> 13017  2008-12-25 0.029B
> 13538  2008-12-26 0.029B
> 14059  2008-12-27 0.030B
> 14580  2008-12-28 0.030B
> 15069  2008-12-29 0.030B
> 15547  2008-12-30 0.031B
> 15851  2008

[R] JGR installation problem

2010-12-29 Thread SNV Krishna
Hi All,
 
I am trying to install JGR GUI for R (windows xp) but facing the problem.
The following error message is displayed when I click on JGR.exe
 
"Cannot find Java/R Interface (JRI) library (jri.dll)
Please make sure you start JGR by double clicking the JGR.exe program"
 
I know this is R help forum, but trying to get help from experts who are
using JGR.
 
Any help or idea will be highly appreciated. 
 
thanks and regards,
 
SNVK
 

[[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 subset unique factor combinations from a data frame.

2011-01-03 Thread SNV Krishna
Hi All
 
I have these questions and request members expert view on this. 
 
a) I have a dataframe (df) with five factors (identity variables) and value
(measured value). The id variables are Year, Country, Commodity, Attribute,
Unit. Value is a value for each combination of this.
 
I would like to get just the unique combination of Commodity, Attribute and
Unit. I just need the unique factor combination into a dataframe or a table.
I know aggregate and subset but dont how to use them in this context. 
 
b) Is it possible to inclue non- aggregate columns with aggregate function
 
say in the above case > aggregate(Value ~ Commodity + Attribute, data = df,
FUN = count). The use of count(Value) is just a round about to return the
combinations of Commodity & Attribute, and I would like to include 'Unit'
column in the returned data frame?
 
c) Is it possible to subset based on unique combination, some thing like
this.
 
> subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)). I
know this is not correct as it returns an error 'subset needs a logical
evaluation'. Trying various ways to accomplish the task. 
 
will be grateful for any ideas and help 
 
Regards,
 
SNVK 

[[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] how to subset unique factor combinations from a data frame.

2011-01-04 Thread SNV Krishna
Hi,

Sorry that my example is not clear. I will give an example of what each
variable holds. I hope this clearly explains the case.

Names of the dataframe (df) and description

Year :- Year is calendar year, from 1980 to 2010

Country :- is the country name, total no. (levels) of countries is ~ 190 

Commodity :- Crude oil, Sugar, Rubber, Coffee  No. (levels) of
commodities is 20

Attribute: - Production, Consumption, Stock, Import, Export... Levels ~ 20

Unit :- this is actually not a factor. It describes the unit of Attribute.
Say the unit for Coffee (commodity) - Production (attribute) is 60 kgs.
While the unit for Crude oil - Production is 1000 barrels

Value :-  value 

> tail(df, n = 10) // example data//

YearCountry Commodity   Attribute   Unit
Value
1991United Kingdom  Wheat, DurumTotal Supply(1000 MT)   70
1991United Kingdom  Wheat, DurumTY Exports  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imp. from U  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imports  (1000 MT)   60
1991United Kingdom  Wheat, DurumYield   (MT/HA) 5

Wish this is clear. Any suggestion

Regards,

SNVK

-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz] 
Sent: Tuesday, January 04, 2011 4:06 PM
To: SNV Krishna
Cc: r-help@r-project.org
Subject: Odp: [R] how to subset unique factor combinations from a data
frame.

Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:

> Hi All
> 
> I have these questions and request members expert view on this. 
> 
> a) I have a dataframe (df) with five factors (identity variables) and
value
> (measured value). The id variables are Year, Country, Commodity,
Attribute,
> Unit. Value is a value for each combination of this.
> 
> I would like to get just the unique combination of Commodity, 
> Attribute
and
> Unit. I just need the unique factor combination into a dataframe or a
table.
> I know aggregate and subset but dont how to use them in this context. 

aggregate(Value, list(Comoditiy, Atribute, Unit), function)

> 
> b) Is it possible to inclue non- aggregate columns with aggregate
function
> 
> say in the above case > aggregate(Value ~ Commodity + Attribute, data 
> =
df,
> FUN = count). The use of count(Value) is just a round about to return
the
> combinations of Commodity & Attribute, and I would like to include
'Unit'
> column in the returned data frame?

Hm. Maybe xtabs? But without any example it is only a guess.

> 
> c) Is it possible to subset based on unique combination, some thing 
> like this.
> 
> > subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)). 
I
> know this is not correct as it returns an error 'subset needs a 
> logical evaluation'. Trying various ways to accomplish the task.
> 

Probably sqldf package has tools for doing it but I do not use it so you
have to try yourself.

df[Comodity==something, c("Commodity", "Attribute", "Unit")]

can be other way.

Anyway your explanation is ambiguous. Let say you have three rows with the
same Commodity. Which row do you want to select?

Regards
Petr


> will be grateful for any ideas and help
> 
> Regards,
> 
> SNVK
> 
>[[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-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] how to subset unique factor combinations from a data frame.

2011-01-04 Thread SNV Krishna
Hi Dennis,
 
It worked! this is what I am looking for. Many thanks.
 
Rgds, 
 
SNVK
  _  

From: Dennis Murphy [mailto:djmu...@gmail.com] 
Sent: Tuesday, January 04, 2011 9:07 PM
To: SNV Krishna
Cc: r-help@r-project.org
Subject: Re: [R] how to subset unique factor combinations from a data frame.


Hi:

Did you try something like

summdf <- as.data.frame(with(df, table(Commodity, Attribute, Unit)))


? 
The rows of the table should represent the unique combinations of the three
variables

Here's a simple toy example to illustrate:
> x <- sample(LETTERS[1:6], 1000, replace = TRUE)
> xx <- sample(letters[1:6], 1000, replace = TRUE)
> u <- as.data.frame(table(x, xx))
> dim(u)
[1] 36  3
> head(u)
  x xx Freq
1 A  a   26
2 B  a   29
3 C  a   25
4 D  a   25
5 E  a   27
6 F  a   29

HTH,
Dennis


On Tue, Jan 4, 2011 at 2:19 AM, SNV Krishna  wrote:


Hi,

Sorry that my example is not clear. I will give an example of what each
variable holds. I hope this clearly explains the case.

Names of the dataframe (df) and description

Year :- Year is calendar year, from 1980 to 2010

Country :- is the country name, total no. (levels) of countries is ~ 190

Commodity :- Crude oil, Sugar, Rubber, Coffee  No. (levels) of
commodities is 20

Attribute: - Production, Consumption, Stock, Import, Export... Levels ~ 20

Unit :- this is actually not a factor. It describes the unit of Attribute.
Say the unit for Coffee (commodity) - Production (attribute) is 60 kgs.
While the unit for Crude oil - Production is 1000 barrels

Value :-  value

> tail(df, n = 10) // example data//

YearCountry Commodity   Attribute   Unit
Value
1991United Kingdom  Wheat, DurumTotal Supply(1000 MT)   70
1991United Kingdom  Wheat, DurumTY Exports  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imp. from U  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imports  (1000 MT)   60
1991United Kingdom  Wheat, DurumYield   (MT/HA) 5

Wish this is clear. Any suggestion

Regards,

SNVK

-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Sent: Tuesday, January 04, 2011 4:06 PM
To: SNV Krishna
Cc: r-help@r-project.org
Subject: Odp: [R] how to subset unique factor combinations from a data
frame.

Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:

> Hi All
>
> I have these questions and request members expert view on this.
>
> a) I have a dataframe (df) with five factors (identity variables) and
value
> (measured value). The id variables are Year, Country, Commodity,
Attribute,
> Unit. Value is a value for each combination of this.
>
> I would like to get just the unique combination of Commodity,
> Attribute
and
> Unit. I just need the unique factor combination into a dataframe or a
table.
> I know aggregate and subset but dont how to use them in this context.

aggregate(Value, list(Comoditiy, Atribute, Unit), function)

>
> b) Is it possible to inclue non- aggregate columns with aggregate
function
>
> say in the above case > aggregate(Value ~ Commodity + Attribute, data
> =
df,
> FUN = count). The use of count(Value) is just a round about to return
the
> combinations of Commodity & Attribute, and I would like to include
'Unit'
> column in the returned data frame?

Hm. Maybe xtabs? But without any example it is only a guess.

>
> c) Is it possible to subset based on unique combination, some thing
> like this.
>
> > subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)).
I
> know this is not correct as it returns an error 'subset needs a
> logical evaluation'. Trying various ways to accomplish the task.
>

Probably sqldf package has tools for doing it but I do not use it so you
have to try yourself.

df[Comodity==something, c("Commodity", "Attribute", "Unit")]

can be other way.

Anyway your explanation is ambiguous. Let say you have three rows with the
same Commodity. Which row do you want to select?

Regards
Petr


> will be grateful for any ideas and help
>
> Regards,
>
> SNVK
>
>[[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-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] stats::reshape question

2010-08-06 Thread Krishna Tateneni
Hello,

A quick question for my edification.  When I run the following (R 2.8.1 on
Microsoft Windows):

> d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
> reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")

I found myself surprised by the results--the column labeled "y" is actually
the data from "x1" and "x2", and the column labeled "x" is actually the data
from "y1" and "y2".

Is this behaviour of reshape as intended?  That is, have I missed something
in the documentation?

Many thanks for any comments.

--Krishna

[[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] stats::reshape question

2010-08-06 Thread Krishna Tateneni
Thanks for the reply, I realize that having x and y in that order in
"varying" and "v.names" will work.  The question is why reversing the order
(i.e., y followed by x) does not work; it seems unintuitive, so I'm
wondering if I've just misread the documentation.

On Fri, Aug 6, 2010 at 1:45 PM, Dennis Murphy  wrote:

> Hi:
>
> Is this what you were aiming for?
>
> reshape(d,varying=list(c("x1","x2"),
> c("y1","y2")),v.names=c("x","y"),dir="long")
> time x y id
> 1.11 1 5  1
> 2.11 2 6  2
> 1.22 3 7  1
> 2.22 4 8  2
>
> HTH,
> Dennis
>
> On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni wrote:
>
>> Hello,
>>
>> A quick question for my edification.  When I run the following (R 2.8.1 on
>> Microsoft Windows):
>>
>> > d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
>> > reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")
>>
>> I found myself surprised by the results--the column labeled "y" is
>> actually
>> the data from "x1" and "x2", and the column labeled "x" is actually the
>> data
>> from "y1" and "y2".
>>
>> Is this behaviour of reshape as intended?  That is, have I missed
>> something
>> in the documentation?
>>
>> Many thanks for any comments.
>>
>> --Krishna
>>
>>[[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] strength of seasonal component

2011-05-12 Thread SNV Krishna
Hi All,
 
a) Is it possible to estimate the strength of seasonality in timeseries
data. Say I have monthly mean prices of an ten different assets. I decompose
the data using stl() and obtain the seasonal parameter for each month. Is it
possible to order the assets based on the strength of seasonality?
 
b) which gives a better estimate on seasonality stl() or a robust linear
model like MASS::rlm(mean price ~ month), considering the fact that the
variable analysed is price series.
 
Many thanks for the insight and help
 
Regards,
 
Krishna
 

[[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] error with geomap in googleVis

2011-06-06 Thread SNV Krishna
Hi All,
 
I am unable to get the plot geomap in googleVis package. data is as follows
 
> head(index.ret)
countryytd
1 Argentina -10.18
2 Australia  -3.42
3   Austria  -2.70
4   Belgium   1.94
5Brazil  -7.16
6Canada   0.56
 
> map1 = gvisGeoMap(index.ret,locationvar = 'country', numvar = 'ytd')
> plot(map1)
 
But it just displays a blank page, showing an error symbol at the right
bottom corner. I tried demo(googleVis), it also had a similar problem. The
demo showed all other plots/maps except for those geomaps. Could any one
please hint me what/where could be the problem? Many thanks for the idea and
support. 
 
Regards,
 
SNV Krishna

 

[[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] regex help: splitting strings with no separator

2010-05-19 Thread Krishna Tateneni
Greetings,

I have a vector of values that are a word followed by a number, e.g., x =
c("Apple12","HP42","Dell91").  The goal is to split this vector into two
vectors such that the first vector contains just the words and the second
contains just the numbers.  I cannot use strsplit (or at least I do not know
how) as there is no obvious separator.

I can use sub to create a separator, e.g., y = sub("([[:digit:]])","
\\1",x), and then use strsplit, but I thought more experienced R users may
have a better solution.  I've spent some time with Google, but not turned up
anything so far.

Many thanks,
--Krishna

[[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] syntax to subset for multiple values from a single variable

2011-04-06 Thread SNV Krishna
Hi All,
 
Is it possible to use the subset() function to select data based on multiple
values of a single variable from a data frame.
 
My actual data set is much bigger and would like to illustrate with
following dataset
> df = data.frame(x = c('a','b','c','d','e','f','g','h','a','a','b','b'), y
= 1:12)
I would like to select all rows where x = a or b. 
 

> subset(df, x == c('a','b')) # this command did not return all rows where x
is equal to a or b

   x  y

1  a  1

2  b  2

9  a  9

12 b 12
 
> df[df$x %in% c('a','b'),] # subsetting using subscripts returned all rows 
   x  y

1  a  1

2  b  2

9  a  9

10 a 10

11 b 11

12 b 12
 
I know there might be a problem with subset syntax that I have used, but
could'nt figure out what it is. Any insights from members will be highly
appreciated and thanks for the same.
 
Regards,
 
S.N.V. Krishna

 

[[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 start R script editor by default

2011-08-29 Thread SNV Krishna
Hi All,
 
1) Is it possible to set the options such that R opens a new script editor
every time I start the R and 2) specify the size of windows.
 
Thanks for the suggestion and Best regards,
 
Krishna

 

[[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] text matching

2011-09-19 Thread SNV Krishna
Hi All,
 
I have a character vector by name tickers
 
> head(tickers,10)
 
V1
1  ADARSHPL.BO
2AGR.V
3  AGU
4   AGU.TO
5 AIMCO.BO
6  ALUFLUOR.BO
7AMZ.V
8  AVD
9  ANILPROD.BO
10ARIES.BO

I would like to extract all elements that has ".BO" in it. I tried 
 
> grep("\.BO",tickers)
Error: '\.' is an unrecognized escape in character string starting "\."
 
> grep(".BO",tickers)
[1] 1

Could any one please guide me on this. Many thanks for the help
 
Best Regards,
 
Krishna

[[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] text matching

2011-09-19 Thread SNV Krishna
Hi,

I noticed the mistake, first thing is double escape, so it should be "\\.BO"
instead of "\.BO" . Second and more important observation is tickers$V1.
Thanks for pointing out David and thank you all for the help.

Best regards,

Krishna

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Monday, September 19, 2011 10:10 PM
To: Sarah Goslee
Cc: SNV Krishna; r-help@r-project.org
Subject: Re: [R] text matching


On Sep 19, 2011, at 7:05 AM, Sarah Goslee wrote:

> Hi,
>
> On Mon, Sep 19, 2011 at 6:15 AM, SNV Krishna 
> wrote:
>> Hi All,
>>
>> I have a character vector by name tickers
>>
>>> head(tickers,10)
>>
>>V1
>> 1  ADARSHPL.BO
>> 2AGR.V
>> 3  AGU
>> 4   AGU.TO
>> 5 AIMCO.BO
>> 6  ALUFLUOR.BO
>> 7AMZ.V
>> 8  AVD
>> 9  ANILPROD.BO
>> 10ARIES.BO
>>
>> I would like to extract all elements that has ".BO" in it. I tried
>>
>>> grep("\.BO",tickers)
>> Error: '\.' is an unrecognized escape in character string starting 
>> "\."
>
> You need instead:
>> tickers <- c("A.BO", "BOB", "C.BO")
>> grep("\\.BO", tickers)
> [1] 1 3
>>
>> tickers[grep("\\.BO", tickers)]
> [1] "A.BO" "C.BO"
>
>
>>> grep(".BO",tickers)
>> [1] 1
>
> That's odd; it should have returned many more matches. You may need to 
> check the format of your data.

There are two NOT-oddities at work here. Periods and other special  
characters need to be doubly escaped when used as literals in search   
patterns,  and the vector that needs to be searched is not "tickers"  
but rather "tickers$V1".

That result is because there is only one element in the list named "tickers"
and grep finds that it does have an instance that matches the pattern.
(Despite that fact that it is not searching what the OP thought he was
searching for but rather a more general pattern.)

--
David.


>
>> Could any one please guide me on this. Many thanks for the help
>>
>> Best Regards,
>>
>> Krishna
>>
>
>
> -- 
> Sarah Goslee
> http://www.functionaldiversity.org
>
> __
> 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.

David Winsemius, MD
West Hartford, CT

__
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] Grouped regression

2012-07-08 Thread Suresh Krishna


Hi,

I am a very occasional user of R, and will be grateful for some help  in  
constructing a regression across groups.


Here is an example:

library(MASS)
attach(cats)
Sex[120:144]<-factor(TG) #Renaming some males to transgender, to create 3  
groups, male, female and transgender


out<-lm(Bwt~Sex/Hwt) #Gives me 3 separate linear regressions for groups M,  
F and TG


What I now want to do is to examine subsets of this, where groups F and TG  
have the same slope (and/or intercept). I want to do this in such a way  
that future calls to anova() for model comparison will recognize the  
subset structure: so I do not want to just reset the levels with F to TG  
and then examine the regression.


Thanks much,

Suresh

__
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] anova.lm and F-test

2012-07-09 Thread Suresh Krishna


Hello,

Why does anova.lm sometimes return a p-value and at other times  not ? Is  
it because it recognizes nested models from non-nested ones ?



x<-seq(1,100,1)
y<-3*x+rnorm(100)
anova(lm(y~x),lm(y~x+I(x^2)),test="F")

Analysis of Variance Table

Model 1: y ~ x
Model 2: y ~ x + I(x^2)
  Res.DfRSS Df Sum of Sq  F Pr(>F)
1 98 90.449
2 97 90.288  1   0.16117 0.1732 0.6782


anova(lm(y~x),lm(y~I(x^2)+I(x^3)),test="F")

Analysis of Variance Table

Model 1: y ~ x
Model 2: y ~ I(x^2) + I(x^3)
  Res.DfRSS Df Sum of Sq F Pr(>F)
1 98   90.4
2 97 7345.7  1   -7255.3

Thanks, Suresh

__
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] customizing help, how to replace r.css of all packages

2012-03-13 Thread SNV Krishna
Hi All,

 

I would like to replace default r.css that is found in "C:\Program
Files\R\R-2.14.2\doc\html" and "C:\Program Files\R\R-2.14.2\library\\html" with a custom r.css file. I have some 71 packages installed and
want to replace r.css across all packages. 

 

Windows explorer can aggregate the files into a single window based on
search criteria, but couldn't replace them.

 

Is it possible to do this through R-software?

 

Thanks in advance for the input and help.

 

Regards,

 

S.N.V. Krishna



 


[[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] stats::reshape question

2012-02-16 Thread Krishna Tateneni
It's been a long time since this topic was posted, but I recently had
occasion to use stats::reshape again.  This time, I looked closer at the
code for the function so I could understand what was going on.

I now realize that if the argument "varying" is a vector of names (as I
had) rather than a list (as Dennis had), the reshape function uses "split"
to create the list.  Split in turn uses "as.factor", which sorts the
variables alphanumerically.  So my inputs:
varying=c("y1","x1","y2","x2")
v.names=c("y","x")
are sent to split as:
split(varying,rep(v.names,length(varying)%/%length(v.names)))
which yields the list:
$x
[1] "x1" "x2"
$y
[1] "y1" "y2"
Note the reversal of x and y after split is used.  Unfortunately, when this
happens, the reshape function transposes the data for the "y" and "x"
variables in the long form of the data without any warning.

So to avoid the error I was running into, it is necessary to either make
sure the arguments to varying and v.names are sorted correctly, or to use a
list argument as Dennis has done.

Cheers,
Krishna

On Fri, Aug 6, 2010 at 1:53 PM, Krishna Tateneni  wrote:

> Thanks for the reply, I realize that having x and y in that order in
> "varying" and "v.names" will work.  The question is why reversing the order
> (i.e., y followed by x) does not work; it seems unintuitive, so I'm
> wondering if I've just misread the documentation.
>
>
> On Fri, Aug 6, 2010 at 1:45 PM, Dennis Murphy  wrote:
>
>> Hi:
>>
>> Is this what you were aiming for?
>>
>> reshape(d,varying=list(c("x1","x2"),
>> c("y1","y2")),v.names=c("x","y"),dir="long")
>> time x y id
>> 1.11 1 5  1
>> 2.11 2 6  2
>> 1.22 3 7  1
>> 2.22 4 8  2
>>
>> HTH,
>> Dennis
>>
>> On Fri, Aug 6, 2010 at 10:28 AM, Krishna Tateneni wrote:
>>
>>> Hello,
>>>
>>> A quick question for my edification.  When I run the following (R 2.8.1
>>> on
>>> Microsoft Windows):
>>>
>>> > d = data.frame(x1=c(1,2),x2=c(3,4),y1=c(5,6),y2=c(7,8))
>>> > reshape(d,varying=c("y1","x1","y2","x2"),v.names=c("y","x"),dir="long")
>>>
>>> I found myself surprised by the results--the column labeled "y" is
>>> actually
>>> the data from "x1" and "x2", and the column labeled "x" is actually the
>>> data
>>> from "y1" and "y2".
>>>
>>> Is this behaviour of reshape as intended?  That is, have I missed
>>> something
>>> in the documentation?
>>>
>>> Many thanks for any comments.
>>>
>>> --Krishna
>>>
>>>[[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] How to adaptively sample a simulated population of individuals

2008-05-31 Thread Krishna Pacifici
Hello,
I am looking for advice on how to adaptively sample from a simulated population.

I have simulated a population of individuals in a matrix and need to do the 
following:

1) select a random sample from that population
2) apply a function to that sample to determine if I detect any individuals at 
each of the referenced site locations [i,j] in the matrix

3) then if I detect any individuals after that first function (adaptive 
condition y[i,j] > 0) I need to sample the 4 adjacent plots in that matrix 
[i,j+1]; [i,j-1]; [i+1,j]; [i-1,j]

4) apply that function to those adjacent plots to see if I detect any 
individuals 
5) continue in that fashion to eventually develop a network

I have already simulated the population with spatial dependence (used a 
gamma-poisson mixture), so that in each [i,j] site there is a number of 
individuals such that the the adjacent sites (contained in a 4x3 sub-matrix) 
are distributed via the same lambda from a poisson distribution, but each 4x3 
sub-matrix has a unique lambda describing the distribution.  I have then been 
able to sample from that population using the sampling package and have been 
able to apply the function to determine if I detect any individuals.  

The real problem is how to adapt the sampling protocol to the adjacent plots in 
the matrix given I have initially detected an individual.  I am not sure what 
the best approach is to do this.  I have thought that because I have the 
population simulated in a matrix I already have spatially referenced 
information about the population through the [i,j] locations in the matrix, but 
am not sure if this is enough spatially referenced information and if it is how 
do I apply the function to the adjacent sites.  An alternative would be to 
assign spatial coordinates to the sites so that they are referenced or put it 
into a data.frame that would keep the locations and the numbers of individuals 
at each of those locations.  I am not sure if this is possible ( I am guessing 
it is) and if so how to do it.

Any advice on how to do this or where to start would be greatly appreciated.  

Thank you very much,
Krishna 

Krishna Pacifici
Ph.D. Student
Georgia Cooperative Fish and Wildlife Unit
Warnell School of Forestry and Natural Resources
University of Georgia
Athens, GA 30602
(706) 248-9968

__
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] R and reading matlab compressed files

2007-11-21 Thread Suresh Krishna

One possibility is to save in ASCII format from Matlab (save -ascii)

Suresh

> On 17/11/2007, Prof Leslie Smith <[EMAIL PROTECTED]> wrote:
>> Is there any way to read these files (standard .mat files, created by
>> matlab version 7 onwards are compressed)? I know that R.matlab doesn't
>> read them (it even says in the file MatlabServer.m "Matlab v7 saves
>> compressed files, which is not recognized by R.matlab's readMat()"  
>> (lines
>> 47-8)).
>>
>> I know I should be able to make R call Matlab and transfer data (not  
>> that
>> I managed to make it work yet!), but I'd rather not run Matlab & R
>> together: I'd like to use R to read matlab files on machines not  
>> licensed
>> for matlab!
>>
>> Are there any ways to make this work?
>>
>> --Leslie Smith
>>
>> --
>> Prof Leslie Smith
>> Computing Science and Maths
>> University of Stirling FK9 4LA
>> Scotland
>> Tel (44) 1786 467435
>>
>> --
>> The University of Stirling is a university established  
>> i...{{dropped:11}}
>>
>> __
>> 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-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] locfit smoothing question (package maintainer not reachable)

2009-03-03 Thread Suresh Krishna


Dear list members,

I am trying to understand this output from the smoothing package locfit  
(1.5-4, running on R 2.8.1 on Windows Vista 64 bit).


# sample code

x<-1:100

y<-rnorm(100)
fit<-locfit(y~x,family="gaussian") #default parameters are fine
plot(fit,band="global")  #plot seems "reasonable", confidence bands use a  
global estimate of variance


y<-1000*rnorm(100)
fit<-locfit(y~x,family="gaussian")
plot(fit,band="global") #aren't these confidence bands too small ? am i  
using this function wrongly ?


Using band="local" gives results that seem to make "more sense". Could  
someone offer me some guidance ?


Thanks, Suresh

ps. The package maintainer, Catherine Loader, is no longer reachable at  
her Auckland address.


__
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] locfit smoothing question (package maintainer not reachable)

2009-03-03 Thread Suresh Krishna


Dear all,

I just realized that using family="qgauss" restores normal-looking  
confidence bands... I read that using family="gaussian" rather than  
family="qgauss" fixes the dispersion parameter at 1, but without knowing  
the theory behind the code, I dont understand why there is such a  
difference between the two. If there is a simple explanation or  
recommendation, I am eager to hear it.


Thanks, Suresh


On Tue, 03 Mar 2009 16:56:43 +0100, Suresh Krishna   
wrote:




Dear list members,

I am trying to understand this output from the smoothing package locfit  
(1.5-4, running on R 2.8.1 on Windows Vista 64 bit).


# sample code

x<-1:100

y<-rnorm(100)
fit<-locfit(y~x,family="gaussian") #default parameters are fine
plot(fit,band="global")  #plot seems "reasonable", confidence bands use  
a global estimate of variance


y<-1000*rnorm(100)
fit<-locfit(y~x,family="gaussian")
plot(fit,band="global") #aren't these confidence bands too small ? am i  
using this function wrongly ?


Using band="local" gives results that seem to make "more sense". Could  
someone offer me some guidance ?


Thanks, Suresh

ps. The package maintainer, Catherine Loader, is no longer reachable at  
her Auckland address.





__
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] locfit smoothing question (package maintainer not reachable)

2009-03-03 Thread Suresh Krishna


David Winsemis wrote:

I think you should read (or re-read)  the locfit help page and *also*  
the links from that page to the help pages for locfit.raw and rv. I  
would have thought that since family= is not an argument to locfit per  
se, but rather is documented in locfit.raw that you have yet done so,  
but perhaps not?


I did read the help pages for locfit.raw, and found:

"Local likelihood family; "gaussian"; "binomial"; "poisson"; "gamma" and  
"geom". Density and rate estimation families are "dens", "rate" and  
"hazard" (hazard rate). If the family is preceded by a 'q' (for example,  
family="qbinomial"), quasi-likelihood variance estimates are used.  
Otherwise, the residual variance (rv) is fixed at 1. The default family is  
"qgauss" if a response y is provided; "density" if no response is  
provided. "


However, since the fake data were generated from a known gaussian  
distribution, I did not imagine that using family=gaussian would lead to  
such wildly different results. This is what I was hoping to understand,  
without having to struggle with Catherine's Loader book in order to  
understand the above paragraph deeply enough that this behavior makes  
sense.


Thanks again, Suresh

__
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] locfit smoothing question (package maintainer not reachable)

2009-03-04 Thread Suresh Krishna
On Tue, 03 Mar 2009 22:10:42 +0100, David Winsemius  
 wrote:


That is what I thought to be the critical paragraph. The variance is  
assumed to be = 1 when you use family="gaussian" rather than the default  
of family="qgauss". You give it a vector, 1000*rnorm(100), that ranges  
widely and a small (relative) variance is assumed and so the confidence  
intervals are plotted as very narrow. This does not seem surprising  
given the functions documented design. I have the book and do not think  
I even need to pull it off the shelf since the help pages appear fully  
informative in this instance. I get an rv of 1 with the "gaussian"  
option and an rv of nearly 1000 when the default is used.




Thank you, that is helpful. I guess I am wondering under what circumstance  
would it be appropriate to assume that the data had a variance of 1 and  
use the family=gaussian option. Perhaps this is for normalized data ?


Suresh

__
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] R newbie: how to replace string/regular expression

2008-11-03 Thread Krishna Dagli
On Mon, Nov 3, 2008 at 3:36 AM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> I did provide a link to that solution already but also wanted to
> show how to do it in the same way that the code in the question
> was written.

Thanks for pointing me in right direction, both solutions are wonderful.
Yes I made a mistake for 100k.

I have one doubt though, how does one locate packages that's
available for specific task (like this one). Does one look at package
index (http://cran.cnr.berkeley.edu/web/packages/index.html).
or is there any other trick?

I tried "help.search("string")" and also looked at help.start()
but I think it just displays whats available on my machine.

Regards and Thanks
Krishna

__
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] socket server, textConnection and readLines

2008-12-16 Thread Krishna Dagli
Hello;

This is bit long email but hope someone can guide me.

I have questions regarding socket, readLines and textConnection. I am
not sure if my code is efficient (due to textConnection) and how to
handle client disconnect and restart of the socket server in R.

I have a huge(3.5+G) text file on machine 'A', which I want to process
on machine 'B' using read.table (one line or a chunk at a time). On
machine B, I would like to use NWS and multiple R scripts to process
each line/chunk.

To do this I am running netcat (http://netcat.sourceforge.net/) on
macine 'A' and sending data to machine 'B's R socket server.

Here is the data that I have on machine 'A'

---data---
RELIANCE,1200.00,03-NOV-2008,09:00:02:286
RELIANCE,1200.20,03-NOV-2008,09:00:02:287
RELIANCE,1200.10,03-NOV-2008,09:00:02:289
RELIANCE,1201.10,03-NOV-2008,09:00:02:310
INFOSYSTCH,1400.00,03-NOV-2008,09:00:02:286
INFOSYSTCH,1400.20,03-NOV-2008,09:00:02:287
INFOSYSTCH,1400.10,03-NOV-2008,09:00:02:289
INFOSYSTCH,1401.10,03-NOV-2008,09:00:02:310
---end data---


Here is the code that I am using for reading this data on machine 'B'.

---code---
a.connection <- socketConnection(host = 'localhost', 1234,
 server = TRUE,
 blocking = TRUE,
 open = "r",
 encoding = getOption("encoding")
 )
while(1) {
  line.raw <- NULL;
  line.raw <- readLines( a.connection, n = 1, ok = TRUE);
  tConnection <- textConnection(line.raw);
  line.data <- read.table(tConnection);
  if ( (class(line.data) == 'try-error') ||
 (length(line.data) <= 0)) {
print ("may be client is disconnected! ");
break;
  }
  # validate line.data and store it using
  print (line.data);
  close(tConnection);
}
---end code---

Questions:

1) Is there a way to avoid creation and closing of textConnection in
   above code? How can I directly read a line over socket in R?
   If I do not explicitly close the connection I get an warning message
   saying  "closing unused connection 7 (line.raw)".

2) What is the best way to detect that client is disconnected?

3) In C, we can create a socket, bind it but do accept() in side a
   while loop using select() call but how do I do the same in R.


Thanks again for reading such a long email and thanks in advance for
your pointers.

Thanks and Regards
Krishna

__
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] help with SSOAP (can't find working examples)

2009-11-02 Thread Hari Krishna Dara
First of all, let me confess that I am a newbie to R and don't know
much about the language or the environment. We have a need for
plugging in R in our production runtime and need the ability to pull
data out of our existing services. I am trying to see if I can take
advantage of SSOAP such that we can expose the data via webservices
and use SSOAP to call into them. Our runtime is mostly composed of
python, so the idea is to use rpy2 to interface from python to R, and
use SSOAP to call back into python modules where needed.

Now the problem is that I have hard time trying to find a single
example that works. I am using windows and here are the version
numbers:

R: 2.9.2
SSOAP: 0.5-3
XMLSchema: 0.1-1
XML: 2.6-0

The packages are up to date as per "Update packages". I tried all the
examples that came under library/SSOAP/examples directory and most
failed during genSOAPClientInterface(), while one failed right in
processWSDL(). This is the most common error during
genSOAPClientInterface():

Error in paste(" .elementFormQualified", .elementFormQualified, sep = " = ") :
  no slot of name "elementFormQualified" for this object of class "SchemaTypes"

There was only one reference to this error in the archives, and it
seems like the OP got the problem solved after updating XMLSchema
(which happened to be the same version as what I have). I tried a
couple of WSDL's that I have for creating python webservices, as well
as a "hello world" example, and they all have the same error as well.
While KEGG.wsdl, and others gave the above error, the eutils.wsdl gave
me the below error:

Error: Cannot resolve SOAP type in empty context

Interop.wsdl got me the below error:

Error: Cannot resolve string in SchemaCollection

nwis.wsdl failes in processWSDL() itself, with the below error:

Error in parse(text = paste(txt, collapse = "\n")) :
  unexpected input in "function(x, ..., obj = new( ‘"

I am most interested in solving the first error that I reported (as
the rest might be real issues with the wsdl syntax). Here is the full
output for KEGG.wsdl:

[1] "ArrayOfstring"
defining class ArrayOfstring
defining setAs() for ArrayOfstring
[1] "SSDBRelation"
defining class SSDBRelation
defining setAs() for SSDBRelation
[1] "ArrayOfSSDBRelation"
defining class ArrayOfSSDBRelation
defining setAs() for ArrayOfSSDBRelation
[1] "MotifResult"
defining class MotifResult
defining setAs() for MotifResult
[1] "ArrayOfMotifResult"
defining class ArrayOfMotifResult
defining setAs() for ArrayOfMotifResult
[1] "Definition"
defining class Definition
defining setAs() for Definition
[1] "ArrayOfDefinition"
defining class ArrayOfDefinition
defining setAs() for ArrayOfDefinition
[1] "LinkDBRelation"
defining class LinkDBRelation
defining setAs() for LinkDBRelation
[1] "ArrayOfLinkDBRelation"
defining class ArrayOfLinkDBRelation
defining setAs() for ArrayOfLinkDBRelation
Operation list_databases
resolve(, SchemaCollection) ArrayOfDefinition
resolve(, list) ArrayOfDefinition
Note: Method with signature "ArrayType#list" chosen for function "resolve",
 target signature "ArrayType#SchemaCollection".
 "SimpleSequenceType#SchemaCollection" would also be valid
Error in paste(" .elementFormQualified", .elementFormQualified, sep = " = ") :
  no slot of name "elementFormQualified" for this object of class "SchemaTypes"
In addition: Warning message:
In .findOrCopyClass(class2, classDef2, where, "subclass") :
  Class "VirtualXMLSchemaClass" is defined (with package slot
"XMLSchema") but no metadata object found to revise subclass
information---not exported?  Making a copy in package ".GlobalEnv"

I am not an expert in web services and WSDL, but I did compare them
with a few public WSDL samples and couldn't really make out an issue.
I would really appreciate any help or information in getting SSOAP to
work in my environment. Hopefully it is something trivial, like a
configuration issue.

And one more thing, I found version 0.5.4 of SSOAP at omegahat.org
website and tried that out as well, but it didn't make any difference.
I found a newer version of XMLSchema as well, but it didn't install
(with compilation errors). I have activeperl and mingw in the path.

Thank you,
Hari

__
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] issues with SSOAP when wsdl has ComplexTypes

2009-11-05 Thread Hari Krishna Dara
I recently started trying R and SSOAP and was able to successfully try a "hello
world" service. I am now trying to get a more complicated interface to work with
SSOAP and so far failed miserably at that and so need any help I can
get from here.

The service I am attaching is a prototype for a full service that would
take information to identify a data source and a query to run and
return a tabular
data (a sql query result or a dataframe in R).

Note: If you are impatient to read the long email, you may skip to the
description of
"Third attempt"

First attempt: I have a ServiceInfo type as part of the request, that has two
components, a clientID that is an int and a serviceInfoType that is an enum. I
was able to create the ServiceInfo class object and was able to make the
function call, but I was getting an error in the toSOAP().

> sinfo = c(clientId=1, serviceType='Engine')
> class(sinfo) <- d...@classes$`soap/DataService`$ServiceInfo
> res = d...@functions$simplequery(sinfo, 'select 1 as One')
Loading required package: bitops
Error in toSOAP(argValues[[i]], methodCall, type = typedef,
literal = .literal) :
  No code yet for the toSOAP method for any object and
ClassDefinition pair with literal = FALSE

Second attempt: I then flattened the ServiceInfo such that the clientId and
sericeType are passed inline to bypass the above error. SSOAP went past that but
complained about a missing elType (seems to not like the enum).

> res = d...@functions$simplequery(1, 'Engine', 'select 1 as One')
Error in toSOAPArray(obj, con, type = type, literal = literal, ...) :
  no slot of name "elType" for this object of class
"RestrictedStringDefinition"

Third attmept: To bypass the above error as well, I then changed serviceType to
string. SSOAP then actually made a successful call, and the webservice returned
a response. However, now SSOAP failed to deserialize it with the below error

> res = d...@functions$simplequery(1, 'Engine', 'select 1 as One')
Error in as(from, "QueryResultRow") :
  no method or default for coercing "XMLInternalElementNode" to
"QueryResultRow"

I have since then created a standalone version of the service that only takes
the query (no clientId and serviceType) and attached the code. The service is
written in python using ZSI, and there is ZSI client code in the comments that
shows how to use it from a python client (which btw, works as expected). The
code doesn't actually execute the query, it simply fills in dummy data into the
result, so all that you need to try the sample is python 2.6 and ZSI
(http://pywebsvcs.sourceforge.net/). The comment also has sample R client code
which I am paste below:

library(SSOAP)
dataService <-
processWSDL('C:/src/tmp/python/webserv/dataService/DataService.wsdl')
def = genSOAPClientInterface(def = dataService, verbose = TRUE)
res = d...@functions$simplequery('select 1 as One')

At this point, my priority is to get the deserialization of the response
working, as I am able to workaround the first two issues in sending request. I
would really appreciate if anyone can help me in solving this problem.

Here is some more information on getting the python sample to work.
- Save the wsdl and py file in the same directory.
- After installing python 2.6 and ZSI, run the below commands:
$ wsdl2py --complexType --file DataService.wsdl
$ wsdl2dispatch --file DataService.wsdl
- Run the below command to start the service:
$ python DataService.py
- Start another python shell and run the below commands to see it in action:
$ python
>>> import sys
>>> from DataService_services import *
>>> loc = DataServiceServiceLocator()
>>> service = loc.getDataServicePortType(tracefile=sys.stdout)
>>> req = DataServiceQueryRequest()
>>> req.Query = "select 1 as One"
>>> res = service.simpleQuery(req)
>>> print "Field names: %s" % [field.StringValue for field in
...res.Result.ResultHeading.QueryFields]
>>> print "Rows:"
>>> for i in xrange(0, len(res.Result.ResultRows)):
>>> print "Row %d: %s" % (i+1, [field.StringValue or
... field.LongValue or field.DoubleValue for field in
... res.Result.ResultRows[i].QueryFields])

Please let me know if you need any more information on the problem or getting
the python sample to work.

Thank you,
Hari
__
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] summary(list) is awesome, but I want more than summary

2011-01-08 Thread Krishna Kirti Das
When I load a table from a data source and run summary() on it, the
summary gives me basic summary statistics I'm looking for, and it also
discriminates between quantitative and qualitative data and summarizes
them accordingly. For example, if I do this:

 mydata <- read.table("data.txt")
 summary(mydata)

I would get output like this:


> summary(mydata)
County
 BERNALILLO:2863
 DONA ANA  : 772
 SANTA FE  : 671
 SANDOVAL  : 579
 SAN JUAN  : 471
 VALENCIA  : 281
 (Other)   :2863

   Votemode2010
  Min.   : 1.000
  1st Qu.: 3.000
  Median : 4.000
  Mean   : 3.942
  3rd Qu.: 5.000
  Max.   : 6.000
  NA's   :11.000

Notice how for the first table the summary simply reports the
frequencies of the qualitative data and in the second table it gives
me a five-number summary for the quantitative data.

Now, here is what I'm looking for. I like how the summary function
dumps either frequency summary or a five number summary depending on
what the data is, but what I really would like is something like what
summary does for the quantitative data, but that it gives me the
frequency for all the rest of the values "(Other)" not reported in the
summary. In other words, how do I make the summary function give me
not a summary but everything? I would like all frequencies, not just
the top five.

I shall be obliged.

All the best,

KKD

__
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] Unbalanced Anova: What is the best approach?

2011-04-03 Thread Krishna Kirti Das
I have a three-way unbalanced ANOVA that I need to calculate (fixed effects
plus interactions, no random effects). But word has it that aov() is good
only for balanced designs. I have seen a number of different recommendations
for working with unbalanced designs, but they seem to differ widely (car,
nlme, lme4, etc.). So I would like to know what is the best or most usual
way to go about working with unbalanced designs and extracting a reliable
ANOVA table from them in R?

[[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] Unbalanced Anova: What is the best approach?

2011-04-03 Thread Krishna Kirti Das
Thank you, John.

Yes, your answers do help. For me it's mainly about getting familiar with
the "R" way of doing things.

Thus your response also confirms what I suspected, that there is no explicit
user-interface (at least one that is widely used) in terms of
functions/packages that represents an unbalanced design in the same way that
aov would represent a balanced one. Analyzing balanced and unbalanced data
are obviously possible, but with balanced designs via aov what has to be
done is intuitive within the language but unintuitive for unbalanced
designs.

I did notice that this question gets asked several times and in slightly
different ways, and I think the lack of an interface that represents an
unbalanced design in the same way aov represents balanced designs is why the
question will probably keep getting asked again.

I had mentioned nlme and lme4 because I saw in some of the discussions that
using those were recommended for working with unbalanced designs. And
specifying random effects with zero variance, for example, would probably
serve my purposes.

Thank you for your help.

Sincerely,

Krishna

On Sun, Apr 3, 2011 at 7:28 AM, John Fox  wrote:

> Dear Krishna,
>
> Although it's difficult to explain briefly, I'd argue that balanced and
> unbalanced ANOVA are not fundamentally different, in that the focus should
> be on the hypotheses that are tested, and these are naturally expressed as
> functions of cell means and marginal means. For example, in a two-way
> ANOVA,
> the null hypotheses of no interaction is equivalent to parallel profiles of
> cell means for one factor across levels of the other. What is different,
> though, is that in a balanced ANOVA all common approaches to constructing
> an
> ANOVA table coincide.
>
> Without getting into the explanation in detail (which you can find in a
> text
> like my Applied Regression Analysis and Generalized Linear Models),
> so-called type-I (or sequential) tests, such as those performed by the
> standard anova() function in R, test hypotheses that are rarely of
> substantive interest, and, even when they are, are of interest only by
> accident. So-called type-II tests, such as those performed by default by
> the
> Anova() function in the car package, test hypotheses that are almost always
> of interest. Type-III tests, which the Anova() function in car can perform
> optionally, require careful formulation of the model for the hypotheses
> tested to be sensible, and even then have less power than corresponding
> type-II tests in the circumstances in which a test would be of interest.
>
> Since you're addressing fixed-effects models, I'm not sure why you
> introduced nlme and lme4 into the discussion, but I note that Anova() in
> the
> car package has methods that can produce type-II and -III Wald tests for
> the
> fixed effects in mixed models fit by lme() and lmer().
>
> Your question has been asked several times before on the r-help list. For
> example, if you enter terms like "type-II" or "unbalanced ANOVA" in the
> RSeek search engine and look under the "Support Lists" tab, you'll see many
> hits -- e.g.,
> https://stat.ethz.ch/pipermail/r-help/2006-August/111927.html>.
>
> I hope this helps,
>  John
>
> 
> John Fox
> Senator William McMaster
>  Professor of Social Statistics
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox
>
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> > On Behalf Of Krishna Kirti Das
> > Sent: April-03-11 3:25 AM
> > To: r-help@r-project.org
> > Subject: [R] Unbalanced Anova: What is the best approach?
> >
> > I have a three-way unbalanced ANOVA that I need to calculate (fixed
> > effects plus interactions, no random effects). But word has it that aov()
> > is good only for balanced designs. I have seen a number of different
> > recommendations for working with unbalanced designs, but they seem to
> > differ widely (car, nlme, lme4, etc.). So I would like to know what is
> the
> > best or most usual way to go about working with unbalanced designs and
> > extracting a reliable ANOVA table from them in R?
> >
> >   [[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.


Re: [R] Unbalanced Anova: What is the best approach?

2011-04-03 Thread Krishna Kirti Das
On Sun, Apr 3, 2011 at 3:10 AM, peter dalgaard  wrote:

>
> On Apr 3, 2011, at 09:24 , Krishna Kirti Das wrote:
>
> > I have a three-way unbalanced ANOVA that I need to calculate (fixed
> effects
> > plus interactions, no random effects). But word has it that aov() is good
> > only for balanced designs. I have seen a number of different
> recommendations
> > for working with unbalanced designs, but they seem to differ widely (car,
> > nlme, lme4, etc.). So I would like to know what is the best or most usual
> > way to go about working with unbalanced designs and extracting a reliable
> > ANOVA table from them in R?
>
> Actually, without random effects, aov() is not too crazy, but you might as
> well use plain lm(). In both cases, the main point is that you need to be
> aware that there is no such thing as "the" ANOVA table: Sums of squares will
> depend on the order of testing, and there is nothing to do about that
> (except getting balanced data).
>
> Pragmatically, I'd test the three-factor interaction, then use drop1() on a
> model with two-factor interactions, if nothing glaringly obvious pops up,
> try reduction to additive model and then use drop1() again. Obviously, if
> significant interactions appear, you cannot just remove them and need to
> investigate what they mean.
>
> That helps. And I've been looking for something like drop1() for a while
now.

Thank you.

Sincerely,

Krishna

[[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] rJava Package

2014-11-26 Thread Krishna Bhargava S K
Hi All,

I am a beginner to R. I have installed tried a sample of JRI 
using Rengine and Rserve.
I found normalization and sqrt function in some sample code.
Is there any link where there is a list of functions that is 
provided in R which I can use to process data in java programs.

Regards
KB

L&T Technology Services Ltd

www.LntTechservices.com

This Email may contain confidential or privileged information for the intended 
recipient (s). If you are not the intended recipient, please do not use or 
disseminate the information, notify the sender and delete it from your system.

[[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] problem loading large xlsx file into r

2013-07-21 Thread S N V Krishna
Hi,

I am facing trouble when trying to read large xlsx file into R. please find the 
code and error below. The file I was trying to read has 36,500 rows X 188 col, 
~ 37 MB size.

> options( java.parameters = "-Xmx4g" )

> library(xlsx)
Loading required package: xlsxjars
Loading required package: rJava

> cftc = read.xlsx("d:\\Krishna\\Research\\CFTC_COT\\cftcdata.xlsx", 1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.OutOfMemoryError: Java heap space

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] xlsx_0.5.1 xlsxjars_0.5.0 rJava_0.9-5

Many thanks for the help and guidance.

Regards,

Krishna

[[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] problem loading large xlsx file into r

2013-07-22 Thread S N V Krishna
Thanks Jim, I tried XLConnect but faced with same error.

> options(java.parameters = '-Xmx5g')

> library(XLConnect)
Loading required package: rJava
XLConnect 0.2-5 by Mirai Solutions GmbH
http://www.mirai-solutions.com ,
http://miraisolutions.wordpress.com

> cftc = 
> readWorksheetFromFile("d:\\Krishna\\Research\\CFTC_COT\\cftcdata.xlsx", sheet 
> = 'Sheet1')
Error: OutOfMemoryError (Java): Java heap space

What is the maximum file size to load into R? is there a better way to load 
large excel files to R?

Many thanks for the help.

Regards, 

Krishna

-Original Message-
From: Jim Holtman [mailto:jholt...@gmail.com] 
Sent: Monday, July 22, 2013 5:10 PM
To: S N V Krishna
Cc: r-help@r-project.org
Subject: Re: [R] problem loading large xlsx file into r

try the "XLConnect" package and if possible change the "xlsx" to "xls" format 
for better performance.

Sent from my iPad

On Jul 22, 2013, at 1:24, S N V Krishna  wrote:

> Hi,
> 
> I am facing trouble when trying to read large xlsx file into R. please find 
> the code and error below. The file I was trying to read has 36,500 rows X 188 
> col, ~ 37 MB size.
> 
>> options( java.parameters = "-Xmx4g" )
> 
>> library(xlsx)
> Loading required package: xlsxjars
> Loading required package: rJava
> 
>> cftc = read.xlsx("d:\\Krishna\\Research\\CFTC_COT\\cftcdata.xlsx", 1)
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
>  
> 
>> sessionInfo()
> R version 3.0.1 (2013-05-16)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
> States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C 
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> other attached packages:
> [1] xlsx_0.5.1 xlsxjars_0.5.0 rJava_0.9-5
> 
> Many thanks for the help and guidance.
> 
> Regards,
> 
> Krishna
> 
>[[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-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] Can anyone help why the errors are coming and rectify it?

2012-09-17 Thread Sri krishna Devarayalu Balanagu
Hi Everyone,

Can anyone help why the errors are coming and rectify it?


invalid.ids <- c(1,3,5)
if (length(invalid.ids)==0)   {

cat("No Errors found")
   }
else  {

cat(paste(invalid.ids), sep="\n")
  }

Error: unexpected 'else' in "else"
Error: unexpected '}' in "}"

Thank you in advance

Warm Regards
Rayalu
Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] I want to send the vector a into the Object A.......

2012-09-17 Thread Sri krishna Devarayalu Balanagu
a=c(1,2,3)
b=c(23, 24, 25)
x=c("a", "b")
#if (length(x[1]) == 0) {cat("x[1] is having 3 elements")}

Suppose I want to send the vector a into the Object A,
um getting only "a" as the ouput for Object A but not getting required output 
as the vector with the elements 1, 2, 3 with  the following code

A<- x[1]

How to code it?
Can anyone help?
Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] I want to send the vector a into the Object A.......

2012-09-18 Thread Sri krishna Devarayalu Balanagu
Thank you very much
I am having one more doubt. Please clarify it, if possible.

x = c("a", "b", "c", "d", "e")
suppose I want to create an object named "a.Arms" with the elements 1,2,3. I am 
trying with following code. But getting error

paste(x[1], ".Arms", sep="") <- c(1,2,3)
Error: could not find function "paste<-"
Can you pls help

From: Jean V Adams [mailto:jvad...@usgs.gov]
Sent: Monday, September 17, 2012 10:24 PM
To: Sri krishna Devarayalu Balanagu
Cc: r-help@r-project.org
Subject: Re: [R] I want to send the vector a into the Object A...

Try this.

A <- get(x[1])

Jean


Sri krishna Devarayalu Balanagu  wrote on 
09/17/2012 07:13:51 AM:
>
> a=c(1,2,3)
> b=c(23, 24, 25)
> x=c("a", "b")
> #if (length(x[1]) == 0) {cat("x[1] is having 3 elements")}
>
> Suppose I want to send the vector a into the Object A,
> um getting only "a" as the ouput for Object A but not getting
> required output as the vector with the elements 1, 2, 3 with  the
> following code
>
> A<- x[1]
>
> How to code it?
> Can anyone help?
Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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 x[1] is not getting substituted?

2012-09-18 Thread Sri krishna Devarayalu Balanagu
Suppose I want the output as "Trial and a sheet" without quotes
x=c("a", "b", "c")
print("Trial and x[1] sheet")

Getting  "Trial and x[1] sheet"

Can anyone help?
Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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 get rid of page 1 and 4 i.e Only dots pages while generating the graphs?

2012-10-12 Thread Sri krishna Devarayalu Balanagu
Suppose I have "Orange1" data like this.

TIME1

RESPONSE

RESPSTAT

RESPUT

REFID

ARM

SUBARM

0

299.5

Mean

8-item scale

68

0

0

0

287

Median

8-item scale

68

0

0

0

303.9

Mean

8-item scale

68

1

0

0

286

Median

8-item scale

68

1

0

0

295

Mean

8-item scale

85

0

0

12

254

Mean

8-item scale

85

0

0

0

287

Mean

8-item scale

85

1

0

12

216

Mean

8-item scale

85

1

0

0

306

Mean

8-item scale

85

2

0

12

218

Mean

8-item scale

85

2

0

0

273

Mean

8-item scale

18

0

0

1

258.003

Mean

8-item scale

18

0

0

2

261.392

Mean

8-item scale

18

0

0

4

250.812

Mean

8-item scale

18

0

0

0

258

Mean

8-item scale

18

1

0

1

226.153

Mean

8-item scale

18

1

0

2

213.41

Mean

8-item scale

18

1

0

4

206.781

Mean

8-item scale

18

1

0


While I am generating graphs for the above data I am getting four graphs in 
four pages in a pdf with the following programme.

Page1: Only dots (No lines)
Page2: Lines observed
Page3: Lines observed
Page4: Only dots (No lines)

I want to get rid of page 1 and 4 i.e Only dots pages while generating the 
graphs.
So that the pdf should contain only two pages(Page 2 & 3)
Can anyone help?


unique(Orange1$RESPSTAT) -> change
pdf("CDAI Response.pdf")
for (j in 1:length(change)){
((Orange1$RESPUT == "8-item scale")&(Orange1$RESPSTAT == change[j])) -> b
FD <- Orange1[b, ]
unique(FD$REFID) -> refid
for (i in refid)
{
Orange2 <- FD[i == FD$REFID, ]
Orange2$ARM<- factor(Orange2$ARM)
unique(Orange2$RESPSTAT) -> x
y <- paste("REFID=", i,"; ", "RESPSTAT=", x, sep="")
print(qplot(TIME1, RESPONSE, data=Orange2, geom= c("line", "point"), 
colour=ARM, main=y))
}
}
dev.off()
Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] EOF error reading csv file

2014-06-20 Thread S N V Krishna
Hi,

I am confronted with this error while trying to read csv file into R session.
Though it is warning message, I noticed that the whole file was not read 
properly.
After having gone through the whole file, unable to identify error in file. I 
am copying the last 2 rows in original csv file after which the reading was not 
proper. (cannot enclose file because of big size)

TRANSCONTINENTAL GAS - ZONE 6 (NY) (BASIS) - ICE FUTURES ENERGY DIV

2/25/2014

81271

51032

37508

14592

31154

1710

0

1490

1296

943

0

341

69914

73499

11357

7772

WAHA HUB - WEST TEXAS DELIVERED/BUYER'S INDEX - ICE FUTURES ENERGY DIV

2/25/2014

14232

13331

11786

0

0

0

0

615

0

280

0

0

13611

12401

621

1831



Can someone go through the same and suggest what I am missing out.

> cftc = read.table("cftcdata_ncn.csv", sep = ',', header = TRUE, fill = TRUE)
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  EOF within quoted string

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
>
Many thanks for the help.

Best regards,

Krishna


[[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] EOF error reading csv file

2014-06-22 Thread S N V Krishna
Hi All,

Thanks for the suggestions. It is the problem with that particular name which 
has single ' in it. I renamed and able to load the file.

Best regards,

S.N.V. Krishna

-Original Message-
From: David L Carlson [mailto:dcarl...@tamu.edu] 
Sent: Monday, June 23, 2014 12:29 AM
To: Chitra Baniya; S N V Krishna; r-help@r-project.org
Subject: RE: [R] EOF error reading csv file

The error message "EOF within quoted string" is telling you have an unbalanced 
" or ' in the .csv file. 

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Chitra Baniya
Sent: Saturday, June 21, 2014 7:15 PM
To: kris...@primps.com.sg; r-help@r-project.org
Subject: [R] EOF error reading csv file

Can someone go through the same and suggest what I am missing out.

> cftc = read.table("cftcdata_ncn.csv", sep = ',', header = TRUE, fill =
TRUE)
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  EOF within quoted string
Hi, I guessed you have also tried with function read.csv instead of read.table.
Thanks








*Chitra Bahadur Baniya, PhDAssociate ProfessorCentral Department of 
BotanyTribhuvan UniversityKirtipurKathmandu, Nepal*

[[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-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 the result is coming as NULL?

2012-08-01 Thread Sri krishna Devarayalu Balanagu
Why the result is coming as NULL. Can anyone help. I want to find the outliers 
for a reference


setwd("D:/AZ")

library("RODBC")
cdb_cnct <- odbcConnectExcel("Book1.xls")
cdb_frame <- sqlFetch(cdb_cnct, "Sheet1")
odbcClose(cdb_cnct)
rm(cdb_cnct)

x<- cdb_frame$Publication >=1990 & cdb_frame$Publication <=2012
invalid <- cdb_frame[!x, c("Reference")]
invalid


Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).
__
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 the error is coming while extracting the data from sheet?

2012-08-01 Thread Sri krishna Devarayalu Balanagu
Even though the sheet name Publication exists. The error is coming.
Can anyone help?


library("RODBC")
cdb_cnct <- odbcConnectExcel("Copy of 
AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
cdb_frame <- sqlFetch(cdb_cnct, "Publication")
odbcClose(cdb_cnct)

Error in odbcTableExists(channel, sqtable) :
  'Publication': table not found on channel

rm(cdb_cnct)

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).
__
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 can we compare two vectors?

2012-08-08 Thread Sri krishna Devarayalu Balanagu
x=c(5, 8, 28, 29, 30)
y=c(5, 8, 28, 29, 31)
How can we compare these two vectors, whether each element is exactly matched 
with the elements in the other vector ?
How can we get the non matched elements from both the vectors?
Can anyone help?

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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 can I get the Ids with Duplicated key and corresponding Ids with original key?

2012-08-13 Thread Sri krishna Devarayalu Balanagu

In this following example Id 4 is duplicated with Id 1.
Like this I want both Ids (Duplicated and Duplicated with). Can anyone help?

df <- data.frame(
"Publication" = c(1, 2, 3, 1, 4, 5, 2, 3),
"Reference"   = c("a", "b", "c", "a", "d", "e", "b", "c"),
"Id"= c(1, 2, 3, 4, 5, 6, 7, 8)
 )

key <- paste(df$Publication, df$Reference, sep="_")
df.key <- cbind(key, df)
Duplicated.ids <- df.key[duplicated(df.key$key), c("Id")]



Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] How can I get the Ids with Duplicated key and corresponding Ids with original key?

2012-08-13 Thread Sri krishna Devarayalu Balanagu
Thank you for the quick response.
But I want those duplicated with Ids in a separate vector like Duplicated.ids 
in the below example?
Duplication should be checked for Publication and Reference combination, not on 
a single variable.


Regards
Rayalu
-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au]
Sent: Monday, August 13, 2012 3:37 PM
To: Sri krishna Devarayalu Balanagu
Cc: r-help@r-project.org
Subject: Re: [R] How can I get the Ids with Duplicated key and corresponding 
Ids with original key?

On 08/13/2012 07:17 PM, Sri krishna Devarayalu Balanagu wrote:
>
> In this following example Id 4 is duplicated with Id 1.
> Like this I want both Ids (Duplicated and Duplicated with). Can anyone help?
>
> df<- data.frame(
>  "Publication" = c(1, 2, 3, 1, 4, 5, 2, 3),
>  "Reference"   = c("a", "b", "c", "a", "d", "e", "b", "c"),
>  "Id"= c(1, 2, 3, 4, 5, 6, 7, 8)
>   )
>
> key<- paste(df$Publication, df$Reference, sep="_")
> df.key<- cbind(key, df)
> Duplicated.ids<- df.key[duplicated(df.key$key), c("Id")]
>
Hi Sri krishna Devarayalu Balanagu,
Does this do it?

cat("Id Publication(s)\n")
for(pub in unique(df$Publication))
  cat(pub,"-",df$Id[which(df$Publication==pub)],"\n")

Jim

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

__
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] Can we interlink these three if conditions?

2012-08-13 Thread Sri krishna Devarayalu Balanagu
key1.=c(1, 2, 3)
key2.=c(2)

if (identical(key1.,key2.) == "TRUE") {

cat("No Errors found")
}

if (length(setdiff(key1., key2.)) !=0){

cat("Reference.ID_Trial.ID_Arm.ID_SubArm.ID\n\n")

cat(paste(setdiff(key1., key2.)), sep="\n")

cat("Error Message: The above value is not found in key2.\n\n")
}
if (length(setdiff(key2., key1.)) !=0){

cat("Reference.ID_Trial.ID_Arm.ID_SubArm.ID\n\n")

cat(paste(setdiff(key2., key1.)), sep="\n")

cat("Error Message: The above value is not found in key1.\n\n")
}

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] Not able to filter factor, class

2012-08-14 Thread Sri krishna Devarayalu Balanagu
After importing data from Excel through ODBC.
In the inclusion dataset, class(inclusion$Value) is coming as factor. After 
filtering the data, length(inclusion$Value == 0),the answer is coming as 4879, 
but actually Value contains only 225 rows. So how can I get the length as 225.
Can anyone help?

setwd("D:/AZ")
library("RODBC")
cdb_cnct <- 
odbcConnectExcel("AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
arm <- sqlFetch(cdb_cnct, "Arm")
inclusion <- sqlFetch(cdb_cnct, "Inclusion")
odbcClose(cdb_cnct)
rm(cdb_cnct)
names(inclusion)
[1] "Trial_Design_ID""Reference_ID"   "Inclusion_Criteria"
[4] "Value"  "F5" "F6"
> class(inclusion$Value)
[1] "factor"

> nrow(inclusion)
[1] 4879
> length(inclusion$Value == 0)
[1] 4879
> length(inclusion$Value == "0")
[1] 4879

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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 can we compare corresponding values of x and y (first value of x exacly matches with the first value of y)?

2012-08-17 Thread Sri krishna Devarayalu Balanagu
df <- data.frame  (
"RowId" = 4:7,
"x"=c("1_1", "2_2", "3_3", "3_3"),
 "y"=c("1_1", "3_3", "2_2", "3_3")
 )

How can we compare corresponding values of x and y (first value of x exacly 
matches with the first value of y)?
If they were not matced exactly how can we get the row id?
In this case the row ids were 5 and 6.



Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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] Error: level sets of factors are different?

2012-08-17 Thread Sri krishna Devarayalu Balanagu
Why the error is coming? even though the length of outcome.new$compkey and 
outcome.new$armkey were exactly same.
Can anyone help?

setwd("D:/AZ")
library("RODBC")
cdb_cnct <- 
odbcConnectExcel("AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
outcomes <- sqlFetch(cdb_cnct, "Outcomes_info")
odbcClose(cdb_cnct)
rm(cdb_cnct)
sink("Dependency checks.log")
outcomes[(outcomes$Comparator != ), ] -> outcome
compkey <- paste(outcome$Comparator, outcome$Comparator_Subarm, sep='_')
armkey <- paste(outcome$Arm_ID, outcome$SubArm_ID, sep='_')
outcome.new <- cbind(outcome, compkey, armkey)
invalid.ids <- outcome.new[outcome.new$compkey == outcome.new$armkey, 
c("Assessment_record_ID")]

Error in Ops.factor(outcome.new$compkey, outcome.new$armkey) :
  level sets of factors are different



Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

[[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 the error is coming, can anyone help?

2012-09-06 Thread Sri krishna Devarayalu Balanagu
Hi everyone
Can anyone help?

x = c("Treatment", "Planned", "Actual", "Demographics", "Outcomes")
for (i in x) {
df <- paste(i)[, c("Reference_ID", "Arm_ID")]
unique(df) -> uniq
as.data.frame(table(uniq$Reference_ID)) -> y
i.Arms<- paste(y$Var1, y$Freq, sep="_")
Print_Message("Check for the Total No of Arms in Trial_level_info and print(i) 
sheet", Trial.Arms, print(i).Arms, "Trial level sheet", "print(i) sheet")
}

Error: unexpected symbol in:
"i.Arms<- paste(y$Var1, y$Freq, sep="_")
Print_Message("Check for the Total No of Arms in Trial_level_info and print(i) 
sheet", Trial.Arms, print(i).Arms"
Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, 
Ocean Place Resort - Long Branch, NJ, United States

Visit us at Booth No. 4 at World Conference on Pharmacometrics, 5-7 Sept 2012, 
Grand Hilton Hotel, Seoul, Korea

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).



[[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 find the non matching vectors among these five, if so how we can find the non matching element of that vectors?

2012-09-06 Thread Sri krishna Devarayalu Balanagu
Hello,

Say all the below five vectors should have same elements in any situation.
How to find the non matching vectors among these five, if so how we can find 
the non matching elements of those vectors?
Can anyone help?

a=c(1,2,3)
b=c(1,2,3,4)
c=c(1,2,3)
d=c(1,2,3)
e=c(1,4,5)
identical(a,b,c,d,e)
Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, 
Ocean Place Resort - Long Branch, NJ, United States

Visit us at Booth No. 4 at World Conference on Pharmacometrics, 5-7 Sept 2012, 
Grand Hilton Hotel, Seoul, Korea

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).



[[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] Why the error is coming, can anyone help?

2012-09-07 Thread Sri krishna Devarayalu Balanagu

Thank you for the answer. It's working.
But the error occurring here also

df <- paste(i)[, c("Reference_ID", "Arm_ID")]

How to get rid of that.

-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Thursday, September 06, 2012 10:15 PM
To: Sri krishna Devarayalu Balanagu; r-help@r-project.org
Subject: RE: Why the error is coming, can anyone help?

  print(i).Arms
is not valid R syntax.  Did you mean
  print(i.Arms)
?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Sri krishna Devarayalu Balanagu
> Sent: Wednesday, September 05, 2012 11:54 PM
> To: r-help@r-project.org
> Subject: [R] Why the error is coming, can anyone help?
>
> Hi everyone
> Can anyone help?
>
> x = c("Treatment", "Planned", "Actual", "Demographics", "Outcomes")
> for (i in x) {
> df <- paste(i)[, c("Reference_ID", "Arm_ID")]
> unique(df) -> uniq
> as.data.frame(table(uniq$Reference_ID)) -> y
> i.Arms<- paste(y$Var1, y$Freq, sep="_")
> Print_Message("Check for the Total No of Arms in Trial_level_info and 
> print(i) sheet",
> Trial.Arms, print(i).Arms, "Trial level sheet", "print(i) sheet")
> }
>
> Error: unexpected symbol in:
> "i.Arms<- paste(y$Var1, y$Freq, sep="_")
> Print_Message("Check for the Total No of Arms in Trial_level_info and 
> print(i) sheet",
> Trial.Arms, print(i).Arms"
> Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, 
> Ocean
> Place Resort - Long Branch, NJ, United States
>
> Visit us at Booth No. 4 at World Conference on Pharmacometrics, 5-7 Sept 
> 2012, Grand
> Hilton Hotel, Seoul, Korea
> 
> Notice: The information contained in this electronic mail message is intended 
> only for
> the use of the designated recipient. This message is privileged and 
> confidential. and the
> property of GVK BIO or its affiliates and subsidiaries. If the reader of this 
> message is not
> the intended recipient or an agent responsible for delivering it to the 
> intended recipient,
> you are hereby notified that you have received this message in error and that 
> any review,
> dissemination, distribution, or copying of this message is strictly 
> prohibited. If you have
> received this communication in error, please notify us immediately by 
> telephone +91-40-
> 6692 and destroy any and all copies of this 
> message in
> your possession (whether hard copies or electronically stored copies).
>
>
>
>   [[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.
Visit us at Booth No. 5 at 2012 ChemOutsourcing Conference, 10-13 Sept 2012, 
Ocean Place Resort - Long Branch, NJ, United States

Visit us at Booth No. 4 at World Conference on Pharmacometrics, 5-7 Sept 2012, 
Grand Hilton Hotel, Seoul, Korea

Notice: The information contained in this electronic mail message is intended 
only for the use of the designated recipient. This message is privileged and 
confidential. and the property of GVK BIO or its affiliates and subsidiaries. 
If the reader of this message is not the intended recipient or an agent 
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. 
If you have received this communication in error, please notify us immediately 
by telephone +91-40-6692 and destroy any and all 
copies of this message in your possession (whether hard copies or 
electronically stored copies).

__
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] Not getting correct graphs

2012-03-31 Thread Sri krishna Devarayalu Balanagu
Hi all,
Can anybody debug the following programme, as I am getting some Junk graphs in 
the pdf.
Please find the attached raw data file.
Thank you
Regards
Rayalu


library(ggplot2)
setwd("D:\\General Check list")
library(RODBC)
conn <- odbcConnectExcel ("Book1.xls")
Orange1 <- sqlFetch (conn, "Sheet3")
odbcClose(conn)
rm(conn)

#CDAI Change
unique(Orange1$BSCHSTAT) -> change
pdf("xxx.pdf")
for (j in 1:length(change)){
((Orange1$BASCHGAUT == "8-item scale")&(Orange1$BSCHSTAT == change[j])) -> b
FD <- Orange1[b, ]
unique(FD$REFID) -> refid
for (i in refid)
{
Orange2 <- FD[i == FD$REFID, ]
Orange2$ARM<- factor(Orange2$ARM)
unique(Orange2$BSCHSTAT) -> x
y <- paste("REFID=", i,"; ", "BSCHSTAT=", x, sep="")
print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line", "point"), colour=ARM, 
main=y))
}
}
dev.off()

__
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] Not generating line chart

2012-01-18 Thread Sri krishna Devarayalu Balanagu
Hi All,


Can you please help me, why this code in not generating line chart?



library(ggplot2)
par(mfrow=c(1,3))

#qplot(TIME1, BASCHGA, data=Orange1, geom= c("point", "line"), colour= ACTTRT)
unique(Orange1$REFID) -> refid
for (i in refid)
{
Orange2 <- Orange1[i == Orange1$REFID, ]
pdf('PGA.pdf')
qplot(TIME1, BASCHGA, data=Orange2, geom= c("line"), colour= ACTTRT)
dev.off()
}
Regards,
Devarayalu

[[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] Legend problem in line charts

2012-01-19 Thread Sri krishna Devarayalu Balanagu

Hi all,

Small problem in generating the line charts.

Question: Legend for the first graph is coming wrong.,  for second graph 
correctly.  Please fix the legend postion at the down of graph.
Plesae give me the solution.

Thank you
Devarayalu



Orange1 <- structure(list(REFID = c(7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9), ARM = c(1, 1, 1, 1, 2, 2, 2, 2, 1, 1,
1, 1, 2, 2, 2, 2, 1, 1, 2, 2), SUBARM = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ACTTRT = structure(c(3L,
3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L,
1L, 2L, 2L), .Label = c("ABC", "DEF", "LCD", "Vehicle"), class = "factor"),
TIME1 = c(0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6,
12, 0, 12, 0, 12), ENDPOINT = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), .Label = "PGA", class = "factor"), BASCHGA = c(0, -39,
-47, -31, 0, -34, -25, -12, 0, -45, -47, -20, 0, -25, -30,
-35, 0, -30, 0, -40), STATANAL = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = "UNK", class = "factor"), Art_Name = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), .Label = c("Bela_2010_206878", "Dansinger_2010_20687812"
), class = "factor")), .Names = c("REFID", "ARM", "SUBARM",
"ACTTRT", "TIME1", "ENDPOINT", "BASCHGA", "STATANAL", "Art_Name"
), row.names = c(NA, 20L), class = "data.frame")


unique(Orange1$REFID) -> refid
# Create Line Chart
for (i in 1:length(refid)) {
# convert factor to numeric for convenience
refid1 <- subset(Orange1, REFID == refid[i])
refid1$ACTTRTnum <- as.numeric(refid1$ACTTRT)
nACTTRTs <- max(refid1$ACTTRTnum)

# get the range for the x and y axis
xrange <- range(refid1$TIME1)
yrange <- range(refid1$BASCHGA)

# set up the plot
pdf (paste("pga", i, ".pdf", sep=''))
print(plot(xrange, yrange, type="n", xlab="TIME1 (WK)",
   ylab="BASCHGA (mm)" ))
colors <- rainbow(nACTTRTs)
linetype <- c(1:nACTTRTs)
plotchar <- seq(18,18+nACTTRTs,1)

# add lines

for (i in 1:nACTTRTs) {
  ACTTRT <- subset(refid1, ACTTRTnum==i)
  print(lines(ACTTRT$TIME1, ACTTRT$BASCHGA, type="b", lwd=1.5,
lty=linetype[i], col=colors[i], pch=plotchar[i]))
}

# add a title and subtitle
paste("REFID = ", unique(refid1$REFID), "; STATANAL = ", 
unique(refid1$STATANAL), sep="") -> x
title(x)


# add a legend
legend(xrange[1], yrange[2], unique(refid1$ACTTRT), cex=0.8, col=colors,
   pch=plotchar, lty=linetype)
#"bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", 
"right" and "center"
dev.off()
}


[[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] Legend appearance

2012-01-20 Thread Sri krishna Devarayalu Balanagu
Hi All,

I want small modification in apperance of legend. I want seperate legend for 
each graph representing the lines present in that graph only (not all the lines 
in all graphs) .
Can you please help?

Thank you
Regards
Devarayalu

Orange1 <- structure(list(REFID = c(7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9), ARM = c(1, 1, 1, 1, 2, 2, 2, 2, 1, 1,
1, 1, 2, 2, 2, 2, 1, 1, 2, 2), SUBARM = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ACTTRT = structure(c(3L,
3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L,
1L, 2L, 2L), .Label = c("ABC", "DEF", "LCD", "Vehicle"), class = "factor"),
TIME1 = c(0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6,
12, 0, 12, 0, 12), ENDPOINT = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), .Label = "PGA", class = "factor"), BASCHGA = c(0, -39,
-47, -31, 0, -34, -25, -12, 0, -45, -47, -20, 0, -25, -30,
-35, 0, -30, 0, -40), STATANAL = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = "UNK", class = "factor"), Art_Name = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), .Label = c("Bela_2010_206878", "Dansinger_2010_20687812"
), class = "factor")), .Names = c("REFID", "ARM", "SUBARM",
"ACTTRT", "TIME1", "ENDPOINT", "BASCHGA", "STATANAL", "Art_Name"
), row.names = c(NA, 20L), class = "data.frame")


unique(Orange1$REFID) -> refid
for (i in refid)
{
Orange2 <- Orange1[i == Orange1$REFID, ]
pdf(paste ("PGA", i, ".pdf", sep=''))
print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line"), colour= ACTTRT))
dev.off()
}


[[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] error in data.frame(...., check.names = FALSE)

2012-01-21 Thread Sri krishna Devarayalu Balanagu

Hi all,


Error is coming  as "error in data.frame(, check.names = FALSE): arguments 
has differents
counts of rows: 0, 18" for the following code.

Can you please help?
Thank you
Devarayalu

library(ggplot2)
setwd("D:\\General Check list")
library(RODBC)
conn <- odbcConnectExcel ("Book1.xls")
Orange1 <- sqlFetch (conn, "Sheet2")
odbcClose(conn)
rm(conn)

unique(Orange1$BSCHSTAT) -> change
pdf("xxx.pdf")
for (j in 1:length(change)){
((Orange1$BASCHGAUT == "8-item scale")&(Orange1$BSCHSTAT == change[j])) -> b
FD <- Orange1[b, ]
unique(FD$REFID) -> refid
for (i in refid)
{
Orange2 <- FD[i == Orange1$REFID, ]
Orange2$ACTTRT<- factor(Orange2$ACTTRT)
unique(Orange2$BSCHSTAT) -> x
y <- paste("REFID=", i,"; ", "BSCHSTAT=", x, sep="")
print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line", "point"), colour= 
factor(ACTTRT), main=y))
}
}
dev.off()


[[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] Error is coming as NULL

2012-01-23 Thread Sri krishna Devarayalu Balanagu
Hi all,

A small problem raising.
Suppose the follow raw data is stored in a csv file.  And the error is coming 
as NULL with the following code.
Can you please help?
Thank you in advance.

SUBJCET











1Ito

1Ito

1Ito

1Ito

1Ito

1Ito










read.csv("Noname3.csv") -> FD
FD$SUBJECT
NULL

Regards
Devarayalu


[[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] Error is coming as NULL

2012-01-24 Thread Sri krishna Devarayalu Balanagu

Hi All,

This is the file which I want to import into R After importing and querying the 
data, error is coming as null.

read.csv("Noname3.csv", header=T) -> FD
 FD$SUBJECT
 NULL

Can please help?
Regards
Devarayalu

__
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] R newbie: how to replace string/regular expression

2008-11-02 Thread Krishna Dagli/Krushna Dagli
Hello;

I am a R newbie and would like to know correct and efficient method for
doing string replacement.

I have a large data set, where I want to replace character "M", "b",
and "K" (currency in Million, Billion and K) to  millions.  That is
209.7B with (209.7 * 10e6) and 100.00K with (100.00 *1/100)
and etc..

d <- c("120.0M", "11.01m", "209.7B", "100.00k", "50")

This works that is it removes "b/B",

gsub ("(.*)(B$)", "\\1", d, ignore.case=T, perl=T)

but

gsub ("(.*)(B$)", as.numeric("\\1") * 10e6, d, ignore.case=T, perl=T)

does not work. I tried with sprintf and other combination of as.numeric but
that fails, how to use \\1 and multiply with 10e6??

The other solution is :

location <- grep ("M", d, ignore.case=T)
y <- sub("M", "", d, ignore.case=T)
y[location]<-y[location] * 10e6

Is the second solution faster or (if) combination of grep along with
multiply (if it works) is faster? Or what is the most efficient method
to do something like this in R?

Thanks and Regards
Krishna

__
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.