Re: [R] An error in the Package JGL

2013-07-16 Thread Prof Brian Ripley

Please do not multiple-post.

What did the maintainer say when you asked him (see the posting guide)?

On 16/07/2013 05:36, Azam Peyvand wrote:

I am currently working with the package JGL.
I tried to run JGL function JGL(Y,penalty=fused,...) over my data, but
there is the following error which makes it stop:

Error in while ((iter==0)|| (iter  maxiter  diff_valuetol))
missing value where TRUE/FALSE needed. 

Any special idea for fixing such error?

[[alternative HTML version deleted]]


The posting guide asked you not to send HTML.


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


We don't have anything reproducible here.

--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] Serialize data.frame to database

2013-07-16 Thread Simon Zehnder
Hi Jeff,

I think you are more right than me. I have not much experience with R-specific 
objects and Databases. I just know, that for languages like Java, C, etc. this 
process is a usual one for storing for example matrices (in case of course that 
I do not have to access specific elements inside of the matrix but only the 
matrix as a whole).

Thank you for the tip with the R-sig-DB list. I switch over to this list.

Best

Simon

On Jul 16, 2013, at 2:34 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:

 I could be wrong, but I would guess that doing what you are describing is 
 very unusual. Most of the time the data frame is mapped to a table in the 
 database so the rows can be searched. Storing data frames as BLOBs really 
 seems odd.
 
 Note that there is an R-sig-db mailing list for questions of this type.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 --- 
 Sent from my phone. Please excuse my brevity.
 
 Simon Zehnder szehn...@uni-bonn.de wrote:
 
 Dear R-Users,
 
 I need a very fast and reliable database solution so I try to serialize
 a data.frame (to binary data) and to store this data to an SQLite
 database. 
 
 This is what I tried to do:
 
 library(RSQLite)
 con - dbDriver(SQLite)
 db - dbConnect(con, test)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data BLOB)')
 data.bin - serialize(iris, NULL, ascii = FALSE)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.bin,
 '), sep = ))
 data.bin2 - dbGetQuery(db, SELECT DATA FROM frames WHERE simID = 1)
 data.bin2
 data
 1   58
 
 So, only the first entry of data.bin is saved to the database. I tried
 to first convert the binary data to raw data:
 data.raw - rawToChar(data.bin)
 Error in rawToChar(data.bin) :
 embedded nul in string:
 'X\n\0\0\0\002\0\003\0\001\0\002\003\0\0\0\003\023\0\0\0\005\0\0\0\016\0\0\0\x96@\024ff@\023\x99\x99\x99\x99\x99\x9a@\022\xcc\xcc\xcc\xcc\xcc\xcd@\022ff@\024\0\0\0\0\0\0@\025\x99\x99\x99\x99\x99\x9a@\022ff@\024\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\023\x99\x99\x99\x99\x99\x9a@\025\x99\x99\x99\x99\x99\x9a@\02333@\02333@\02133@\02733@\026\xcc\xcc\xcc\xcc\xcc\xcd@\025\x99\x99\x99\x99\x99\x9a@\024ff@\026\xcc\xcc\xcc\xcc\xcc\xcd@\024ff@\025\x99\x99\x99\x99\x99\x9a@\024ff@\022ff@\024ff@\02333@\024\0\0\0\0\0\0@\024\0\0\0\0\0\0@\024\xcc\xcc\xcc\xcc\xcc\xcd@\024\xcc\xcc\xcc\xcc\xcc\xcd@\022\xcc\xcc\xcc\xcc\xcc\xcd@\02333@\025\x99\x99\x99\x99\x99\x9a@\024\xcc\xcc\xcc\xcc\xcc\xcd@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\024\0\0\0\0\0\0@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\021\x99\x99\x99\x99\x99\x9a@\024ff@\024\0\0\0\0\0\0@\022\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\024\0\0\0\0\!
 
 
 0\0
 
 I don't know what this error should tell me. Then I tried to use the
 ASCII format
 
 data.ascii - serialize(iris, NULL, ascii = TRUE)
 data.raw - rawToChar(data.ascii)
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.raw,
 '), sep = ))
 Error in sqliteExecStatement(conn, statement, ...) :
 RS-DBI driver: (error in statement: unrecognized token: X'A
 
 This also does not work. It seems the driver does not deal that nicely
 with the regular INSERT query for BLOB objects in SQLite. Then I used a
 simpler way:
 
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, DROP TABLE frames)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data TEXT DEFAULT
 NULL)')
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, ', data.raw, '),
 sep = ))
 data.bin2 - dbGetQuery(db, SELECT data FROM frames WHERE simID = 1)
 
 Nice, that worked. Now I want to unserialize the data:
 
 unserialize(data.bin2)
 Error in unserialize(data.bin2) : 'connection' must be a connection
 
 unserialize(data.bin2[1, 'data'])
 Error in unserialize(data.bin2[1, data]) :
 character vectors are no longer accepted by unserialize()
 
 I feel a little stuck here, but I am very sure, that converting
 data.frames to binary data and storing them to a database is not that
 unusual. So I hope somebody has already done this and could give me the
 missing piece.
 
 
 Best
 
 Simon
 
 __
 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

Re: [R] Problem with plot in several cases, font issue?

2013-07-16 Thread Alice Julien-Laferrière

Thanks for the help.

As  indicated into the R-admin manual, it was an ubuntu install problem.
But it only shows in R, as I do not use special fonts usually.





Le 15/07/2013 18:17, Prof Brian Ripley a écrit :

On 15/07/2013 15:59, Alice Julien-Laferrière wrote:

Dear all,

I am having problem on plots in R for some cases.


Your machine has Cairo: Cairo-based X11 devices do not use those 
fonts.  So it seems you have done something you have not shown us.


The fix is to use the Cairo-based X11 devices.  See the R-admin manual 
for more details.




For example:


plot( 1:10 )
text( 1:10, letters[1:10], cex = 1)


works well but :


plot(1:10)
text(1:10, letters[1:10], cex = 0.9)


returns :
Erreur dans text.default(1:10, letters[1:10], cex = 0.9) :
   impossible de charger la police X11
-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, de face 1 et de taille 11

(sorry for the french).


But it is very easy to set LANGUAGE=en to get American English 
messages 



In this message, for other cases the function may changed (it can be
axis( ) for example) but it always a font problem.

I encountered this issue various times (with more complicated graphics).

I'm working on ubuntu 12.04 with R 3.0.1 (2013-05-16).


The capabilities function returns me:
   jpeg  png tifftcltk  X11 aqua http/ftp sockets
TRUE TRUE TRUE TRUE TRUEFALSE TRUE TRUE
  libxml fifo   clediticonv  NLS  profmemcairo
  TRUE TRUE TRUE TRUE TRUEFALSE TRUE


I think this may be an issue with my installation, but I could not
figured out what was the missing package.
I tried this on other computers. I did not see the same bug.


Thanks in advance for the help,

Alice

__
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] Program SPACECAP help

2013-07-16 Thread Jose Jimenez
Please, could you post the the R code and the head of your data? Are you
usuing the csv template?

Jose



--
View this message in context: 
http://r.789695.n4.nabble.com/Program-SPACECAP-help-tp4670514p4671667.html
Sent from the R help mailing list archive at Nabble.com.

__
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] About Detrended Fluctuation Analysis

2013-07-16 Thread whialy
Hello~

I am just beginner in R program
During my research, I should analyze my data using detrended fluctuation
analysis
But it is difficult to find package in R
I found the package named fractal to calcuate DFA but in new version in
R, that package does not work any more
So...would you tell my some tools or packages to calcuated DFA?

Thank you for reading this post~





--
View this message in context: 
http://r.789695.n4.nabble.com/About-Detrended-Fluctuation-Analysis-tp4671666.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Ode error message

2013-07-16 Thread Raphaëlle Carraud
Hello,

I am creating a program with R to solve a differential equation system. 
However, I get the following message I do not understand :

 out - ode(y = state, times = z, func = liquide, parms = 0, atol = 0)
DLSODA-  EWT(I1) is R1 .le. 0.0
In above message, I1 = 1
 
In above message, R1 = 0
 
Error in lsoda(y, times, func, parms, ...) : 
  illegal input detected before taking any integration steps - see written 
message

or this one when I tried modifying the atoll value :

 out - ode(y = state, times = z, func = liquide, parms = 0, atol = 10^-14)
DLSODA-  Warning..Internal T (=R1) and H (=R2) are
  such that in the machine, T + H = T on the next step
 (H = step size). Solver will continue anyway.
In above message, R1 = 0, R2 = 0
 
DINTDY-  T (=R1) illegal
In above message, R1 = 1
 
  T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 0, R2 = 0
 
DINTDY-  T (=R1) illegal
In above message, R1 = 2
 
  T not in interval TCUR - HU (= R1) to TCUR (=R2)
In above message, R1 = 0, R2 = 0
 
DLSODA-  Trouble in DINTDY.  ITASK = I1, TOUT = R1
In above message, I1 = 1
 
In above message, R1 = 2

Here is my program. I also tried changing the initial values but it does not 
work well.

liquide - function(z, state, parameters) {
  with(as.list(c(state,parameters)),{
# rate of change
  
Tr - 273+90
C - CA + CB + CC + CD + CE + CI + CG + CJ + CK + CH

K32 - 6.54*10^4  
K33 - 1.37*10^4  
K34 - 330 
K35 - 5.81*10^4  
kf2 - 1.37*10^3  
kf3 - 1.37*10^3 
kf4 - 8.68*10^5  
kf5 - 157.2

K2 - 10^1.37
K3 - 10^(-3.35) 

r1 - kf4*CD - kf4/K34*CE^2
r2 - kf3*CA*CB - kf3/K33*CD
r3 - kf2*CA^2 - kf2/K32*CC
r4 - kf5*CC - kf5/K35*CE*CI^2 


dCA - -r2  # dNO/dt
dCB - -r3 - r2   # dNO2/dt
dCC - r3/2 - r4 # dN2O4/dt
dCD - r2 - r1# dN2O3/dt
dCE - 2*r1 + r4# dHNO2/dt
dCI - r4 # dHNO3/dt
dCG - -r4 - r1   # dH2O/dz
dCH - (dCE + dCI)/((K2 + K3)*(CE + CI))  # dH/dz
dCJ -  (CH*dCI - CI*dCH)/(K3*CH^2)  # dNO3-/dz
dCK -  (CH*dCE - CE*dCH)/(K2*CH^2)# dNO2-/dz

   

list(c(dCA, dCB, dCC, dCD, dCE, dCI, dCG, dCH, dCJ, dCK))
  })   # end with(as.list ...
}


Ti - 273+90   # K
Ct - 5100   # mol/m^3

state -c(CA = 0,   # mol/m^3 NO2
  CB = 0,   # mol/m^3 NO
  CC = 0,# mol/m^3 N2O4
  CD = 0,  # mol/m^3 N2O3
  CE = 50,  # mol/m^3 HNO2
  CI = 50, # mol/m^3 HNO3
  CG = 5000, # mol/m^3 H2O
  CH = 0, # mol/m^3 H+
  CJ = 0,# mol/m^3 NO3-
  CK = 0) # mol/m^3 NO2-
  
parameters - c(Ct = 5100)

z - seq(0, 15, by = 1)  # en seconde

library(deSolve)
out - ode(y = state, times = z, func = liquide, parms = 0, atol = 10^-14)
head(out)
plot(out)

Thank you

__
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] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
Dear R users,

I´ve stumbled over a problem that can be easily seen from the R code below:

- When I use plot.gam() on a fitted model object, I get a nice and well-looking 
smooth curve for all
terms in the model.

- However, when I use predict(model) for a given predictor, with values of all 
other predictors set
to their means, the resulting curve doesn´t fit well at all.

Is there a way to overlay the curve produced by plot.gam() over a plot of the 
original data?

Here´s some reproducible code with mgcv version 1.7-22 on R3.0.1 (Windows 7):

##

library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,scale=2)
b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
plot(b,select=1)

plot(y~x0,dat)
mydata=data.frame(x0=0:1,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
lines(0:1,predict(b,mydata,type=response))

##

Best wishes,
Christoph


-- 
PD Dr Christoph Scherber
Georg-August University Goettingen
Department of Crop Science
Agroecology
Grisebachstrasse 6
D-37077 Goettingen
Germany
phone 0049 (0)551 39 8807
fax 0049 (0)551 39 8806
http://www.gwdg.de/~cscherb1

__
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] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Simon Wood

Probably you didn't want to set x0=0:1? Here is some code, to do what you want.
(The CI shape is not identical to the plot(b) version as the uncertainty 
includes
the uncertainty in the other smooths and the intercept now.)

library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,scale=2)
b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
plot(b,select=1)

