Andrew Ziem | 1 Mar 01:36 2009
Picon

How to create temporary table in MySQL

Creating a temp table isn't completely intuitive with MySQL 5 and R
2.8..1, but it can be done.

> library(RMySQL)
Loading required package: DBI
> con <- dbConnect(dbDriver("MySQL"), dbname = "foo", user="me",password="secret")
> x<- data.frame(1:10)
> colnames(x) <-c("x")
> dbWriteTable(con, "#x", x, verbose=TRUE,row.names=FALSE, overwrite=T) # fails
Error in mysqlExecStatement(conn, statement, ...) :
  RS-DBI driver: (could not run statement: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near '(
	x bigint
)' at line 2)
[1] FALSE
Warning message:
In mysqlWriteTable(conn, name, value, ...) :
  could not create table: aborting mysqlWriteTable
> dbGetQuery(con, "create temporary table x ( x int);") # workaround
NULL
> dbWriteTable(con, "x", x, verbose=TRUE,row.names=FALSE, overwrite=T)
[1] TRUE
> dbGetQuery(con, "select * from x;")
    x
1   1
2   2
3   3
4   4
5   5
(Continue reading)

Andrew Ziem | 1 Mar 02:12 2009
Picon

Temporary tables with Microsoft SQL?

I can create a temp table with MySQL and R DBI[1], but I don't see how
to do the same with Microsoft SQL 2005 and RODBC.  R 2.8.1 creates the
table, but then it can never see it.  I'm looking to avoid replacing
the convenience functions like sqlSave().

[1] https://stat.ethz.ch/pipermail/r-help/2009-March/190033.html

> library(RODBC)
> channel <- odbcDriverConnect("driver=SQL Server;server=foo;Initial Catalog=bar;Integrated Security=SSPI;")
> x<-data.frame(1:10)
> colnames(x) <-c("x")

> sqlSave(channel, x, "#x", verbose=TRUE)
Query: CREATE TABLE "#x"  ("rownames" varchar(255), "x" int)
Error in sqlColumns(channel, tablename) :
  ‘#x’: table not found on channel

> sqlSave(channel, "#x", verbose=TRUE) #repeat
Query: CREATE TABLE "#x"  ("rownames" varchar(255), "x" int)
Error in sqlSave(db_i3_eic, x, "#x", verbose = TRUE) :
  [RODBC] ERROR: Could not SQLExecDirect
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is
already an object named '#x' in the database.

> sqlSave(channel, "x", verbose=TRUE) # try without hash
Query: CREATE TABLE "x"  ("rownames" varchar(255), "x" int)
Error in sqlSave(db_i3_eic, x, "x", verbose = TRUE) :
  [RODBC] ERROR: Could not SQLExecDirect