plot(y~x0,dat)
mydata=data.frame(x0=0:200/200,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
pv - predict(b,mydata,type=response,se=TRUE)
lines(mydata$x0,pv$fit)
lines(mydata$x0,pv$fit+2*pv$se.fit,lty=2)
lines(mydata$x0,pv$fit-2*pv$se.fit,lty=2)


 


On 16/07/13 09:52, Christoph Scherber wrote:

Dear R users,

I´ve stumbled over a problem that can be easily seen from the R code below:

- When I use plot.gam() on a fitted model object, I get a nice and well-looking 
smooth curve for all
terms in the model.

- However, when I use predict(model) for a given predictor, with values of all 
other predictors set
to their means, the resulting curve doesn´t fit well at all.

Is there a way to overlay the curve produced by plot.gam() over a plot of the 
original data?

Here´s some reproducible code with mgcv version 1.7-22 on R3.0.1 (Windows 7):

##

library(mgcv)
set.seed(2)
dat - gamSim(1,n=400,dist=normal,scale=2)
b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
plot(b,select=1)

plot(y~x0,dat)
mydata=data.frame(x0=0:1,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
lines(0:1,predict(b,mydata,type=response))

##

Best wishes,
Christoph




__
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] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
Thanks, the sequence of x0 values was clearly too short.

However, is there a way to overlay the (marginal) curve from plot.gam() over a 
plot of (x,y) values?

Best wishes
Christoph



Am 16/07/2013 11:04, schrieb Simon Wood:
 Probably you didn't want to set x0=0:1? Here is some code, to do what you 
 want.
 (The CI shape is not identical to the plot(b) version as the uncertainty 
 includes
 the uncertainty in the other smooths and the intercept now.)
 
 library(mgcv)
 set.seed(2)
 dat - gamSim(1,n=400,dist=normal,scale=2)
 b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
 plot(b,select=1)
 
 plot(y~x0,dat)
 mydata=data.frame(x0=0:200/200,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
 pv - predict(b,mydata,type=response,se=TRUE)
 lines(mydata$x0,pv$fit)
 lines(mydata$x0,pv$fit+2*pv$se.fit,lty=2)
 lines(mydata$x0,pv$fit-2*pv$se.fit,lty=2)
 
 
   
 
 On 16/07/13 09:52, Christoph Scherber wrote:
 Dear R users,

 I´ve stumbled over a problem that can be easily seen from the R code below:

 - When I use plot.gam() on a fitted model object, I get a nice and 
 well-looking smooth curve for all
 terms in the model.

 - However, when I use predict(model) for a given predictor, with values of 
 all other predictors set
 to their means, the resulting curve doesn´t fit well at all.

 Is there a way to overlay the curve produced by plot.gam() over a plot of 
 the original data?

 Here´s some reproducible code with mgcv version 1.7-22 on R3.0.1 (Windows 7):

 ##

 library(mgcv)
 set.seed(2)
 dat - gamSim(1,n=400,dist=normal,scale=2)
 b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
 plot(b,select=1)

 plot(y~x0,dat)
 mydata=data.frame(x0=0:1,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
 lines(0:1,predict(b,mydata,type=response))

 ##

 Best wishes,
 Christoph


 
 
 

__
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] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
Meanwhile, I found the solution myself:

using plot.gam() with shift=intercept and trans=exp (for a poisson model) does 
the job. I can then
add the original data using points()

Thanks again for your help, which is greatly appreciated!

Best wishes
Christoph

Am 16/07/2013 11:04, schrieb Simon Wood:
 Probably you didn't want to set x0=0:1? Here is some code, to do what you 
 want.
 (The CI shape is not identical to the plot(b) version as the uncertainty 
 includes
 the uncertainty in the other smooths and the intercept now.)
 
 library(mgcv)
 set.seed(2)
 dat - gamSim(1,n=400,dist=normal,scale=2)
 b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
 plot(b,select=1)
 
 plot(y~x0,dat)
 mydata=data.frame(x0=0:200/200,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
 pv - predict(b,mydata,type=response,se=TRUE)
 lines(mydata$x0,pv$fit)
 lines(mydata$x0,pv$fit+2*pv$se.fit,lty=2)
 lines(mydata$x0,pv$fit-2*pv$se.fit,lty=2)
 
 
   
 
 On 16/07/13 09:52, Christoph Scherber wrote:
 Dear R users,

 I´ve stumbled over a problem that can be easily seen from the R code below:

 - When I use plot.gam() on a fitted model object, I get a nice and 
 well-looking smooth curve for all
 terms in the model.

 - However, when I use predict(model) for a given predictor, with values of 
 all other predictors set
 to their means, the resulting curve doesn´t fit well at all.

 Is there a way to overlay the curve produced by plot.gam() over a plot of 
 the original data?

 Here´s some reproducible code with mgcv version 1.7-22 on R3.0.1 (Windows 7):

 ##

 library(mgcv)
 set.seed(2)
 dat - gamSim(1,n=400,dist=normal,scale=2)
 b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
 plot(b,select=1)

 plot(y~x0,dat)
 mydata=data.frame(x0=0:1,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3))
 lines(0:1,predict(b,mydata,type=response))

 ##

 Best wishes,
 Christoph


 
 
 

__
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] Question on plotting with googleVis

2013-07-16 Thread Arnaud Michel

You can try with list options :

plot(gvisBarChart(MyData, xvar=Names1, yvar=c(Values1, Values2),
options=list(width=1200,height=1500)))



Le 15/07/2013 20:00, Christofer Bogaso a écrit :

Hello again,

Let say I have following data-frame:

MyData - data.frame(Names1 = paste(XXX, 1:150), Values1 = 1:150 + 10,
Values2 = 1:150)

Now I want to plot this data-frame with googleVis. Therefore I run
following codes:

library(googleVis)
plot(gvisBarChart(MyData, xvar=Names1, yvar=c(Values1, Values2)))

However the problem is that, hardly this plot can be read. However if I
plot a fraction of my data-frame then the underlying plot is clearly
visible:

plot(gvisBarChart(MyData[1:15,], xvar=Names1, yvar=c(Values1,
Values2)))  ## This is clearly visible.


I would really appreciate if someone gives me some pointer how I can
clearly plot my data-frame with googleVis. I understand that there are many
other plotting methods available with R like ggplot, however here I want to
use googleVis because of its strength in showing the values within the plot
area itself if you hover your mouse.

Thanks and regards,

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



--
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31

__
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] Finding parameters for residuals using GAMLSS and a lognormal dist.

2013-07-16 Thread Chris89
Hi everyone!

First of all: I am new to the forum, so please excuse my lack of knowledge
on how to post a question...

I am working on a project where I need to use the GAMLSS package, and the
boss have asked me to try using the lognormal distribution. 
The regression goes as planned, but when evaluating the residuals and using
the coef() function, I get multiple coefficients as theory says, but I´m not
sure if they can be used as parameters.

My question is: How can I model the residuals? Do I have to assume a
lognormal distribution of these, or can I assume a distribution of choice? 
I have plotted the kernel density of the residuals and they do seem to fit a
lognormal distribution, but as I am not entirely sure how to find
parameters, I do not know how... I guess this is an easy question, but I
just cant seem to find a solution to this.

A section of the code:
tmpformula = as.formula(paste(logvarnames[i], ~ ,
paste(logvarnames[1:i-1], collapse= +)))
res = gamlss(tmpformula, family = LOGNO(), data = myall )

where logvarnames[] is a vector containing the names of columns  from the
dataset I use called myall. 





--
View this message in context: 
http://r.789695.n4.nabble.com/Finding-parameters-for-residuals-using-GAMLSS-and-a-lognormal-dist-tp4671674.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Masking oceans using polypath

2013-07-16 Thread Louise Wilson
Hi R-help

I am trying to mask the ocean from an image plot I have made.


Here is some example code:

library(mapdata)

image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, +),

  xlab = lon, ylab = lat)

outline - map(worldHires, plot=FALSE) # returns a list of x/y coords

xrange - range(outline$x, na.rm=TRUE) # get bounding box

yrange - range(outline$y, na.rm=TRUE)

xbox - xrange + c(-2, 2)

ybox - yrange + c(-2, 2)

# create the grid path in the current device

polypath(c(outline$x, NA, c(xbox, rev(xbox))),

 c(outline$y, NA, rep(ybox, each=2)),

 col=light blue, rule=evenodd)


As you can see, the polypath is on both sides of the country outline. Any
help is much appreciated.


Louise

[[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] Serialize data.frame to database

2013-07-16 Thread Rainer Schuermann
Maybe a simple

dbWriteTable( db, frames, iris )

does what you want?



On Monday 15 July 2013 23:43:18 Simon Zehnder wrote:
 Dear R-Users,
 
 I need a very fast and reliable database solution so I try to serialize a 
 data.frame (to binary data) and to store this data to an SQLite database. 
 
 This is what I tried to do:
 
 library(RSQLite)
 con - dbDriver(SQLite)
 db - dbConnect(con, test)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data BLOB)')
 data.bin - serialize(iris, NULL, ascii = FALSE)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.bin, '), sep 
 = ))
 data.bin2 - dbGetQuery(db, SELECT DATA FROM frames WHERE simID = 1)
 data.bin2
   data
 1   58
 
 So, only the first entry of data.bin is saved to the database. I tried to 
 first convert the binary data to raw data:
 data.raw - rawToChar(data.bin)
 Error in rawToChar(data.bin) :
   embedded nul in string: 
 'X\n\0\0\0\002\0\003\0\001\0\002\003\0\0\0\003\023\0\0\0\005\0\0\0\016\0\0\0\x96@\024ff@\023\x99\x99\x99\x99\x99\x9a@\022\xcc\xcc\xcc\xcc\xcc\xcd@\022ff@\024\0\0\0\0\0\0@\025\x99\x99\x99\x99\x99\x9a@\022ff@\024\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\023\x99\x99\x99\x99\x99\x9a@\025\x99\x99\x99\x99\x99\x9a@\02333@\02333@\02133@\02733@\026\xcc\xcc\xcc\xcc\xcc\xcd@\025\x99\x99\x99\x99\x99\x9a@\024ff@\026\xcc\xcc\xcc\xcc\xcc\xcd@\024ff@\025\x99\x99\x99\x99\x99\x9a@\024ff@\022ff@\024ff@\02333@\024\0\0\0\0\0\0@\024\0\0\0\0\0\0@\024\xcc\xcc\xcc\xcc\xcc\xcd@\024\xcc\xcc\xcc\xcc\xcc\xcd@\022\xcc\xcc\xcc\xcc\xcc\xcd@\02333@\025\x99\x99\x99\x99\x99\x9a@\024\xcc\xcc\xcc\xcc\xcc\xcd@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\024\0\0\0\0\0\0@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\021\x99\x99\x99\x99\x99\x9a@\024ff@\024\0\0\0\0\0\0@\022\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\024\0\0\0\!
 0\!
  0\0
 
 I don't know what this error should tell me. Then I tried to use the ASCII 
 format
 
 data.ascii - serialize(iris, NULL, ascii = TRUE)
 data.raw - rawToChar(data.ascii)
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.raw, '), sep 
 = ))
 Error in sqliteExecStatement(conn, statement, ...) :
   RS-DBI driver: (error in statement: unrecognized token: X'A
 
 This also does not work. It seems the driver does not deal that nicely with 
 the regular INSERT query for BLOB objects in SQLite. Then I used a simpler 
 way:
 
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, DROP TABLE frames)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data TEXT DEFAULT NULL)')
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, ', data.raw, '), sep = 
 ))
 data.bin2 - dbGetQuery(db, SELECT data FROM frames WHERE simID = 1)
 
 Nice, that worked. Now I want to unserialize the data:
 
 unserialize(data.bin2)
 Error in unserialize(data.bin2) : 'connection' must be a connection
 
 unserialize(data.bin2[1, 'data'])
 Error in unserialize(data.bin2[1, data]) :
   character vectors are no longer accepted by unserialize()
 
 I feel a little stuck here, but I am very sure, that converting data.frames 
 to binary data and storing them to a database is not that unusual. So I hope 
 somebody has already done this and could give me the missing piece.
 
 
 Best
 
 Simon
 
 __
 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.
- - - - -

Der NSA keine Chance: e-mail verschluesseln!
http://www.gpg4win.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.


Re: [R] Weird 'xmlEventParse' encoding issue

2013-07-16 Thread Duncan Temple Lang
Hi Sascha

 Your code gives the correct results on my machine (OS X),
either reading from the file directly or via readLines() and passing
the text to xmlEventParse().

 The problem might be the version of the XML package or your environment
settings.  And it is important to report the session information.
So you should provide the output from

   sessionInfo()
   Sys.getenv()
   libxmlVersion()


 D

On 7/15/13 4:41 AM, Sascha Wolfer wrote:
 Dear list,
 
 I have got a weird encoding problem with the xmlEventParse() function from 
 the 'XML' package.
 
 I tried finding an answer on the web for several hours and a Stack Exchange 
 question came back without success :(
 
 So here's the problem. I created a small XML test file, which looks like this:
 
 ?xml version=1.0 encoding=iso-8859-1?
 !DOCTYPE testFile
 s type=manualauch der Schulleiter steht dafür zur Verfügung. Das ist 
 seßhaft mit ä und ö.../s
 
 This file is encoded with the iso-8859-1 encoding which is also defined in 
 its header.
 
 I have 3 handler functions, definitions as follows:
 
 sE2 - function (name, attrs) {
   if (name == s) {
 get.text - T }
 }
 
 eE2 - function (name, attrs) {
   if (name == s) {
 get.text - F
   }
 }
 
 tS2 - function (content, ...) {
   if (get.text  nchar(content)  0) {
 collected.text - c(collected.text, content)
   }
 }
 
 I have one wrapper function around xmlEventParse(), definition as follows:
 
 get.all.text - function (file) {
   t1 - Sys.time()
   read.file - paste(readLines(file, encoding = ), collapse =  )
   print(read.file)
   assign(collected.text, c(), env = .GlobalEnv)
   assign(get.text, F, env = .GlobalEnv)
   xmlEventParse(read.file, asText = T, list(startElement = sE2,
endElement = eE2,
text = tS2),
error = function (...) { },
saxVersion = 1)
   t2 - Sys.time()
   cat(That took, round(difftime(t2,t1, units=secs), 1), seconds.\n)
   cat(Result of reading is in variable 'collected.text'.\n)
   collected.text
 }
 
 The output of calling get.all.text(test file) is as follows:
 [1] ?xml version=\1.0\ encoding=\iso-8859-1\? !DOCTYPE testFile s 
 type=\manual\auch der Schulleiter steht
 dafür zur Verfügung. Das ist seßhaft mit ä und ö.../s 
 That took 0 seconds.
 Result of reading is in variable 'collected.text'.
 [1] auch der Schulleiter steht dafür zur 
 Verfügung. Das ist seßhaft mit ä und ö...
 
 Now the REALLY weird thing (for me) is that R obviously reads in the file 
 correctly (first output) with 'readLines()'.
 Then this output is passed to xmlEventParse. Afterwards the output is broken 
 and it sometimes also inserts weird breaks
 were special characters occur.
 
 Do you have any ideas how to solve this problem?
 
 I cannot use the xmlParse() function because I need the SAX functionality of 
 xmlEventParse(). I also tried reading the
 file with xmlEventParse() directly (with asText = F). No changes...
 
 Thanks a lot,
 Sascha W.
 
 __
 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] Serialize data.frame to database

2013-07-16 Thread Simon Zehnder
Hi Rainer,

dbWriteTable is a nice function but in my case I need something that can 
actually save a dataframe in one row of a table. That is why I want to 
serialize my data.frame. 


Best

Simon


On Jul 16, 2013, at 3:05 PM, Rainer Schuermann rainer.schuerm...@gmx.net 
wrote:

 Maybe a simple
 
 dbWriteTable( db, frames, iris )
 
 does what you want?
 
 
 
 On Monday 15 July 2013 23:43:18 Simon Zehnder wrote:
 Dear R-Users,
 
 I need a very fast and reliable database solution so I try to serialize a 
 data.frame (to binary data) and to store this data to an SQLite database. 
 
 This is what I tried to do:
 
 library(RSQLite)
 con - dbDriver(SQLite)
 db - dbConnect(con, test)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data BLOB)')
 data.bin - serialize(iris, NULL, ascii = FALSE)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.bin, '), sep 
 = ))
 data.bin2 - dbGetQuery(db, SELECT DATA FROM frames WHERE simID = 1)
 data.bin2
  data
 1   58
 
 So, only the first entry of data.bin is saved to the database. I tried to 
 first convert the binary data to raw data:
 data.raw - rawToChar(data.bin)
 Error in rawToChar(data.bin) :
  embedded nul in string: 
 'X\n\0\0\0\002\0\003\0\001\0\002\003\0\0\0\003\023\0\0\0\005\0\0\0\016\0\0\0\x96@\024ff@\023\x99\x99\x99\x99\x99\x9a@\022\xcc\xcc\xcc\xcc\xcc\xcd@\022ff@\024\0\0\0\0\0\0@\025\x99\x99\x99\x99\x99\x9a@\022ff@\024\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\023\x99\x99\x99\x99\x99\x9a@\025\x99\x99\x99\x99\x99\x9a@\02333@\02333@\02133@\02733@\026\xcc\xcc\xcc\xcc\xcc\xcd@\025\x99\x99\x99\x99\x99\x9a@\024ff@\026\xcc\xcc\xcc\xcc\xcc\xcd@\024ff@\025\x99\x99\x99\x99\x99\x9a@\024ff@\022ff@\024ff@\02333@\024\0\0\0\0\0\0@\024\0\0\0\0\0\0@\024\xcc\xcc\xcc\xcc\xcc\xcd@\024\xcc\xcc\xcc\xcc\xcc\xcd@\022\xcc\xcc\xcc\xcc\xcc\xcd@\02333@\025\x99\x99\x99\x99\x99\x9a@\024\xcc\xcc\xcc\xcc\xcc\xcd@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\024\0\0\0\0\0\0@\026\0\0\0\0\0\0@\023\x99\x99\x99\x99\x99\x9a@\021\x99\x99\x99\x99\x99\x9a@\024ff@\024\0\0\0\0\0\0@\022\0\0\0\0\0\0@\021\x99\x99\x99\x99\x99\x9a@\024\0\0\0\!
 0\!
 0\0
 
 I don't know what this error should tell me. Then I tried to use the ASCII 
 format
 
 data.ascii - serialize(iris, NULL, ascii = TRUE)
 data.raw - rawToChar(data.ascii)
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, X', data.raw, '), sep 
 = ))
 Error in sqliteExecStatement(conn, statement, ...) :
  RS-DBI driver: (error in statement: unrecognized token: X'A
 
 This also does not work. It seems the driver does not deal that nicely with 
 the regular INSERT query for BLOB objects in SQLite. Then I used a simpler 
 way:
 
 dbSendQuery(db, DELETE FROM frames)
 dbSendQuery(db, DROP TABLE frames)
 dbSendQuery(db, 'CREATE TABLE frames(simID INT, data TEXT DEFAULT NULL)')
 dbSendQuery(db, paste(INSERT INTO frames VALUES(1, ', data.raw, '), sep 
 = ))
 data.bin2 - dbGetQuery(db, SELECT data FROM frames WHERE simID = 1)
 
 Nice, that worked. Now I want to unserialize the data:
 
 unserialize(data.bin2)
 Error in unserialize(data.bin2) : 'connection' must be a connection
 
 unserialize(data.bin2[1, 'data'])
 Error in unserialize(data.bin2[1, data]) :
  character vectors are no longer accepted by unserialize()
 
 I feel a little stuck here, but I am very sure, that converting data.frames 
 to binary data and storing them to a database is not that unusual. So I hope 
 somebody has already done this and could give me the missing piece.
 
 
 Best
 
 Simon
 
 __
 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.
 - - - - -
 
 Der NSA keine Chance: e-mail verschluesseln!
 http://www.gpg4win.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.

__
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 from running R2WinBUGS in R

2013-07-16 Thread Anamika Chaudhuri
Hi All:
I am getting an error (highlighted) from running R2WinBUGS in R.
To be able to replicate the situation heres the code:
.#Set working directory
setwd(H://AChaudhuri/Testing/CSVS)
matrix=NULL
csvs - paste(MVN, 1:2, .csv, sep=)
for(i in 1:length(csvs)){
  matrix[[i]] - read.csv(file=csvs[i], header=T)
  print(matrix[[i]])
}

So now I have read in 2 simulated datasets which  look like
 Y1 Y2
1 11  6
2  8  5
3 25 13
4  1 13
5  8 22
  Y1 Y2
1  9  1
2  7  9
3 25 13
4  1 18
5  9 12

My next step is to run a multivariate logit normal model on these datasets
and automate this process for such simulated datasets. Heres the model
statement:
model
 {
  for (j in 1 : Nf)

  {
  p1[j, 1:2 ] ~ dmnorm(gamma[1:2 ], T[1:2 ,1:2 ])

  for (i in 1:2)
  {
 logit(p[j,i])-p1[j,i]

 Y[j,i] ~ dbin(p[j,i],n)
}}

I am trying to use the following code to run it in R
library(R2WinBUGS)
bugs.output - list()
for(i in 1:2){

   Y -(matrix[i])

   bugs.output[[i]] - bugs(
   data=list(Y=Y, Nf=5), # change for no of sites
inits=NULL,
   model.file=M-LN_model_trial.txt,
   parameters.to.save = c(p,rho,sigma2),
n.chains=1, n.iter=12000, n.burnin=5000,
bugs.directory=H://AChaudhuri/winbugs14/WinBUGS14,
working.directory=NULL)}


Error in FUN(X[[1L]], ...) :

  .C(..): 'type' must be real for this format

Any suggestion would be helpful.
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.


[R] Setting Derived Class Slots

2013-07-16 Thread Steve Creamer
Dear AllI am really struggling with oo in R. Trying to set attributes of
the base class in a derived class method but the slot is only populated in
the method itself, not when I try to print out the object from the console.

Code is  

library(RODBC)
#
# -
# Define a medical event class. This is abstract (VIRTUAL)
# -
#
setClass(Medical_Event,
 representation(
Event_Name=character,
Capacity_Profile=numeric,
Delay_Profile=numeric,
VIRTUAL),
 prototype(Event_Name=An
Event,Capacity_Profile=c(.2,.2,.2,.2,.2,0,0)))

setGeneric(getDelayProfile,function(object){standardGeneric(getDelayProfile)},simpleInheritanceOnly=T)

# --
# Now define a derived class called GP_Event
# --

setClass(GP_Event,representation(Surgery_Name=character),contains=c(Medical_Event),prototype(Surgery_Name=Unknown))

# -
# Now define a derived class called OP_Appt
# -

setClass(OP_Appt,representation(Clinic_Name=character),contains=c(Medical_Event),prototype(Clinic_Name=Unknown))


setMethod(f=getDelayProfile,signature(OP_Appt),definition=function(object)
   {
  OpTablesDB-odbcDriverConnect(DRIVER=Microsoft Access Driver (*.mdb,
*.accdb);
 DBQ=Z:\\srp\\Development
Code\\Projects\\CancerPathwaySimulation\\Database\\CancerPathway.accdb)
  strQuery-select * from op_profile
  odbcQuery(OpTablesDB,strQuery)
  dfQuery-odbcFetchRows(OpTablesDB)
  odbcClose(OpTablesDB)
  delay-dfQuery$data[[1]][1:70]
  prob-dfQuery$data[[2]][1:70]
#  as(object,Medical_Event)@Delay_Profile-prob
  object@Delay_Profile - prob
   object
   }
)

if I instantiate a new instance of the derived class 

*aTest-new(OPP_Appt)*and then try and populate the attribute
Delay_Profile by 

*getDelayProfile(aTest) *

the object slot seems to be populated in the method because I can print it
out, viz

An object of class OP_Appt
Slot Clinic_Name:
[1] Unknown

Slot Event_Name:
[1] An Event

Slot Capacity_Profile:
[1] 0.2 0.2 0.2 0.2 0.2 0.0 0.0

*Slot Delay_Profile:
 [1]  14  21  25  29  27  49  72  71  43  65 102 134 223 358  24  14  21  25 
35  31  38  43  31  23  21  26  46  54  42  26
[31]  34  24  25  41  48  33  30  17  18  31  24  35  35  24  16  32  36  39 
46  36  26  16  27  21  30  32  33  27   7   5
[61]   9  10   9  11   8   6   1  11  14  10*

but when the method returns and I type

*aTest*

I get 

An object of class OP_Appt
Slot Clinic_Name:
[1] Unknown

Slot Event_Name:
[1] An Event

Slot Capacity_Profile:
[1] 0.2 0.2 0.2 0.2 0.2 0.0 0.0

*Slot Delay_Profile:
numeric(0)*

ie the Delay_Profile slot is empty

What haven't I done - can anybody help me please?
Many Thanks

Steve Creamer




--
View this message in context: 
http://r.789695.n4.nabble.com/Setting-Derived-Class-Slots-tp4671683.html
Sent from the R help mailing list archive at Nabble.com.

__
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] glm - change offset to avoid NA?

2013-07-16 Thread Hermann Norpois
I did not think of something like try. I thouht that there should always
be a value if I do a logistic regression but sometimes the values are far
from being meaningful. So there is a cut-off. My plan was to change the
cut-off.
Thanks
Johannes


2013/7/15 Bert Gunter gunter.ber...@gene.com

 I think what you want is

 ?try  ##or
 ?tryCatch

 ## The second is more flexible but slightly more complicated.

 to trap the error and perhaps refit the model without interaction?

 Cheers,
 Bert

 On Mon, Jul 15, 2013 at 10:45 AM, Hermann Norpois hnorp...@gmail.com
 wrote:
  Hello,
 
  I use glm within a function testing for the appearence of the coexistence
  of (minor allels in a subset of)  snps. And then I extract the
  Pr(|z|)-value for the interaction. Principally it works but sometimes
 the
  function stops because this value for the interaction  is NA. For
  instance, this is the case in the following example:
 
  lz - glm(trait~rs7572685*rs10520302, data=mus, family=binomial)
  summary (lz)
  ...
  Coefficients: (1 not defined because of singularities)
   Estimate Std. Error z value Pr(|z|)
  (Intercept)   0.056140.16782   0.3350.738
  rs7572685 0.490410.41437   1.1830.237
  rs105203020.492690.43514   1.1320.258
  rs7572685:rs10520302   NA NA  NA   NA
  ...
 
  I would prefer some values instead of NA (though it does not make any
 sense
  in terms of interpretation) for the sake of the smooth running of my
  function. How is this done? I guess I have to change the offset but I
 dont
  understand how.
  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.



 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:

 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm


[[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] Errors using large numbers ((i) all entries of 'x' must be nonnegative and finite and (ii) NAs introduced by coercion)

2013-07-16 Thread jgibbons1
Hello,
I am fairly new to R, so please forgive me if this is a fairly easy
solution.

I am trying to perform multiple Fisher's Exact tests or Pearson's
Chi-squared contingency tests from a datamatrix in which data from each row
is data for an independent test.

My data is formatted as such:

AAA 75533 4756922556 88210 6715122129
BBB 14869 4756983220 16384 6715193955
CCC  7230 4756990859  8559 6715201780
DDD 18332 4756979757 23336 6715187003
EEE 14733 4756983356 16826 6715193513
FFF  2918 4756995171  3433 6715206906
GGG  3726 4756994363  4038 6715206301
HHH  6196 4756991893  7011 6715203328
III  7925 4756990164  9130 6715201209
JJJ  1434 4756996655  1602 6715208737

Where the 1st column is the identifier, the 2nd column = observations 1, the
3rd column = background counts 1, the 4th column = observations 2 and the
5th column = background counts 2.

I am loading my data as such:

  data=read.table(My.File, header=FALSE)

And I am looping through each row to perform a test like this:

  pvalues=c(pvalue)
  for(i in 1:10){
 + datamatrix=matrix(c(as.integer(data[i,2:5])),nrow=2)
 + fisherresult=fisher.test(datamatrix)
 + pvalues=cbind(pvalues,fisherresult[1])
 + }

Here is the Error I am Getting:

Error in fisher.test(datamatrix) : 
  all entries of 'x' must be nonnegative and finite
In addition: Warning messages:
1: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
  NAs introduced by coercion
2: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
  NAs introduced by coercion
 

When I replace the large number in the 3rd and 5th column with smaller
numbers, the statistical calculation works fine.

Any ideas? Any help would be GREATLY appreciated!



--
View this message in context: 
http://r.789695.n4.nabble.com/Errors-using-large-numbers-i-all-entries-of-x-must-be-nonnegative-and-finite-and-ii-NAs-introduced-b-tp4671685.html
Sent from the R help mailing list archive at Nabble.com.

__
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] glm - change offset to avoid NA?

2013-07-16 Thread David Winsemius

On Jul 16, 2013, at 8:52 AM, Hermann Norpois wrote:

 I did not think of something like try. I thouht that there should always
 be a value if I do a logistic regression but sometimes the values are far
 from being meaningful. So there is a cut-off.

That seems implausilbe. I think you are just seeing the effect of a random 
selection creating a data situation where the interaction term is aliased with 
the others, in which case `glm` will set the coefficient to NA.

 My plan was to change the
 cut-off.

You said there was an error, but you should have said that the results were 
unexpected. You can create an error-condition when this occurs with the 
`stop` function. And then do whatever remedial work is needed.

-- 
David.

 Thanks
 Johannes
 
 
 2013/7/15 Bert Gunter gunter.ber...@gene.com
 
 I think what you want is
 
 ?try  ##or
 ?tryCatch
 
 ## The second is more flexible but slightly more complicated.
 
 to trap the error and perhaps refit the model without interaction?
 
 Cheers,
 Bert
 
 On Mon, Jul 15, 2013 at 10:45 AM, Hermann Norpois hnorp...@gmail.com
 wrote:
 Hello,
 
 I use glm within a function testing for the appearence of the coexistence
 of (minor allels in a subset of)  snps. And then I extract the
 Pr(|z|)-value for the interaction. Principally it works but sometimes
 the
 function stops because this value for the interaction  is NA. For
 instance, this is the case in the following example:
 
 lz - glm(trait~rs7572685*rs10520302, data=mus, family=binomial)
 summary (lz)
 ...
 Coefficients: (1 not defined because of singularities)
 Estimate Std. Error z value Pr(|z|)
 (Intercept)   0.056140.16782   0.3350.738
 rs7572685 0.490410.41437   1.1830.237
 rs105203020.492690.43514   1.1320.258
 rs7572685:rs10520302   NA NA  NA   NA
 ...
 
 I would prefer some values instead of NA (though it does not make any
 sense
 in terms of interpretation) for the sake of the smooth running of my
 function. How is this done? I guess I have to change the offset but I
 dont
 understand how.
 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.
 
 
 
 --
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 Internal Contact Info:
 Phone: 467-7374
 Website:
 
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
 
 
   [[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.

David Winsemius
Alameda, CA, USA

__
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] Setting Derived Class Slots

2013-07-16 Thread Martin Morgan

On 07/16/2013 06:36 AM, Steve Creamer wrote:

Dear AllI am really struggling with oo in R. Trying to set attributes of
the base class in a derived class method but the slot is only populated in
the method itself, not when I try to print out the object from the console.

Code is

library(RODBC)
#
# -
# Define a medical event class. This is abstract (VIRTUAL)
# -
#
setClass(Medical_Event,
  representation(
 Event_Name=character,
 Capacity_Profile=numeric,
 Delay_Profile=numeric,
 VIRTUAL),
  prototype(Event_Name=An
Event,Capacity_Profile=c(.2,.2,.2,.2,.2,0,0)))

setGeneric(getDelayProfile,function(object){standardGeneric(getDelayProfile)},simpleInheritanceOnly=T)

# --
# Now define a derived class called GP_Event
# --

setClass(GP_Event,representation(Surgery_Name=character),contains=c(Medical_Event),prototype(Surgery_Name=Unknown))

# -
# Now define a derived class called OP_Appt
# -

setClass(OP_Appt,representation(Clinic_Name=character),contains=c(Medical_Event),prototype(Clinic_Name=Unknown))


setMethod(f=getDelayProfile,signature(OP_Appt),definition=function(object)
{
   OpTablesDB-odbcDriverConnect(DRIVER=Microsoft Access Driver (*.mdb,
*.accdb);
  DBQ=Z:\\srp\\Development
Code\\Projects\\CancerPathwaySimulation\\Database\\CancerPathway.accdb)
   strQuery-select * from op_profile
   odbcQuery(OpTablesDB,strQuery)
   dfQuery-odbcFetchRows(OpTablesDB)
   odbcClose(OpTablesDB)
   delay-dfQuery$data[[1]][1:70]
   prob-dfQuery$data[[2]][1:70]
#  as(object,Medical_Event)@Delay_Profile-prob
   object@Delay_Profile - prob
object
}
)

if I instantiate a new instance of the derived class

*aTest-new(OPP_Appt)*and then try and populate the attribute
Delay_Profile by

*getDelayProfile(aTest) *

the object slot seems to be populated in the method because I can print it
out, viz

An object of class OP_Appt
Slot Clinic_Name:
[1] Unknown

Slot Event_Name:
[1] An Event

Slot Capacity_Profile:
[1] 0.2 0.2 0.2 0.2 0.2 0.0 0.0

*Slot Delay_Profile:
  [1]  14  21  25  29  27  49  72  71  43  65 102 134 223 358  24  14  21  25
35  31  38  43  31  23  21  26  46  54  42  26
[31]  34  24  25  41  48  33  30  17  18  31  24  35  35  24  16  32  36  39
46  36  26  16  27  21  30  32  33  27   7   5
[61]   9  10   9  11   8   6   1  11  14  10*

but when the method returns and I type

*aTest*

I get

An object of class OP_Appt
Slot Clinic_Name:
[1] Unknown

Slot Event_Name:
[1] An Event

Slot Capacity_Profile:
[1] 0.2 0.2 0.2 0.2 0.2 0.0 0.0

*Slot Delay_Profile:
numeric(0)*

ie the Delay_Profile slot is empty

What haven't I done - can anybody help me please?


It helps to provide a more minimal example, preferably reproducible (no data 
base queries needed to illustrate your problem); I'm guessing that, just as with


f = funtion(l) { l$a = 1; l }
lst = list(a=0, b=1)

one would 'update' lst with

  lst = f(lst)

and not

  f(lst)

you need to assign the return value to the original object

  aTest - getDelayProfile(aTest)

Martin


Many Thanks

Steve Creamer




--
View this message in context: 
http://r.789695.n4.nabble.com/Setting-Derived-Class-Slots-tp4671683.html
Sent from the R help mailing list archive at Nabble.com.

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




--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
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] Setting Derived Class Slots

2013-07-16 Thread Simon Zehnder
Hi Steve,

it seems to me, that you want to pass an object inside of getDelayProfile. In 
this case you must use setReplaceMethod(getDelayProfile-,) in your 
definition inside the virtual and of course also in the specification of 
OP_Appt. R does not know, that your function should give back an object, that 
replaces the one on which it was called.

Otherwise making any modifications on the slot of the object inside the 
function will never arrive at the object outside of the function. They have two 
different environments and as soon as you modify an object inside of a function 
R builds a copy of it. See more about this by googling R pass-by-value.  

By the way: I wouldn't call this function getDelayProfile as getters and 
setters have usually differing a different meaning (encapsulation) in OO 
programming. Use rather something like fetchDelayProfile or 
initializeDelayProfile. It will probably make it easier for Users and 
Programmers to work with your program. 


Hope this helps

Best 

Simon

On Jul 16, 2013, at 3:36 PM, Steve Creamer stephen.crea...@nhs.net wrote:

 


[[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] Ode error message

2013-07-16 Thread Berend Hasselman


See inline remarks.

On 16-07-2013, at 10:07, Raphaëlle Carraud raphaelle.carr...@oc-metalchem.com 
wrote:

 Hello,
 
 I am creating a program with R to solve a differential equation system. 
 However, I get the following message I do not understand :
 
 out - ode(y = state, times = z, func = liquide, parms = 0, atol = 0)
 DLSODA-  EWT(I1) is R1 .le. 0.0
 In above message, I1 = 1
 
 In above message, R1 = 0
 
 Error in lsoda(y, times, func, parms, ...) : 
  illegal input detected before taking any integration steps - see written 
 message
 
 or this one when I tried modifying the atoll value :
 
 out - ode(y = state, times = z, func = liquide, parms = 0, atol = 10^-14)
 DLSODA-  Warning..Internal T (=R1) and H (=R2) are
  such that in the machine, T + H = T on the next step
 (H = step size). Solver will continue anyway.
 In above message, R1 = 0, R2 = 0
 
 DINTDY-  T (=R1) illegal
 In above message, R1 = 1
 
  T not in interval TCUR - HU (= R1) to TCUR (=R2)
 In above message, R1 = 0, R2 = 0
 
 DINTDY-  T (=R1) illegal
 In above message, R1 = 2
 
  T not in interval TCUR - HU (= R1) to TCUR (=R2)
 In above message, R1 = 0, R2 = 0
 
 DLSODA-  Trouble in DINTDY.  ITASK = I1, TOUT = R1
 In above message, I1 = 1
 
 In above message, R1 = 2
 
 Here is my program. I also tried changing the initial values but it does not 
 work well.
 
 liquide - function(z, state, parameters) {
  with(as.list(c(state,parameters)),{
# rate of change
 
Tr - 273+90

Why are you defining Tr? It is not used anywhere

C - CA + CB + CC + CD + CE + CI + CG + CJ + CK + CH
 

Same thing. Not used.

K32 - 6.54*10^4  
K33 - 1.37*10^4  
K34 - 330 
K35 - 5.81*10^4  
kf2 - 1.37*10^3  
kf3 - 1.37*10^3 
kf4 - 8.68*10^5  
kf5 - 157.2
 
K2 - 10^1.37
K3 - 10^(-3.35) 
 
r1 - kf4*CD - kf4/K34*CE^2
r2 - kf3*CA*CB - kf3/K33*CD
r3 - kf2*CA^2 - kf2/K32*CC
r4 - kf5*CC - kf5/K35*CE*CI^2 
 
 
dCA - -r2  # dNO/dt
dCB - -r3 - r2   # dNO2/dt
dCC - r3/2 - r4 # dN2O4/dt
dCD - r2 - r1# dN2O3/dt
dCE - 2*r1 + r4# dHNO2/dt
dCI - r4 # 
 dHNO3/dt
dCG - -r4 - r1   # dH2O/dz
dCH - (dCE + dCI)/((K2 + K3)*(CE + CI))  # dH/dz
dCJ -  (CH*dCI - CI*dCH)/(K3*CH^2)  # dNO3-/dz

You are dividing by CH, which is 0 initially. So what value does dCH  then get?
dCK -  (CH*dCE - CE*dCH)/(K2*CH^2)# dNO2-/dz
 

Same thing.
 
 
list(c(dCA, dCB, dCC, dCD, dCE, dCI, dCG, dCH, dCJ, dCK))
  })   # end with(as.list ...
 }
 
 
 Ti - 273+90   # K

You are not using Ti.
 Ct - 5100   # mol/m^3
 

And Ct is also not used.

 state -c(CA = 0,   # mol/m^3 NO2
  CB = 0,   # mol/m^3 NO
  CC = 0,# mol/m^3 N2O4
  CD = 0,  # mol/m^3 N2O3
  CE = 50,  # mol/m^3 HNO2
  CI = 50, # mol/m^3 HNO3
  CG = 5000, # mol/m^3 H2O
  CH = 0, # mol/m^3 H+

0!!

  CJ = 0,# mol/m^3 NO3-
  CK = 0) # mol/m^3 NO2-
 
 parameters - c(Ct = 5100)
 

Why not parameters - c(Ct = Ct)?

 z - seq(0, 15, by = 1)  # en seconde
 
 library(deSolve)
 out - ode(y = state, times = z, func = liquide, parms = 0, atol = 10^-14)
 head(out)
 plot(out)
 
You will still get messages.
You should really learn to de elementary debugging.
Such as inserting

liquide(0,state,parameters)

after defining state and parameters to check and test.

Berend

 Thank you
 
 __
 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] Errors using large numbers ((i) all entries of 'x' must be nonnegative and finite and (ii) NAs introduced by coercion)

2013-07-16 Thread PIKAL Petr
Well,

You could find it yourself,

as.integer(c(75533, 4756922556, 88210, 6715122129))
[1] 75533NA 88210NA
Warning message:
NAs introduced by coercion 
 matrix(c(75533, 4756922556, 88210, 6715122129), nrow=2)
   [,1]   [,2]
[1,]  75533  88210
[2,] 4756922556 6715122129

Using as.integer inputs NA as integer type has limited size.

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of jgibbons1
 Sent: Tuesday, July 16, 2013 4:44 PM
 To: r-help@r-project.org
 Subject: [R] Errors using large numbers ((i) all entries of 'x' must be
 nonnegative and finite and (ii) NAs introduced by coercion)
 
 Hello,
 I am fairly new to R, so please forgive me if this is a fairly easy
 solution.
 
 I am trying to perform multiple Fisher's Exact tests or Pearson's Chi-
 squared contingency tests from a datamatrix in which data from each row
 is data for an independent test.
 
 My data is formatted as such:
 
 AAA 75533 4756922556 88210 6715122129
 BBB 14869 4756983220 16384 6715193955
 CCC  7230 4756990859  8559 6715201780
 DDD 18332 4756979757 23336 6715187003
 EEE 14733 4756983356 16826 6715193513
 FFF  2918 4756995171  3433 6715206906
 GGG  3726 4756994363  4038 6715206301
 HHH  6196 4756991893  7011 6715203328
 III  7925 4756990164  9130 6715201209
 JJJ  1434 4756996655  1602 6715208737
 
 Where the 1st column is the identifier, the 2nd column = observations
 1, the 3rd column = background counts 1, the 4th column = observations
 2 and the 5th column = background counts 2.
 
 I am loading my data as such:
 
   data=read.table(My.File, header=FALSE)
 
 And I am looping through each row to perform a test like this:
 
   pvalues=c(pvalue)
   for(i in 1:10){
  + datamatrix=matrix(c(as.integer(data[i,2:5])),nrow=2)
  + fisherresult=fisher.test(datamatrix)
  + pvalues=cbind(pvalues,fisherresult[1])
  + }
 
 Here is the Error I am Getting:
 
 Error in fisher.test(datamatrix) :
   all entries of 'x' must be nonnegative and finite In addition:
 Warning messages:
 1: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
   NAs introduced by coercion
 2: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
   NAs introduced by coercion
 
 
 When I replace the large number in the 3rd and 5th column with smaller
 numbers, the statistical calculation works fine.
 
 Any ideas? Any help would be GREATLY appreciated!
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Errors-
 using-large-numbers-i-all-entries-of-x-must-be-nonnegative-and-finite-
 and-ii-NAs-introduced-b-tp4671685.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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] help

2013-07-16 Thread Dia
Hi, i am tring to learn R own my own. From where can i download data for R
(creating a subset). Right now i'm using
 (http://finance.yahoo.com/q/hp?s=MCD+Historical+Prices) this link for data
but unable to create subset.

Can someone help me using this data or help me to download different data?




--
View this message in context: http://r.789695.n4.nabble.com/help-tp4671698.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] help

2013-07-16 Thread Joshua Ulrich
On Tue, Jul 16, 2013 at 12:23 PM, Dia mnshd...@gmail.com wrote:
 Hi, i am tring to learn R own my own. From where can i download data for R
 (creating a subset). Right now i'm using
  (http://finance.yahoo.com/q/hp?s=MCD+Historical+Prices) this link for data
 but unable to create subset.

 Can someone help me using this data or help me to download different data?

Use quantmod::getSymbols.

library(quantmod)
getSymbols(MCD)
str(MCD)

And read ?xts for ways to subset the MCD object.

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

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

2013-07-16 Thread Belén Cillero
Buenas tardes
Una vez que he leído las variables, sexo, edad, estado civil y nacionalidad, 
¿cómo genero un px para realizar las distintas consultas?. De momento lo único 
que he podido hacer con pxR es leer archivos de extensión px pero no sé 
escribirlos.
Muchas gracias
 
  
[[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] Question on plotting with googleVis

2013-07-16 Thread Greg Snow
The HTKIdentify (requires tcltk package) and HWIdentify (windows only)
functions in the TeachingDemos package will show identifying information on
a plot for the point being hovered over.  Both functions are pure R code,
so if they don't work for you as is you can modify the source to make
whatever tweaks you may want.


On Mon, Jul 15, 2013 at 12:00 PM, Christofer Bogaso 
bogaso.christo...@gmail.com wrote:

 Hello again,

 Let say I have following data-frame:

 MyData - data.frame(Names1 = paste(XXX, 1:150), Values1 = 1:150 + 10,
 Values2 = 1:150)

 Now I want to plot this data-frame with googleVis. Therefore I run
 following codes:

 library(googleVis)
 plot(gvisBarChart(MyData, xvar=Names1, yvar=c(Values1, Values2)))

 However the problem is that, hardly this plot can be read. However if I
 plot a fraction of my data-frame then the underlying plot is clearly
 visible:

 plot(gvisBarChart(MyData[1:15,], xvar=Names1, yvar=c(Values1,
 Values2)))  ## This is clearly visible.


 I would really appreciate if someone gives me some pointer how I can
 clearly plot my data-frame with googleVis. I understand that there are many
 other plotting methods available with R like ggplot, however here I want to
 use googleVis because of its strength in showing the values within the plot
 area itself if you hover your mouse.

 Thanks and regards,

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




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] (1 - 0.7) == 0.3

2013-07-16 Thread arun
HI,
2-0.7==0.3
#[1] FALSE
##May be u meant
 2-0.7==1.3
#[1] TRUE


Possibly R FAQ 7.31
Also, check
http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy

all.equal(2-0.7,1.3)
#[1] TRUE
 all.equal(1-0.7,0.3)
#[1] TRUE
(1-0.7)(0.3+.Machine$double.eps^0.5)
#[1] TRUE



 p - c(0.2, 0.4, 0.6, 0.8, 1) 
round((1-p)*5,1)+1
#[1] 5 4 3 2 1


In your second example,
 p - c(0.8, 0.6, 0.4, 0.2, 0)
floor((1 - p) * 5) + 1 
#[1] 1 3 4 5 6  
((1-0.8)*5) +1
#[1] 2


 round((1-p)*5,1)+1
#[1] 2 3 4 5 6

A.K.

...is false :( However (2 - 0.7) == 0.3 is true. 

Is there any way to get around this?   

The end goal is for this to work: 

p - c(0.2, 0.4, 0.6, 0.8, 1) 
floor((1 - p) * 5) + 1 

  5 4 3 1 1 

whereas the correct result would have been 5 4 3 2 1. If I set p - c(0.8, 0.6, 
0.4, 0.2, 0) then it works as expected.

__
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] Errors using large numbers ((i) all entries of 'x' must be nonnegative and finite and (ii) NAs introduced by coercion)

2013-07-16 Thread arun


HI,
?as.integer() #documentation
Note that current implementations of R use 32-bit integers for
 integer vectors, so the range of representable integers is
 restricted to about +/-2*10^9: ‘double’s can hold much larger
 integers exactly.
as.numeric(c(75533, 4756922556, 88210, 6715122129))
#[1]  75533 4756922556  88210 6715122129
#or
 as.double(c(75533, 4756922556, 88210, 6715122129))
#[1]  75533 4756922556  88210 6715122129
A.K.





- Original Message -
From: PIKAL Petr petr.pi...@precheza.cz
To: jgibbons1 jgibb...@hsph.harvard.edu; r-help@r-project.org 
r-help@r-project.org
Cc: 
Sent: Tuesday, July 16, 2013 12:54 PM
Subject: Re: [R] Errors using large numbers ((i) all entries of 'x' must be 
nonnegative and finite and (ii) NAs introduced by coercion)

Well,

You could find it yourself,

as.integer(c(75533, 4756922556, 88210, 6715122129))
[1] 75533    NA 88210    NA
Warning message:
NAs introduced by coercion 
 matrix(c(75533, 4756922556, 88210, 6715122129), nrow=2)
           [,1]       [,2]
[1,]      75533      88210
[2,] 4756922556 6715122129

Using as.integer inputs NA as integer type has limited size.

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of jgibbons1
 Sent: Tuesday, July 16, 2013 4:44 PM
 To: r-help@r-project.org
 Subject: [R] Errors using large numbers ((i) all entries of 'x' must be
 nonnegative and finite and (ii) NAs introduced by coercion)
 
 Hello,
 I am fairly new to R, so please forgive me if this is a fairly easy
 solution.
 
 I am trying to perform multiple Fisher's Exact tests or Pearson's Chi-
 squared contingency tests from a datamatrix in which data from each row
 is data for an independent test.
 
 My data is formatted as such:
 
 AAA 75533 4756922556 88210 6715122129
 BBB 14869 4756983220 16384 6715193955
 CCC  7230 4756990859  8559 6715201780
 DDD 18332 4756979757 23336 6715187003
 EEE 14733 4756983356 16826 6715193513
 FFF  2918 4756995171  3433 6715206906
 GGG  3726 4756994363  4038 6715206301
 HHH  6196 4756991893  7011 6715203328
 III  7925 4756990164  9130 6715201209
 JJJ  1434 4756996655  1602 6715208737
 
 Where the 1st column is the identifier, the 2nd column = observations
 1, the 3rd column = background counts 1, the 4th column = observations
 2 and the 5th column = background counts 2.
 
 I am loading my data as such:
 
       data=read.table(My.File, header=FALSE)
 
 And I am looping through each row to perform a test like this:
 
       pvalues=c(pvalue)
       for(i in 1:10){
      + datamatrix=matrix(c(as.integer(data[i,2:5])),nrow=2)
      + fisherresult=fisher.test(datamatrix)
      + pvalues=cbind(pvalues,fisherresult[1])
      + }
 
 Here is the Error I am Getting:
 
 Error in fisher.test(datamatrix) :
   all entries of 'x' must be nonnegative and finite In addition:
 Warning messages:
 1: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
   NAs introduced by coercion
 2: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) :
   NAs introduced by coercion
 
 
 When I replace the large number in the 3rd and 5th column with smaller
 numbers, the statistical calculation works fine.
 
 Any ideas? Any help would be GREATLY appreciated!
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Errors-
 using-large-numbers-i-all-entries-of-x-must-be-nonnegative-and-finite-
 and-ii-NAs-introduced-b-tp4671685.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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-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] Importing data by odbcConnectExcel in 64 bit

2013-07-16 Thread Ahmed Attia
I have probably an old question.

I have R.3.0.1 installed in 64 bit windows 7. The odbcConnectExcel in RODBC
library does not work. Tried odbcConnectExcel2007 still does not work.


Any ideas.

Thanks

Melissa-sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),
 :
  first argument is not an open RODBC channel