42000 262 [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE TABLE
permission denied in database 'bar'.
(Continue reading)

rkevinburton | 1 Mar 03:26 2009
Picon

Variable scope.

I have a question on scope/reference/value type of variables with 'R'.

The issue cam up first when I look at the arima code.

I see code like:

    myupARIMA <- function(mod, phi, theta) {
. . . .
                           mod
    }

Then 

armafn <- function(p, trans) {
. . . .
        Z <- upARIMA(mod, trarma[[1]], trarma[[2]])
. . . .
        res <- .Call(R_ARIMA_Like, x, Z$phi, Z$theta, Z$Delta, 
            Z$a, Z$P, Z$Pn, as.integer(0), FALSE)
. . . . 
}

The question is that ARIMA_Like will make changes to the arrays Z$P etc. Since upARIMA essentially returns
'mod' are changes to the arrays passed as Z$... to ARUINA_Like refkected in the original 'mod'? Or another
way of phrasing the question is 'Z' a reference variable? Are the members such as Z$a also passed as
reference hence changes to Z$a should also be seen in mod$a? In the arima code the references to x and mod
seem to be essentially global variables as armafn is 'nested' in arima. Will changes to x also be reflected
in the original x? (Like x <- x - (xreg %*% par[narma + (1:ncxreg)))

Thank you.
(Continue reading)

David Winsemius | 1 Mar 05:09 2009
Picon
Picon

Re: creating log-log survival plots that are not inverted

I think what you want may be produced by this code for InvNormal(S) vs  
log(time):

survplot(fit, fun=qnorm, logT=T, conf = "none")

That is not what you describe, however.

I am worried about the plot on the page you cite, because it is not  
similar to other log(-log(S)) (complementary log-log)  plots I am  
familiar with. I checked the errata listing and do not see a  
correction, but I am still concerned it might not be not a log(- 
log(S)) vs time plot.

Terry Therneau has always been very helpful to readers of this group  
and I suspect he can clarify any confusion I may be laboring under.

--

-- 
David Winsemius
Heritage Laboratories

On Feb 28, 2009, at 5:48 PM, Bob Green wrote:

> I am hoping for some advice regarding how to obtain a log-log  
> survival plot that is not in the inverse. On page 128 of Modelling  
> survival data by Therneau & Grambsch there is the an example of the  
> type of desired plot, with a log of the survival curve  by years.   
> Marc Schwartz has provided me with some reproducible code.
>
> The code below produces inverted plots.
>
(Continue reading)

Johannes Huesing | 1 Mar 07:04 2009

Re: Adjusting confidence intervals for paired t-tests of multiple endpoints

Erich Studerus, Psychiatrische Uni-Klinik <erich.studerus <at> bli.uzh.ch> [Sat, Feb 28, 2009 at
09:23:05PM CET]:
> Thanks, but as far as I know the multcomp package and the tukeyHSD 
> function can only handle one dependent variable, whereas I have 60 
> dependent variables.

Couldn't you re-phrase your model by including timepoint as a continuous 
regressor and scale as a factor?

--

-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johannes <at> huesing.name  from such a trifling investment of fact.                
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")

______________________________________________
R-help <at> 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.
Prof Brian Ripley | 1 Mar 08:22 2009
Picon
Picon

Re: Temporary tables with Microsoft SQL?

This is an issue for the R-sig-db list (as was your other posting).

RODBC is written to use standard SQL, and Microsft often does not use 
standard SQL, as in table names like #x.

The most productive thing to do would be to modify RODBC to handle the 
Microsoft peculiarities you want and feed the changes back to the 
maintainer (mw, at present).  That is how various of those 
peculiarities have been added in the past.

On Sat, 28 Feb 2009, Andrew Ziem wrote:

> I can create a temp table with MySQL and R DBI[1], but I don't see how
> to do the same with Microsoft SQL 2005 and RODBC.  R 2.8.1 creates the
> table, but then it can never see it.  I'm looking to avoid replacing
> the convenience functions like sqlSave().
>
> [1] https://stat.ethz.ch/pipermail/r-help/2009-March/190033.html
>
>> library(RODBC)
>> channel <- odbcDriverConnect("driver=SQL Server;server=foo;Initial Catalog=bar;Integrated Security=SSPI;")
>> x<-data.frame(1:10)
>> colnames(x) <-c("x")
>
>> sqlSave(channel, x, "#x", verbose=TRUE)
> Query: CREATE TABLE "#x"  ("rownames" varchar(255), "x" int)
> Error in sqlColumns(channel, tablename) :
>  ‘#x’: table not found on channel
>
>> sqlSave(channel, "#x", verbose=TRUE) #repeat
(Continue reading)

Dimitris Rizopoulos | 1 Mar 09:44 2009
Picon

Re: rounding problem

it the on-line help file of ?round, you can also find the functions:

ceiling()
floor()
trunc()

I hope it helps.

Best,
Dimitris

tedzzx wrote:
> Hi all,
> 
> According to the help page on round(), round(1.5) could be either 1 or 2.
> But I want to the answere to be 2 for sure just what we usually do. How can
> I do that? Thanks advance.
> 
> Cheers
> 
> Ted

--

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
(Continue reading)

René Mayer | 1 Mar 10:13 2009
Picon

SPSS repeated interaction contrast in R

dear all,

i'm trying to reproduce an spss-anova in R.
It is an 2x3x3 repeated measures desingn with repeated contrasts.
In R i've coded a contrast matrix for all factors and made a
split in the aov summary - but I can't get the repeated interaction contrasts.

The output from SPSS looks like this:

TaskSw * CongNow * CongBefore: SS df Mean Square    F	Sig.
1 vs. 2	 1 vs. 2   1 vs. 2    13944,50	1 13944,50  0.37 0.56
		   2 vs. 3    4278,12	1 4278,12   0.31 0.59
	 2 vs. 3   1 vs. 2    7140,12	1 7140,12   0.17 0.68
		   2 vs. 3    53301,131	1 53301,13  1.38 0.27

The output from R looks like this:

Error: Subj:TaskSw:CongNow:CongBefore

                                         Df Sum Sq Mean Sq F value Pr(>F)
                                         4  18823    4706  1.8804 0.1417
  rep vs. se.con vs. inc.con vs. inc     1
             inc vs. neu.                1
             con vs. inc.inc vs. neu     1
             inc vs. neu.                1
Residuals                               28  70069    2502

I've pasted the R and SPSS code I uesd. thanks in advance. Rene

R code:
(Continue reading)

Daniel Nordlund | 1 Mar 10:15 2009
Picon
Picon

Re: rounding problem

> -----Original Message-----
> From: r-help-bounces <at> r-project.org 
> [mailto:r-help-bounces <at> r-project.org] On Behalf Of tedzzx
> Sent: Saturday, February 28, 2009 4:58 AM
> To: r-help <at> r-project.org
> Subject: [R] rounding problem
> 
> 
> Hi all,
> 
> According to the help page on round(), round(1.5) could be 
> either 1 or 2.
> But I want to the answere to be 2 for sure just what we 
> usually do. How can
> I do that? Thanks advance.
> 
> Cheers
> 
> Ted
> -- 

Ted,

Actually, the documentation (at least for R-2.8.1) doesn't say that.  The
number 1.5 can be represented exactly on most systems that I know, and
therefore it will round to the even digit, i.e. round(1.5) = 2.0 .  The
documentation says that 0.15 cannot be represented exactly, and therefore
whether it rounds to 0.1 or 0.2 depends on the OS and the machine
architecture.  So on my WinXP Pentium IV system, 1.5 rounds to 2.0 and it
also happens that round(0.15, 1) equals 0.2  .  You say you want 1.5 to
(Continue reading)

Žroutík | 1 Mar 10:51 2009
Picon

smoothing a matrix (interpolate in plane)

Hi R-users,

I'd like to smooth a matrix to dismiss spikes and to interpolate in plane

example of a matrix:
Map[1:3,1:3]

      [,1] [,2] [,3]...
[1,] 34.4 34.2 35.1
[2,] 33.4 34.2 35.4
[3,] 34.1 33.2 32.1
....

dim(Map)[1] =/= dim(Map)[2]

What functions can I use?

Thanks a lot for any response, M

	[[alternative HTML version deleted]]

______________________________________________
R-help <at> 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.


Gmane