In addition: Warning messages:
1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed

Melissa-sqlFetch(odbcConnectExcel(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in odbcConnectExcel(F:\\Cotton2012\\validation.xlsx) :
  odbcConnectExcel is only usable with 32-bit Windows

-- 
Ahmed M. Attia


Research Assistant
Dept. Of SoilCrop Sciences
Texas AM University
ahmed ahmeda...@zu.edu.eg.at...@ag.tamu.edu
Cell phone: 001-979-248-5215

[[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] Importing data by odbcConnectExcel in 64 bit

2013-07-16 Thread Adams, Jean
Can't help you with the odbcConnectExcel, but I can suggest an alternative
... loadWorkbook() and readWorksheet() in the XLConnect package work on
Windows 7 64-bit.

library(XLConnect)
wb - loadWorkbook(C:/Temp/Mydata.xlsx)
dat - readWorksheet(wb, sheet=Sheet1)

Jean


On Tue, Jul 16, 2013 at 1:25 PM, Ahmed Attia ahmedati...@gmail.com wrote:

 I have probably an old question.

 I have R.3.0.1 installed in 64 bit windows 7. The odbcConnectExcel in RODBC
 library does not work. Tried odbcConnectExcel2007 still does not work.


 Any ideas.

 Thanks


 Melissa-sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),sqtable
 = Sheet3,
 + na.strings = NA, as.is = TRUE)
 Error in sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),
  :
   first argument is not an open RODBC channel
 In addition: Warning messages:
 1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
   [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
 Manager] Data source name not found and no default driver specified
 2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
   ODBC connection failed
 

 Melissa-sqlFetch(odbcConnectExcel(F:\\Cotton2012\\validation.xlsx),sqtable
 = Sheet3,
 + na.strings = NA, as.is = TRUE)
 Error in odbcConnectExcel(F:\\Cotton2012\\validation.xlsx) :
   odbcConnectExcel is only usable with 32-bit Windows

 --
 Ahmed M. Attia


 Research Assistant
 Dept. Of SoilCrop Sciences
 Texas AM University
 ahmed ahmeda...@zu.edu.eg.at...@ag.tamu.edu
 Cell phone: 001-979-248-5215

 [[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] pxR

2013-07-16 Thread Rafael Robledo
Hola,

creo que la función que buscas es write.px, que te permite guardar un
objeto de tipo 'px' a un archivo.

Por ejemplo:

opx1 - read.px( system.file( extdata, example.px, package = pxR) )
write.px ( opx1, file = ’opx.px’) # write a copy
opx2 - read.px (’opx.px’) # read the copy

con el que lees un archivo px y su contenido lo guardas en otro lugar.

Si tienes más dudas, puedes revisar el manual del paquete pxR, que
está en http://cran.r-project.org/web/packages/pxR/pxR.pdf

Recuerda que esta lista de correos es principalmente para personas que
hablan en inglés, por lo que si preguntas en ese idioma, habrá más
posibilidades de que te respondan.

Saludos :)


2013/7/16 Belén Cillero belen.cill...@hotmail.com:
 Buenas tardes
 Una vez que he leído las variables, sexo, edad, estado civil y nacionalidad, 
 ¿cómo genero un px para realizar las distintas consultas?. De momento lo 
 único que he podido hacer con pxR es leer archivos de extensión px pero no sé 
 escribirlos.
 Muchas gracias


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




--
Rafael Robledo J.

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


[R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
Hi list,

I am using scale() to standardize a distribution?  But why does it
give me attributes attached to the data?  I just want a standardized
matrix, that is all.

library(mvtnorm)
 x - rmvnorm(15, mean=rep(50, 10))
 x
  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
  [,8] [,9]
 [1,] 51.17519 52.34341 49.63084 47.99234 51.63113 50.91391 49.36819
49.23901 51.17377
 [2,] 50.57039 49.17210 48.64395 49.03940 49.65761 49.93840 49.94883
50.69044 49.57632
 [3,] 50.64811 50.21503 50.13786 49.15879 48.51550 50.19444 50.23710
50.98040 51.37032
 [4,] 49.22797 49.66445 49.93287 48.63681 50.49457 50.33302 52.29552
49.98424 51.04724
 [5,] 49.72099 50.84510 50.60976 49.60883 53.59509 49.14728 50.23134
49.09141 49.23780
 [6,] 49.49126 50.90938 49.67140 50.08951 49.79854 49.03711 50.26037
50.24975 48.26958
 [7,] 51.12384 47.92778 50.60112 49.01554 49.47515 50.12756 51.65216
49.21998 49.63808
 [8,] 51.45123 50.44037 50.01039 50.27511 49.97658 51.63002 50.37156
50.02685 48.95423
 [9,] 51.16989 50.16200 51.17724 50.71678 50.79565 50.27128 51.05608
49.61165 47.81732
[10,] 49.54263 49.93501 49.71762 49.33378 51.44935 51.53775 50.54346
49.98333 49.59422
[11,] 51.16497 49.82914 49.08821 51.02918 49.67663 49.53498 50.26647
49.48569 50.94504
[12,] 51.16827 50.50244 49.13003 49.00155 50.26457 48.85465 49.11593
50.58031 51.14926
[13,] 48.26216 49.94866 48.62526 49.11995 50.40082 49.25359 48.57677
50.66760 49.44108
[14,] 49.82530 49.17352 50.05588 50.51265 51.04926 50.32474 49.78180
50.48349 49.92431
[15,] 50.55772 49.84691 47.95021 50.24911 49.85335 50.73062 51.48718
51.36693 50.18307
 [,10]
 [1,] 50.13859
 [2,] 51.54920
 [3,] 49.23230
 [4,] 50.92683
 [5,] 50.97708
 [6,] 50.78799
 [7,] 50.53913
 [8,] 49.30832
 [9,] 49.43606
[10,] 49.42060
[11,] 50.21002
[12,] 51.94848
[13,] 49.41352
[14,] 52.24064
[15,] 51.19474
 scale(x, center=TRUE, scale=TRUE)
[,1]   [,2] [,3][,4][,5]
 [,6][,7]
 [1,]  0.8890317  2.3390090 -0.040395734 -1.86089754  1.00159470
0.92533476 -0.99715965
 [2,]  0.2452502 -0.9109703 -1.190404546 -0.63771097 -0.66104313
-0.21446975 -0.40514793
 [3,]  0.3279747  0.1578297  0.550427419 -0.49823662 -1.62323564
0.08468695 -0.11121941
 [4,] -1.1837031 -0.4064112  0.311551281 -1.10802250  0.04407804
0.24660932  1.98754311
 [5,] -0.6589074  0.8035298  1.100314901  0.02749734  2.65618150
-1.13883336 -0.11709623
 [6,] -0.9034419  0.8694088  0.006865424  0.58904255 -0.54231158
-1.26755243 -0.08749646
 [7,]  0.8343705 -2.1861602  1.090250934 -0.66558751 -0.81476108
0.00655050  1.33157578
 [8,]  1.1828615  0.3887665  0.401888014  0.80585326 -0.39231482
1.76205433  0.02587038
 [9,]  0.8833860  0.1034854  1.761589113  1.32181395  0.29773018
0.17447101  0.72381232
[10,] -0.8487569 -0.1291363  0.060728488 -0.29381647  0.84844800
1.65423826  0.20113824
[11,]  0.8781560 -0.2376361 -0.672712386  1.68676651 -0.64501776
-0.68583461 -0.08127647
[12,]  0.8816611  0.4523675 -0.623990804 -0.68193230 -0.14968994
-1.48074503 -1.25436403
[13,] -2.2117715 -0.1151423 -1.212190165 -0.54361597 -0.03490809
-1.01461386 -1.80409304
[14,] -0.5478718 -0.9095198  0.454889973  1.08335795  0.51138447
0.23693367 -0.57544865
[15,]  0.2317608 -0.2194204 -1.998811911  0.77548830 -0.49613484
0.71117025  1.16336204
[,8][,9]   [,10]
 [1,] -1.2666791  1.17934107 -0.35061189
 [2,]  0.8423439 -0.28600703  1.06389274
 [3,]  1.2636749  1.35963155 -1.25940610
 [4,] -0.1838111  1.06327078  0.43980595
 [5,] -1.4811512 -0.59653247  0.49019839
 [6,]  0.2019965 -1.48467432  0.30058779
 [7,] -1.2943281 -0.22935616  0.05103467
 [8,] -0.1218950 -0.85664924 -1.18316969
 [9,] -0.7252082 -1.89953387 -1.05507780
[10,] -0.1851315 -0.26958168 -1.07058564
[11,] -0.9082374  0.96952049 -0.27897948
[12,]  0.6823136  1.15685832  1.46428187
[13,]  0.8091562 -0.41005981 -1.07768018
[14,]  0.5416286  0.03320871  1.75724879
[15,]  1.8253278  0.27056365  0.70846058
attr(,scaled:center)
 [1] 50.33999 50.06102 49.66551 49.58529 50.44225 50.12196 50.34618
50.11074 49.88811
[10] 50.48823
attr(,scaled:scale)
 [1] 0.9394453 0.9757930 0.8581604 0.8560117 1.1869812 0.8558562
0.9807762 0.6882016
 [9] 1.0901550 0.9972455


Also,
 attributes(x) - NULL
will not work since this is matrix not vector.

Thanks,
Mike

__
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 remove attributes from scale() in a matrix?

2013-07-16 Thread arun
HI,
Try:
x1-scale(x,center=TRUE,scale=TRUE)
str(x1)
# num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
# - attr(*, scaled:center)= num [1:10] 50.2 50 49.8 49.8 50.3 ...
 #- attr(*, scaled:scale)= num [1:10] 1.109 0.956 0.817 0.746 1.019 ...

 attr(x1,scaled:center)-NULL
 attr(x1,scaled:scale)-NULL
str(x1)
 #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
A.K.




- Original Message -
From: C W tmrs...@gmail.com
To: r-help r-help@r-project.org
Cc: 
Sent: Tuesday, July 16, 2013 3:59 PM
Subject: [R] How to remove attributes from scale() in a matrix?

Hi list,

I am using scale() to standardize a distribution?  But why does it
give me attributes attached to the data?  I just want a standardized
matrix, that is all.

library(mvtnorm)
 x - rmvnorm(15, mean=rep(50, 10))
 x
          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
  [,8]     [,9]
[1,] 51.17519 52.34341 49.63084 47.99234 51.63113 50.91391 49.36819
49.23901 51.17377
[2,] 50.57039 49.17210 48.64395 49.03940 49.65761 49.93840 49.94883
50.69044 49.57632
[3,] 50.64811 50.21503 50.13786 49.15879 48.51550 50.19444 50.23710
50.98040 51.37032
[4,] 49.22797 49.66445 49.93287 48.63681 50.49457 50.33302 52.29552
49.98424 51.04724
[5,] 49.72099 50.84510 50.60976 49.60883 53.59509 49.14728 50.23134
49.09141 49.23780
[6,] 49.49126 50.90938 49.67140 50.08951 49.79854 49.03711 50.26037
50.24975 48.26958
[7,] 51.12384 47.92778 50.60112 49.01554 49.47515 50.12756 51.65216
49.21998 49.63808
[8,] 51.45123 50.44037 50.01039 50.27511 49.97658 51.63002 50.37156
50.02685 48.95423
[9,] 51.16989 50.16200 51.17724 50.71678 50.79565 50.27128 51.05608
49.61165 47.81732
[10,] 49.54263 49.93501 49.71762 49.33378 51.44935 51.53775 50.54346
49.98333 49.59422
[11,] 51.16497 49.82914 49.08821 51.02918 49.67663 49.53498 50.26647
49.48569 50.94504
[12,] 51.16827 50.50244 49.13003 49.00155 50.26457 48.85465 49.11593
50.58031 51.14926
[13,] 48.26216 49.94866 48.62526 49.11995 50.40082 49.25359 48.57677
50.66760 49.44108
[14,] 49.82530 49.17352 50.05588 50.51265 51.04926 50.32474 49.78180
50.48349 49.92431
[15,] 50.55772 49.84691 47.95021 50.24911 49.85335 50.73062 51.48718
51.36693 50.18307
         [,10]
[1,] 50.13859
[2,] 51.54920
[3,] 49.23230
[4,] 50.92683
[5,] 50.97708
[6,] 50.78799
[7,] 50.53913
[8,] 49.30832
[9,] 49.43606
[10,] 49.42060
[11,] 50.21002
[12,] 51.94848
[13,] 49.41352
[14,] 52.24064
[15,] 51.19474
 scale(x, center=TRUE, scale=TRUE)
            [,1]       [,2]         [,3]        [,4]        [,5]
[,6]        [,7]
[1,]  0.8890317  2.3390090 -0.040395734 -1.86089754  1.00159470
0.92533476 -0.99715965
[2,]  0.2452502 -0.9109703 -1.190404546 -0.63771097 -0.66104313
-0.21446975 -0.40514793
[3,]  0.3279747  0.1578297  0.550427419 -0.49823662 -1.62323564
0.08468695 -0.11121941
[4,] -1.1837031 -0.4064112  0.311551281 -1.10802250  0.04407804
0.24660932  1.98754311
[5,] -0.6589074  0.8035298  1.100314901  0.02749734  2.65618150
-1.13883336 -0.11709623
[6,] -0.9034419  0.8694088  0.006865424  0.58904255 -0.54231158
-1.26755243 -0.08749646
[7,]  0.8343705 -2.1861602  1.090250934 -0.66558751 -0.81476108
0.00655050  1.33157578
[8,]  1.1828615  0.3887665  0.401888014  0.80585326 -0.39231482
1.76205433  0.02587038
[9,]  0.8833860  0.1034854  1.761589113  1.32181395  0.29773018
0.17447101  0.72381232
[10,] -0.8487569 -0.1291363  0.060728488 -0.29381647  0.84844800
1.65423826  0.20113824
[11,]  0.8781560 -0.2376361 -0.672712386  1.68676651 -0.64501776
-0.68583461 -0.08127647
[12,]  0.8816611  0.4523675 -0.623990804 -0.68193230 -0.14968994
-1.48074503 -1.25436403
[13,] -2.2117715 -0.1151423 -1.212190165 -0.54361597 -0.03490809
-1.01461386 -1.80409304
[14,] -0.5478718 -0.9095198  0.454889973  1.08335795  0.51138447
0.23693367 -0.57544865
[15,]  0.2317608 -0.2194204 -1.998811911  0.77548830 -0.49613484
0.71117025  1.16336204
            [,8]        [,9]       [,10]
[1,] -1.2666791  1.17934107 -0.35061189
[2,]  0.8423439 -0.28600703  1.06389274
[3,]  1.2636749  1.35963155 -1.25940610
[4,] -0.1838111  1.06327078  0.43980595
[5,] -1.4811512 -0.59653247  0.49019839
[6,]  0.2019965 -1.48467432  0.30058779
[7,] -1.2943281 -0.22935616  0.05103467
[8,] -0.1218950 -0.85664924 -1.18316969
[9,] -0.7252082 -1.89953387 -1.05507780
[10,] -0.1851315 -0.26958168 -1.07058564
[11,] -0.9082374  0.96952049 -0.27897948
[12,]  0.6823136  1.15685832  1.46428187
[13,]  0.8091562 -0.41005981 -1.07768018
[14,]  0.5416286  0.03320871  1.75724879
[15,]  1.8253278  0.27056365  0.70846058
attr(,scaled:center)
[1] 50.33999 50.06102 49.66551 49.58529 50.44225 50.12196 50.34618
50.11074 49.88811
[10] 50.48823
attr(,scaled:scale)
[1] 0.9394453 0.9757930 0.8581604 0.8560117 1.1869812 0.8558562
0.9807762 0.6882016
[9] 1.0901550 0.9972455


Also,
 attributes(x) - NULL
will not work since this is matrix not vector.

Thanks,
Mike

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting 

Re: [R] Importing data by odbcConnectExcel in 64 bit

2013-07-16 Thread Peter Alspach
Tena koe

Perhaps the help file will give you some ideas:

odbcConnectAccess, odbcConnectDbase and odbcConnectExcel are convenience 
wrappers to generate connection strings for those file types. The files given 
can be relative to the R working directory or absolute paths (and it seems also 
relative to the user's home directory). The file name can be omitted, which 
will on Rgui bring up a dialog box to search for a file.

Note: they will only work with English-language 32-bit versions of the 
Microsoft drivers, which may or may not be installed in other locales, and are 
not usable from 64-bit R. The 2007 versions work with the drivers which are 
installed with Office 2007/2010 and give access to formats such as '*.xlsx' and 
'*.accdb'. These drivers are also available separately and there is a 64-bit 
version: see the package manual. (You must have the 32-bit drivers when using 
32-bit R and the 64-bit drivers when using 64-bit R: otherwise there will be a 
cryptic message about a driver not being found. And the 64-bit drivers cannot 
be installed alongside 32-bit Microsoft Office, and vice versa.

See the package manual for some of the peculiarities of the Excel drivers. 
readOnly = TRUE may allow very limited changes (to insert and update rows).

HTH 

Peter Alspach

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ahmed Attia
Sent: Wednesday, 17 July 2013 6:25 a.m.
To: r-help@r-project.org
Subject: [R] Importing data by odbcConnectExcel in 64 bit

I have probably an old question.

I have R.3.0.1 installed in 64 bit windows 7. The odbcConnectExcel in RODBC 
library does not work. Tried odbcConnectExcel2007 still does not work.


Any ideas.

Thanks

Melissa-sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),
 :
  first argument is not an open RODBC channel In addition: Warning messages:
1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] 
Data source name not found and no default driver specified
2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed

Melissa-sqlFetch(odbcConnectExcel(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in odbcConnectExcel(F:\\Cotton2012\\validation.xlsx) :
  odbcConnectExcel is only usable with 32-bit Windows

--
Ahmed M. Attia


Research Assistant
Dept. Of SoilCrop Sciences
Texas AM University
ahmed ahmeda...@zu.edu.eg.at...@ag.tamu.edu
Cell phone: 001-979-248-5215

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

The contents of this e-mail are confidential and may be ...{{dropped:14}}

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


[R] Fitting Mixture distributions

2013-07-16 Thread Tjun Kiat Teo
I was trying to use the normixEM in mixtools and I got this error message.

And I got this error message

One of the variances is going to zero;  trying new starting values.
Error in normalmixEM(as.matrix(temp[[gc]][, -(f + 1)])) : Too many tries!

Are there any other packages for fitting mixture distributions  ?


Tjun Kiat Teo

[[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] Fitting Mixture distributions

2013-07-16 Thread Rui Barradas

Hello,

Try the following.


library(sos)
findFn('fitting mixture distribution')


It found several other packages.

Hope this helps,

Rui Barradas

Em 16-07-2013 21:59, Tjun Kiat Teo escreveu:

I was trying to use the normixEM in mixtools and I got this error message.

And I got this error message

One of the variances is going to zero;  trying new starting values.
Error in normalmixEM(as.matrix(temp[[gc]][, -(f + 1)])) : Too many tries!

Are there any other packages for fitting mixture distributions  ?


Tjun Kiat Teo

[[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] Fitting Mixture distributions

2013-07-16 Thread Simon Zehnder
Hi Tjun Kiat Teo,

you try to fit a Normal mixture to some data. The Normal mixture is very 
delicate when it comes to parameter search: If the variance gets closer and 
closer to zero, the log Likelihood becomes larger and larger for any values of 
the remaining parameters. Furthermore for the EM algorithm it is known, that it 
takes sometimes very long until convergence is reached. 

Try the following: 

Use as starting values for the component parameters:

start.par - mean(your.data, na.rm = TRUE) + sd(your.data, na.rm = TRUE) * 
runif(K)

For the weights just use either 1/K or the R cluster function with K clusters

Here K is the number of components. Further enlarge the maximum number of 
iterations. What you could also try is to randomize start parameters and run an 
SEM (Stochastic EM). In my opinion the better method is in this case a Bayesian 
method: MCMC.


Best

Simon


On Jul 16, 2013, at 10:59 PM, Tjun Kiat Teo teotj...@gmail.com wrote:

 I was trying to use the normixEM in mixtools and I got this error message.
 
 And I got this error message
 
 One of the variances is going to zero;  trying new starting values.
 Error in normalmixEM(as.matrix(temp[[gc]][, -(f + 1)])) : Too many tries!
 
 Are there any other packages for fitting mixture distributions  ?
 
 
 Tjun Kiat Teo
 
   [[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 remove attributes from scale() in a matrix?

2013-07-16 Thread C W
Arun, thanks for the quick response.  That helps.

Why does scale() give attributes?  What's the point of that?  I don't
see apply() or any similar functions do it.  Just for my curiosity.

Mike

On Tue, Jul 16, 2013 at 4:07 PM, arun smartpink...@yahoo.com wrote:
 HI,
 Try:
 x1-scale(x,center=TRUE,scale=TRUE)
 str(x1)
 # num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 # - attr(*, scaled:center)= num [1:10] 50.2 50 49.8 49.8 50.3 ...
  #- attr(*, scaled:scale)= num [1:10] 1.109 0.956 0.817 0.746 1.019 ...

  attr(x1,scaled:center)-NULL
  attr(x1,scaled:scale)-NULL
 str(x1)
  #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 A.K.




 - Original Message -
 From: C W tmrs...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, July 16, 2013 3:59 PM
 Subject: [R] How to remove attributes from scale() in a matrix?

 Hi list,

 I am using scale() to standardize a distribution?  But why does it
 give me attributes attached to the data?  I just want a standardized
 matrix, that is all.

 library(mvtnorm)
 x - rmvnorm(15, mean=rep(50, 10))
 x
   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
   [,8] [,9]
 [1,] 51.17519 52.34341 49.63084 47.99234 51.63113 50.91391 49.36819
 49.23901 51.17377
 [2,] 50.57039 49.17210 48.64395 49.03940 49.65761 49.93840 49.94883
 50.69044 49.57632
 [3,] 50.64811 50.21503 50.13786 49.15879 48.51550 50.19444 50.23710
 50.98040 51.37032
 [4,] 49.22797 49.66445 49.93287 48.63681 50.49457 50.33302 52.29552
 49.98424 51.04724
 [5,] 49.72099 50.84510 50.60976 49.60883 53.59509 49.14728 50.23134
 49.09141 49.23780
 [6,] 49.49126 50.90938 49.67140 50.08951 49.79854 49.03711 50.26037
 50.24975 48.26958
 [7,] 51.12384 47.92778 50.60112 49.01554 49.47515 50.12756 51.65216
 49.21998 49.63808
 [8,] 51.45123 50.44037 50.01039 50.27511 49.97658 51.63002 50.37156
 50.02685 48.95423
 [9,] 51.16989 50.16200 51.17724 50.71678 50.79565 50.27128 51.05608
 49.61165 47.81732
 [10,] 49.54263 49.93501 49.71762 49.33378 51.44935 51.53775 50.54346
 49.98333 49.59422
 [11,] 51.16497 49.82914 49.08821 51.02918 49.67663 49.53498 50.26647
 49.48569 50.94504
 [12,] 51.16827 50.50244 49.13003 49.00155 50.26457 48.85465 49.11593
 50.58031 51.14926
 [13,] 48.26216 49.94866 48.62526 49.11995 50.40082 49.25359 48.57677
 50.66760 49.44108
 [14,] 49.82530 49.17352 50.05588 50.51265 51.04926 50.32474 49.78180
 50.48349 49.92431
 [15,] 50.55772 49.84691 47.95021 50.24911 49.85335 50.73062 51.48718
 51.36693 50.18307
  [,10]
 [1,] 50.13859
 [2,] 51.54920
 [3,] 49.23230
 [4,] 50.92683
 [5,] 50.97708
 [6,] 50.78799
 [7,] 50.53913
 [8,] 49.30832
 [9,] 49.43606
 [10,] 49.42060
 [11,] 50.21002
 [12,] 51.94848
 [13,] 49.41352
 [14,] 52.24064
 [15,] 51.19474
 scale(x, center=TRUE, scale=TRUE)
 [,1]   [,2] [,3][,4][,5]
 [,6][,7]
 [1,]  0.8890317  2.3390090 -0.040395734 -1.86089754  1.00159470
 0.92533476 -0.99715965
 [2,]  0.2452502 -0.9109703 -1.190404546 -0.63771097 -0.66104313
 -0.21446975 -0.40514793
 [3,]  0.3279747  0.1578297  0.550427419 -0.49823662 -1.62323564
 0.08468695 -0.11121941
 [4,] -1.1837031 -0.4064112  0.311551281 -1.10802250  0.04407804
 0.24660932  1.98754311
 [5,] -0.6589074  0.8035298  1.100314901  0.02749734  2.65618150
 -1.13883336 -0.11709623
 [6,] -0.9034419  0.8694088  0.006865424  0.58904255 -0.54231158
 -1.26755243 -0.08749646
 [7,]  0.8343705 -2.1861602  1.090250934 -0.66558751 -0.81476108
 0.00655050  1.33157578
 [8,]  1.1828615  0.3887665  0.401888014  0.80585326 -0.39231482
 1.76205433  0.02587038
 [9,]  0.8833860  0.1034854  1.761589113  1.32181395  0.29773018
 0.17447101  0.72381232
 [10,] -0.8487569 -0.1291363  0.060728488 -0.29381647  0.84844800
 1.65423826  0.20113824
 [11,]  0.8781560 -0.2376361 -0.672712386  1.68676651 -0.64501776
 -0.68583461 -0.08127647
 [12,]  0.8816611  0.4523675 -0.623990804 -0.68193230 -0.14968994
 -1.48074503 -1.25436403
 [13,] -2.2117715 -0.1151423 -1.212190165 -0.54361597 -0.03490809
 -1.01461386 -1.80409304
 [14,] -0.5478718 -0.9095198  0.454889973  1.08335795  0.51138447
 0.23693367 -0.57544865
 [15,]  0.2317608 -0.2194204 -1.998811911  0.77548830 -0.49613484
 0.71117025  1.16336204
 [,8][,9]   [,10]
 [1,] -1.2666791  1.17934107 -0.35061189
 [2,]  0.8423439 -0.28600703  1.06389274
 [3,]  1.2636749  1.35963155 -1.25940610
 [4,] -0.1838111  1.06327078  0.43980595
 [5,] -1.4811512 -0.59653247  0.49019839
 [6,]  0.2019965 -1.48467432  0.30058779
 [7,] -1.2943281 -0.22935616  0.05103467
 [8,] -0.1218950 -0.85664924 -1.18316969
 [9,] -0.7252082 -1.89953387 -1.05507780
 [10,] -0.1851315 -0.26958168 -1.07058564
 [11,] -0.9082374  0.96952049 -0.27897948
 [12,]  0.6823136  1.15685832  1.46428187
 [13,]  0.8091562 -0.41005981 -1.07768018
 [14,]  0.5416286  0.03320871  1.75724879
 [15,]  1.8253278  0.27056365  0.70846058
 attr(,scaled:center)
 [1] 50.33999 50.06102 49.66551 49.58529 50.44225 50.12196 50.34618
 50.11074 49.88811
 [10] 

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread arun
Hi Mike,
If you check ?scale

For ‘scale.default’, the centered, scaled matrix.  The numeric
 centering and scalings used (if any) are returned as attributes
 ‘scaled:center’ and ‘scaled:scale’

By checking the source code:
methods(scale)

getAnywhere('scale.default')

function (x, center = TRUE, scale = TRUE) 
{
    x - as.matrix(x)
    nc - ncol(x)
    if (is.logical(center)) {
    if (center) {
    center - colMeans(x, na.rm = TRUE)
    x - sweep(x, 2L, center, check.margin = FALSE)
    }
    }
    else if (is.numeric(center)  (length(center) == nc)) 
    x - sweep(x, 2L, center, check.margin = FALSE)
    else stop(length of 'center' must equal the number of columns of 'x')
    if (is.logical(scale)) {
    if (scale) {
    f - function(v) {
    v - v[!is.na(v)]
    sqrt(sum(v^2)/max(1, length(v) - 1L))
    }
    scale - apply(x, 2L, f)
    x - sweep(x, 2L, scale, /, check.margin = FALSE)
    }
    }
    else if (is.numeric(scale)  length(scale) == nc) 
    x - sweep(x, 2L, scale, /, check.margin = FALSE)
    else stop(length of 'scale' must equal the number of columns of 'x')
    if (is.numeric(center)) 
    attr(x, scaled:center) - center
    if (is.numeric(scale)) 
    attr(x, scaled:scale) - scale
    x
}

#You can comment out the last few lines:

scale1- function (x, center = TRUE, scale = TRUE) 
{
    x - as.matrix(x)
    nc - ncol(x)
    if (is.logical(center)) {
    if (center) {
    center - colMeans(x, na.rm = TRUE)
    x - sweep(x, 2L, center, check.margin = FALSE)
    }
    }
    else if (is.numeric(center)  (length(center) == nc)) 
    x - sweep(x, 2L, center, check.margin = FALSE)
    else stop(length of 'center' must equal the number of columns of 'x')
    if (is.logical(scale)) {
    if (scale) {
    f - function(v) {
    v - v[!is.na(v)]
    sqrt(sum(v^2)/max(1, length(v) - 1L))
    }
    scale - apply(x, 2L, f)
    x - sweep(x, 2L, scale, /, check.margin = FALSE)
    }
    }
    else if (is.numeric(scale)  length(scale) == nc) 
    x - sweep(x, 2L, scale, /, check.margin = FALSE)
    else stop(length of 'scale' must equal the number of columns of 'x')
    #if (is.numeric(center)) 
    #    attr(x, scaled:center) - center
    #if (is.numeric(scale)) 
    #    attr(x, scaled:scale) - scale
    x
}
 x2-scale1(x,center=TRUE,scale=TRUE)
 str(x2)
# num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...

identical(x1,x2)
#[1] TRUE
A.K.



- Original Message -
From: C W tmrs...@gmail.com
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Tuesday, July 16, 2013 6:58 PM
Subject: Re: [R] How to remove attributes from scale() in a matrix?

Arun, thanks for the quick response.  That helps.

Why does scale() give attributes?  What's the point of that?  I don't
see apply() or any similar functions do it.  Just for my curiosity.

Mike

On Tue, Jul 16, 2013 at 4:07 PM, arun smartpink...@yahoo.com wrote:
 HI,
 Try:
 x1-scale(x,center=TRUE,scale=TRUE)
 str(x1)
 # num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 # - attr(*, scaled:center)= num [1:10] 50.2 50 49.8 49.8 50.3 ...
  #- attr(*, scaled:scale)= num [1:10] 1.109 0.956 0.817 0.746 1.019 ...

  attr(x1,scaled:center)-NULL
  attr(x1,scaled:scale)-NULL
 str(x1)
  #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 A.K.




 - Original Message -
 From: C W tmrs...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, July 16, 2013 3:59 PM
 Subject: [R] How to remove attributes from scale() in a matrix?

 Hi list,

 I am using scale() to standardize a distribution?  But why does it
 give me attributes attached to the data?  I just want a standardized
 matrix, that is all.

 library(mvtnorm)
 x - rmvnorm(15, mean=rep(50, 10))
 x
           [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
   [,8]     [,9]
 [1,] 51.17519 52.34341 49.63084 47.99234 51.63113 50.91391 49.36819
 49.23901 51.17377
 [2,] 50.57039 49.17210 48.64395 49.03940 49.65761 49.93840 49.94883
 50.69044 49.57632
 [3,] 50.64811 50.21503 50.13786 49.15879 48.51550 50.19444 50.23710
 50.98040 51.37032
 [4,] 49.22797 49.66445 49.93287 48.63681 50.49457 50.33302 52.29552
 49.98424 51.04724
 [5,] 49.72099 50.84510 50.60976 49.60883 53.59509 49.14728 50.23134
 49.09141 49.23780
 [6,] 49.49126 50.90938 49.67140 50.08951 49.79854 49.03711 50.26037
 50.24975 48.26958
 [7,] 51.12384 47.92778 50.60112 49.01554 49.47515 50.12756 51.65216
 49.21998 49.63808
 [8,] 51.45123 50.44037 50.01039 50.27511 49.97658 51.63002 50.37156
 50.02685 48.95423
 [9,] 51.16989 50.16200 51.17724 50.71678 50.79565 50.27128 51.05608
 49.61165 47.81732
 [10,] 49.54263 49.93501 49.71762 49.33378 51.44935 51.53775 50.54346
 49.98333 49.59422
 [11,] 51.16497 49.82914 49.08821 51.02918 49.67663 49.53498 50.26647
 49.48569 50.94504
 [12,] 

Re: [R] How to remove attributes from scale() in a matrix?

2013-07-16 Thread C W
Thanks, very clear!

On Tue, Jul 16, 2013 at 7:08 PM, arun smartpink...@yahoo.com wrote:
 Hi Mike,
 If you check ?scale

 For ‘scale.default’, the centered, scaled matrix.  The numeric
  centering and scalings used (if any) are returned as attributes
  ‘scaled:center’ and ‘scaled:scale’

 By checking the source code:
 methods(scale)

 getAnywhere('scale.default')

 function (x, center = TRUE, scale = TRUE)
 {
 x - as.matrix(x)
 nc - ncol(x)
 if (is.logical(center)) {
 if (center) {
 center - colMeans(x, na.rm = TRUE)
 x - sweep(x, 2L, center, check.margin = FALSE)
 }
 }
 else if (is.numeric(center)  (length(center) == nc))
 x - sweep(x, 2L, center, check.margin = FALSE)
 else stop(length of 'center' must equal the number of columns of 'x')
 if (is.logical(scale)) {
 if (scale) {
 f - function(v) {
 v - v[!is.na(v)]
 sqrt(sum(v^2)/max(1, length(v) - 1L))
 }
 scale - apply(x, 2L, f)
 x - sweep(x, 2L, scale, /, check.margin = FALSE)
 }
 }
 else if (is.numeric(scale)  length(scale) == nc)
 x - sweep(x, 2L, scale, /, check.margin = FALSE)
 else stop(length of 'scale' must equal the number of columns of 'x')
 if (is.numeric(center))
 attr(x, scaled:center) - center
 if (is.numeric(scale))
 attr(x, scaled:scale) - scale
 x
 }

 #You can comment out the last few lines:

 scale1- function (x, center = TRUE, scale = TRUE)
 {
 x - as.matrix(x)
 nc - ncol(x)
 if (is.logical(center)) {
 if (center) {
 center - colMeans(x, na.rm = TRUE)
 x - sweep(x, 2L, center, check.margin = FALSE)
 }
 }
 else if (is.numeric(center)  (length(center) == nc))
 x - sweep(x, 2L, center, check.margin = FALSE)
 else stop(length of 'center' must equal the number of columns of 'x')
 if (is.logical(scale)) {
 if (scale) {
 f - function(v) {
 v - v[!is.na(v)]
 sqrt(sum(v^2)/max(1, length(v) - 1L))
 }
 scale - apply(x, 2L, f)
 x - sweep(x, 2L, scale, /, check.margin = FALSE)
 }
 }
 else if (is.numeric(scale)  length(scale) == nc)
 x - sweep(x, 2L, scale, /, check.margin = FALSE)
 else stop(length of 'scale' must equal the number of columns of 'x')
 #if (is.numeric(center))
 #attr(x, scaled:center) - center
 #if (is.numeric(scale))
 #attr(x, scaled:scale) - scale
 x
 }
  x2-scale1(x,center=TRUE,scale=TRUE)
  str(x2)
 # num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...

 identical(x1,x2)
 #[1] TRUE
 A.K.



 - Original Message -
 From: C W tmrs...@gmail.com
 To: arun smartpink...@yahoo.com
 Cc: R help r-help@r-project.org
 Sent: Tuesday, July 16, 2013 6:58 PM
 Subject: Re: [R] How to remove attributes from scale() in a matrix?

 Arun, thanks for the quick response.  That helps.

 Why does scale() give attributes?  What's the point of that?  I don't
 see apply() or any similar functions do it.  Just for my curiosity.

 Mike

 On Tue, Jul 16, 2013 at 4:07 PM, arun smartpink...@yahoo.com wrote:
 HI,
 Try:
 x1-scale(x,center=TRUE,scale=TRUE)
 str(x1)
 # num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 # - attr(*, scaled:center)= num [1:10] 50.2 50 49.8 49.8 50.3 ...
  #- attr(*, scaled:scale)= num [1:10] 1.109 0.956 0.817 0.746 1.019 ...

  attr(x1,scaled:center)-NULL
  attr(x1,scaled:scale)-NULL
 str(x1)
  #num [1:15, 1:10] -0.2371 -0.5606 -0.8242 1.5985 -0.0164 ...
 A.K.




 - Original Message -
 From: C W tmrs...@gmail.com
 To: r-help r-help@r-project.org
 Cc:
 Sent: Tuesday, July 16, 2013 3:59 PM
 Subject: [R] How to remove attributes from scale() in a matrix?

 Hi list,

 I am using scale() to standardize a distribution?  But why does it
 give me attributes attached to the data?  I just want a standardized
 matrix, that is all.

 library(mvtnorm)
 x - rmvnorm(15, mean=rep(50, 10))
 x
   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
   [,8] [,9]
 [1,] 51.17519 52.34341 49.63084 47.99234 51.63113 50.91391 49.36819
 49.23901 51.17377
 [2,] 50.57039 49.17210 48.64395 49.03940 49.65761 49.93840 49.94883
 50.69044 49.57632
 [3,] 50.64811 50.21503 50.13786 49.15879 48.51550 50.19444 50.23710
 50.98040 51.37032
 [4,] 49.22797 49.66445 49.93287 48.63681 50.49457 50.33302 52.29552
 49.98424 51.04724
 [5,] 49.72099 50.84510 50.60976 49.60883 53.59509 49.14728 50.23134
 49.09141 49.23780
 [6,] 49.49126 50.90938 49.67140 50.08951 49.79854 49.03711 50.26037
 50.24975 48.26958
 [7,] 51.12384 47.92778 50.60112 49.01554 49.47515 50.12756 51.65216
 49.21998 49.63808
 [8,] 51.45123 50.44037 50.01039 50.27511 49.97658 51.63002 50.37156
 50.02685 48.95423
 [9,] 51.16989 50.16200 51.17724 50.71678 50.79565 50.27128 51.05608
 49.61165 47.81732
 [10,] 49.54263 

Re: [R] Announcing TIBCO Enterprise Runtime for R

2013-07-16 Thread Louis Bajuk-Yorgan
Hi Michael

Thanks for your questions. Posting them here is fine, or you can also post them 
on the TERR Community site: 
https://www.tibcommunity.com/community/products/analytics/terr.

Initial answers below--feel free to ask follow ups:

 1. Do you have concrete benchmarks of what sorts of operations are faster? In 
 particular, are you, like Revolution, licensing MKL?

Yes we have benchmarks, and yes we license MKL. It's challenging to come up 
with comprehensive, meaningful benchmarks, and so we are looking to the 
community for benchmarks they'd like to see. Feel free to post anything you are 
interested in on the community site, or email me directly. 
- Generally we will be much faster for pure R language operations (e.g., for 
loops), since we have written a new, R-compatible interpreter from the ground 
up. The performance ratio will tend to improve with larger data sets, since we 
have implemented highly efficient memory management.
- Since we license MKL (and distribute it in the free Developer's Edition), we 
will have all the related matrix-operation speed advantages.
- For more detailed info and some benchmarks, see the presentation that Michael 
Sannella (the chief architect for TERR) gave at useR 2013. It's now available 
on slideshare: 
http://www.slideshare.net/loubajukyorgan/sannella-use-r2013terrmemorymanagement 

 2. Your white-paper boasts of superior memory management; can you give more 
 details? Are we now reference counting, or abandoning copy-on-write to play 
 better with fork(), or running concurrently? In turn, does this mean the 
 C-API is not kept as is and any package with compiled code isn't usable?

See Michael's presentation Memory Management in TERR, referenced above for 
full details. In particular, yes, full reference counting has been implemented. 

Our goal is to have packages with compiled code work as-is, without 
modification. To do this, since the internals of our engine are different, we 
need to emulate the APIs for these packages to work. We have done this for many 
APIs and packages so far. See the Community site for a list of packages known 
to run successfully. 

 3. You speak of being more robust: is this at a language level 
 (i.e.,something simpler to use than try()/tryCatch()) or an implementation 
 level? If the latter, what non-robustnesses are being addressed?

Primarily, the greater robustness comes from the improvements to memory 
management. Beyond that, we do extensive automated testing (using the deep 
array of tests we have built up over the years for S+ development) to ensure 
reliability, and we have done some work at the language level (around 
improvements to signal handling, throwing and catching errors, etc.). If you'd 
like more info the last point, email me directly and I can get you in touch 
with Michael.

 4. What are y'all's plans for supporting TERR as 'regular R' evolves? Will it 
 track or will things diverge over time?

Our intent is to keep up with current R as closely as possible. In talking to 
our customers, we have heard loud and clear that they love the idea of an 
enterprise R engine, but they don't want to be locked into a proprietary flavor 
of R. 

 5. Known (and not intended to change) differences?

Very minor items. Full list on the Community Site. 

 6. Is the whole R-level API exposed or only a selected subset? I'm thinking 
 in particular of (1) things like .colMeans() which seem rather tied to the 
 implementation; (2) graphics devices; (3) the promise mechanism and 
 copy-on-write semantics?

As mentioned in #2 above, we are implementing the R APIs over time. For a full 
list of what we have and haven't yet implemented, check out the community site, 
and feel free to leave comments about what you'd like us to prioritize next. 

Regards, and thanks again for your interest.
Lou


-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Thursday, July 11, 2013 1:59 PM
To: Louis Bajuk-Yorgan
Cc: r-help
Subject: Re: [R] Announcing TIBCO Enterprise Runtime for R

Hi Louis,

I apologize in advance if this isn't the right forum; feel free to direct me 
elsewhere.

Can you say a bit more about what exactly constitute the advantages of TERR 
over R as most readers of this list know it? Some random points of interest to 
me:

1. Do you have concrete benchmarks of what sorts of operations are faster? In 
particular, are you, like Revolution, licensing MKL?
2. Your white-paper boasts of superior memory management; can you give more 
details? Are we now reference counting, or abandoning copy-on-write to play 
better with fork(), or running concurrently? In turn, does this mean the C-API 
is not kept as is and any package with compiled code isn't usable?
3. You speak of being more robust: is this at a language level (i.e.,something 
simpler to use than try()/tryCatch()) or an implementation level? If the 
latter, what non-robustnesses are being addressed?
4. What are y'all's plans for 

[R] interfacing with website

2013-07-16 Thread Daisy Englert Duursma
Hello,

I have a question about interfacing with the Atlas of Living Australia
website: http://biocache.ala.org.au/#tab_simpleSearch

The following code works and I am able to download species observations.
The problem I am having is that I would like additional fields of data. If
I manually download records for a species from ALA then you can choose to
download all records (detailed). I cannot figure out how to automate this.
I specifically need the field “Locality”.   If done correctly this
information would be present in the rawResponse data that is returned from
ALA.

Any help with this problem would be greatly appreciated.

Thanks,
Daisy


species-Vinca minor
nRecords=FALSE
  library(RCurl)
  library(rjson)
   sp - strsplit(as.character(species), )[[1]]
h - basicHeaderGatherer()

   BaseALA_Data_URL - biocache.ala.org.au
  Referer - 
  DataStr - paste0(/ws/webportal/occurrences?q=,sp[1],+,sp[2])
  message(Querying number of records...)
  rawResponse - getURL(paste0(BaseALA_Data_URL,DataStr), headerfunction =
h$update)
  ResponseCode - as.integer(h$value()[status])
  if(ResponseCode == 200) {
jsres - fromJSON(rawResponse)
  } else {
message(No proper response.)
return(invisible())
  }
  nrecords - jsres$totalRecords
  if(nRecords)return(nrecords)
  message(Downloading , nrecords,  records.)
  # Download all
  DataStr - paste0(DataStr, pageSize=, nrecords)
  rawResponse - getURL(paste0(BaseALA_Data_URL,DataStr), headerfunction =
h$update)
  if(ResponseCode == 200) {
jsres - fromJSON(rawResponse)
  } else {
message(No proper response.)
return(invisible())
  }
  totalRecords - jsres$totalRecords
  res - lapply(jsres$occurrences,
function(x)c(nameSci=x$raw_scientificName,
latitude=x$decimalLatitude,

 longitude=x$decimalLongitude))
  res - as.data.frame(do.call(rbind, res))
  res$longitude - as.numeric(as.character(res$longitude))
  res$latitude - as.numeric(as.character(res$latitude))

[[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] writing multiple lines to a file

2013-07-16 Thread arun
HI,
May be this helps:
printer1- file(out1.txt,w)
write(sprintf(This is line %d.\n,1),printer1,append=TRUE) 
write(This is line 2,printer1,append=TRUE)
close(printer1)

#or


 printer1- file(out1.txt,w)
writeLines(This is line,con=printer1,sep=\n)
writeLines(This is line 2,con=printer1)
 close(printer1)
A.K.


Hello, I am trying to wrote multiple lines to a file, but I only seem to be 
able to write the last line. 

printer = file(out.txt) 
write(sprintf(This is line %d.\n,1),printer,append=T) 
write(This is line 2.,printer,append=T) 
close(printer) 

How can I fix this? I would like to be able to do this in a for-loop with 
hundreds of elements.

__
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] (no subject)

2013-07-16 Thread labib obaid
hi

I need to use boxplot for two subsets at the same page

thank you in advance



Sent from Windows Mail
[[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: missing value where TRUE/FALSE needed

2013-07-16 Thread Lee Jejen
Hello, I have a problem... I tried using a function and I get the error: 
ERROR: missing value where TRUE/FALSE needed
Here is my code:
a-mctp(Ecoli~Fecha, data=Datos, type = Tukey, alternative = two.sided, 
asy.method = mult.t, plot.simci = TRUE)summary(a)
Ecoli, Fecha and Datos are well defined. I don't know what is the problem...
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] Masking oceans using polypath

2013-07-16 Thread Paul Murrell

Hi

There are a couple of problems:

1.
Your 'outline' is much bigger than it needs to be.  For example, the 
following produces just Australia ...


outline - map(worldHires, regions=Australia, exact=TRUE,
   plot=FALSE) # returns a list of x/y coords

2.
The outline you get still has NA values in it (the coastline of 
Australia in this database is a series of distinct lines;  I don't know 
why that is).  Fortunately, you can stitch Australia back together again 
like this ...


subset - !is.na(outline$x)
polypath(c(outline$x[subset], NA, c(xbox, rev(xbox))),
 c(outline$y[subset], NA, rep(ybox, each=2)),
 col=light blue, rule=evenodd)

With those two changes, I get a much better result.  You may want to 
fiddle a bit more to add Tasmania and bits of PNG and Indonesia back in 
the picture OR you could replace these problems with a different 
approach and use a more sophisticated map outline via a shapefile (see 
the 'sp' package and the 'maptools' package and possibly the R-sig-geo 
mailing list).


Hope that helps.

Paul

On 07/16/13 23:17, Louise Wilson wrote:

library(mapdata)

image(x=110:155, y =-40:-10, z = outer(1:45, 1:30, +),

   xlab = lon, ylab = lat)

outline - map(worldHires, plot=FALSE) # returns a list of x/y coords

xrange - range(outline$x, na.rm=TRUE) # get bounding box

yrange - range(outline$y, na.rm=TRUE)

xbox - xrange + c(-2, 2)

ybox - yrange + c(-2, 2)

# create the grid path in the current device

polypath(c(outline$x, NA, c(xbox, rev(xbox))),

  c(outline$y, NA, rep(ybox, each=2)),

  col=light blue, rule=evenodd)


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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