[R] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread Michael Haenlein
Dear all,

this is probably more a statistics question than an R question but probably
there is somebody who can help me nevertheless.

I'm running a regression with four predictors (a, b, c, d) and all their
interaction effects using lm. Based on theory I assume that a influences y
positively. In my output (see below) I see, however, a negative regression
coefficient for a. But several of the interaction effects of a with b, c and
d have positive signs. I don't really understand this. Do I have to add up
the coefficient for the main effect and the ones of all interaction effects
to get a total effect of a on y? Or am I doing something wrong here?

Thanks very much for your answer in advance,

Regards,

Michael


Michael Haenlein
Associate Professor of Marketing
ESCP Europe
Paris, France



Call:
lm(formula = y ~ a * b * c * d)

Residuals:
Min  1Q  Median  3Q Max
-44.919  -5.184   0.294   5.232 115.984

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  27.3067 0.8181  33.379  < 2e-16 ***
a   -11.0524 2.0602  -5.365 8.25e-08 ***
b-2.5950 0.4287  -6.053 1.47e-09 ***
c   -22.0025 2.8833  -7.631 2.50e-14 ***
d20.5037 0.3189  64.292  < 2e-16 ***
a:b  15.1411 1.1862  12.764  < 2e-16 ***
a:c  26.8415 7.2484   3.703 0.000214 ***
b:c   8.3127 1.5080   5.512 3.61e-08 ***
a:d   6.6221 0.8061   8.215 2.33e-16 ***
b:d  -2.0449 0.1629 -12.550  < 2e-16 ***
c:d  10.0454 1.1506   8.731  < 2e-16 ***
a:b:c 1.4137 4.1579   0.340 0.733862
a:b:d-6.1547 0.4572 -13.463  < 2e-16 ***
a:c:d   -20.6848 2.8832  -7.174 7.69e-13 ***
b:c:d-3.4864 0.6041  -5.772 8.05e-09 ***
a:b:c:d   5.6184 1.6539   3.397 0.000683 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.913 on 12272 degrees of freedom
Multiple R-squared: 0.8845, Adjusted R-squared: 0.8844
F-statistic:  6267 on 15 and 12272 DF,  p-value: < 2.2e-16

[[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] Recompile a package

2011-05-11 Thread Yuliya Matveyeva
Hello, dear R community.
 The thing is that I am not in the least a developer, neither do I want to
create a package of my own.
But recently I have found a package LogicForest, which is in the base
written in Fortran I think. And well,
in its manual it is written that there are several parameters there that had
had to be "hard coded", but which
in essence actually have no restrictions. So if one needs to change them, he
sure can, only that he has to change
a file with an .f or .ff extension (I believe that it stands for Fortran
code, but I am not sure) and then recompile it.

http://finzi.psych.upenn.edu/R/library/LogicReg/html/logreg.html

I have found several posts in the mailing-archive, but they seem to deal
with Windows.
And I have a Gentoo-based distro.

I have also found a manual "Installation and Administration".
But it all seems to be destined for developers... and usually talks about
creating your own package,
or about installing a package anew.
What I need is just recompile a package, in which I have manually changed
several files.
I really am kinda silly in these kinds of things... So any hints and help
would be greatly appreciated.

I have tried R CMD COMPILE condlogic.ff
But it tells me:
ERROR: don't know how to compile 'condlogic.ff'
I am probably not getting something...

And there is no `src` subdirectory for this package, nor
any .cpp files in the package directory either... Can somebody please
explain to me on which kinds of files can I and should I use R CMD COMPILE ?

/*The Fortran compiler is installed*/


My sessionInfo() :

R version 2.10.1 (2009-12-14)
x86_64-pc-linux-gnu

locale:
[1] C

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



Thank you in advance.
Yulia.

[[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] Dotplot (package Hmisc) with groups: colours and symbols

2011-05-11 Thread E Hofstadler
Hello all,

This question concerns the function Dotplot from the Hmisc package.

My aim is to compare values between groups in each panel of the
Dotplot, with the values of different groups clearly distinguishable
by different symbols. All lines and symbols should be coloured in
black.

Before adding the panel function to the Dotplot, the groups behaved as
desired and were marked by different symbols, but the error bands were
blue instead of black. After adding the panel function and changing
the trellis colour settings, the error bars are now black, but now the
groups are suddenly marked by the same rather than different symbols.
I've tried several ways to change the group symbols but to no avail.

## set CI lines to black
t1 = trellis.par.get("plot.line")
t1$col <- "black"
trellis.par.set("plot.line",t1)

## load example data
require(lattice)
data(barley)

## example plot (problem: groups marked by the same symbol)

require(Hmisc)
Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year,
data=barley, pch=c(1,2), col="black",
panel=function(x,y){
panel.Dotplot(x,y,col="black")})
Key()




What am I doing wrong?

Many thanks in advance.
Esther

__
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] Loop over a split string

2011-05-11 Thread Joel
Hi

I got a string that looks like this:

string<-"a b c d e f"

And what I wanna do is loop trough all the letters.
like

for(i in string){
 print(i)
}

would render the result:
a
b
c
d
e
f

Ive tried using strsplit but without result, dose anyone know how I could
make this happen?

//Joel

--
View this message in context: 
http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514204.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] Recompile a package

2011-05-11 Thread Uwe Ligges

1. Upgrade to a recent version of R.
2. download the whole source package and untar it
3. change the files
4. R CMD build it
5. R CMD INSTALL it

For more details see the manual R Installation and Administration as 
well as Writing R Extensions if the Fortran changes are not trivial or 
you need other details for applying changes.


Uwe Ligges


On 11.05.2011 10:53, Yuliya Matveyeva wrote:

Hello, dear R community.
  The thing is that I am not in the least a developer, neither do I want to
create a package of my own.
But recently I have found a package LogicForest, which is in the base
written in Fortran I think. And well,
in its manual it is written that there are several parameters there that had
had to be "hard coded", but which
in essence actually have no restrictions. So if one needs to change them, he
sure can, only that he has to change
a file with an .f or .ff extension (I believe that it stands for Fortran
code, but I am not sure) and then recompile it.

http://finzi.psych.upenn.edu/R/library/LogicReg/html/logreg.html

I have found several posts in the mailing-archive, but they seem to deal
with Windows.
And I have a Gentoo-based distro.

I have also found a manual "Installation and Administration".
But it all seems to be destined for developers... and usually talks about
creating your own package,
or about installing a package anew.
What I need is just recompile a package, in which I have manually changed
several files.
I really am kinda silly in these kinds of things... So any hints and help
would be greatly appreciated.

I have tried R CMD COMPILE condlogic.ff
But it tells me:
ERROR: don't know how to compile 'condlogic.ff'
I am probably not getting something...

And there is no `src` subdirectory for this package, nor
any .cpp files in the package directory either... Can somebody please
explain to me on which kinds of files can I and should I use R CMD COMPILE ?

/*The Fortran compiler is installed*/


My sessionInfo() :

R version 2.10.1 (2009-12-14)
x86_64-pc-linux-gnu

locale:
[1] C

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



Thank you in advance.
Yulia.

[[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] Loop over a split string

2011-05-11 Thread Uwe Ligges



On 11.05.2011 11:12, Joel wrote:

Hi

I got a string that looks like this:

string<-"a b c d e f"

And what I wanna do is loop trough all the letters.
like

for(i in string){
  print(i)
}

would render the result:
a
b
c
d
e
f

Ive tried using strsplit but without result, dose anyone know how I could
make this happen?


Please ask your supervisor for advices related to your homework.

Uwe Ligges




//Joel

--
View this message in context: 
http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514204.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.


Re: [R] Loop over a split string

2011-05-11 Thread Joel
This is no homework, Im just trying to learn R but sorry for wasting your
time you all mighty God of R Uwe Ligges.

And if this is not a forum to ask simple questions can you please redirect
me to where I might get help? 

//Joel

--
View this message in context: 
http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514225.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] Loop over a split string

2011-05-11 Thread Paul Hiemstra
 Hi Joel,

This looks so much like homework I would give studens that I'm not
surprised Uwe jumped to conclusions...

ontopic:
You did not specify your earlier attempts, just that they failed. This
makes it hard for us to judge what went wrong. Using strsplit I would do:

string<-"a b c d e f"
# The important bit is the subset ([[1]])
# strsplit can work on a vector of strings
# so just splitting on string requires this step
splitted <- strsplit(string, ' ')[[1]]
for(entry in splitted) print(entry)

cheers,
Paul

On 05/11/2011 09:22 AM, Joel wrote:
> This is no homework, Im just trying to learn R but sorry for wasting your
> time you all mighty God of R Uwe Ligges.
>
> And if this is not a forum to ask simple questions can you please redirect
> me to where I might get help? 
>
> //Joel
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514225.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.


-- 
Paul Hiemstra, MSc
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
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] Loop over a split string

2011-05-11 Thread Joel
Thx

Paul

My string aint that simple its just that if it works for this simple example
it will work for my string therefor I just used the "a b c d e f" syntax.

--
View this message in context: 
http://r.789695.n4.nabble.com/Loop-over-a-split-string-tp3514204p3514252.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] Loop over a split string

2011-05-11 Thread peter dalgaard

On May 11, 2011, at 11:35 , Joel wrote:

> Thx
> 
> Paul
> 
> My string aint that simple its just that if it works for this simple example
> it will work for my string therefor I just used the "a b c d e f" syntax.


> strsplit(string," ")
[[1]]
[1] "a" "b" "c" "d" "e" "f"

> strsplit(string," ")[[1]]
[1] "a" "b" "c" "d" "e" "f"
> for(i in strsplit(string," ")[[1]]) cat(i, "\n")
a 
b 
c 
d 
e 
f 
> cat(strsplit(string," ")[[1]], sep="\n")
a
b
c
d
e
f
> 


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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 with contrasts

2011-05-11 Thread Lars Bishop
Hi,

I need to build a function to generate one column for each level of a factor
in the model matrix created on an arbitrary formula (instead of using the
available contrasts options such as contr.treatment, contr.SAS, etc).

My approach to this was first to use the built-in function for
contr.treatment but changing the default value of the contrasts argument to
FALSE (I named this function "contr.identity" and it shown at the bottom of
the email for reference).

So this function works fine,

> contr.identity(4)

  1 2 3 4
1 1 0 0 0
2 0 1 0 0
3 0 0 1 0
4 0 0 0 1

> contr.treatment(4)
  2 3 4
1 0 0 0
2 1 0 0
3 0 1 0
4 0 0 1

However, when I try to create a model matrix using contr.identity specified
in options(), it actually uses the contr.treatment option. Why is that? Any
hint on how can I do this?

options(contrasts = c('contr.identity', 'contr.poly'))
options("contrasts")
dd <- data.frame(a = gl(3,4), b = gl(4,1,12))
model.matrix(~ a + b, dd) #creates 2 columns for a and 3 for b instead of 3
and 4, respectively


contr.identity <-
function(n, base = 1, contrasts = FALSE, sparse = FALSE)
{
if(is.numeric(n) && length(n) == 1L) {
  if(n > 1L) levels <- as.character(seq_len(n))
  else stop("not enough degrees of freedom to define contrasts")
} else {
 levels <- as.character(n)
 n <- length(n)
}

contr <- .Diag(levels, sparse=sparse)
if(contrasts) {
 if(n < 2L)
 stop(gettextf("contrasts not defined for %d degrees of freedom",
  n - 1L), domain = NA)
 if (base < 1L | base > n)
 stop("baseline group number out of range")
 contr <- contr[, -base, drop = FALSE]
}
contr
}

Thanks for any help,
Lars.

[[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] Dotplot (package Hmisc) with groups: colours and symbols

2011-05-11 Thread Peter Ehlers

On 2011-05-11 02:11, E Hofstadler wrote:

Hello all,

This question concerns the function Dotplot from the Hmisc package.

My aim is to compare values between groups in each panel of the
Dotplot, with the values of different groups clearly distinguishable
by different symbols. All lines and symbols should be coloured in
black.

Before adding the panel function to the Dotplot, the groups behaved as
desired and were marked by different symbols, but the error bands were
blue instead of black. After adding the panel function and changing
the trellis colour settings, the error bars are now black, but now the
groups are suddenly marked by the same rather than different symbols.
I've tried several ways to change the group symbols but to no avail.

## set CI lines to black
t1 = trellis.par.get("plot.line")
t1$col<- "black"
trellis.par.set("plot.line",t1)

## load example data
require(lattice)
data(barley)

## example plot (problem: groups marked by the same symbol)

require(Hmisc)
Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year,
data=barley, pch=c(1,2), col="black",
 panel=function(x,y){
 panel.Dotplot(x,y,col="black")})
Key()




What am I doing wrong?


It seems to me that 'plot.line' is the wrong lattice parameter to set.
Try this:

 Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year,
  par.settings=list(superpose.line=list(col="black")),
  data=barley, pch=c(1,2), col="black")

No need to specify the panel function. (To see what's wrong with
the panel function, add '...' to the arguments.)

Peter Ehlers



Many thanks in advance.
Esther

__
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] Vermunt's LEM in R

2011-05-11 Thread David Duffy
I don't know of any R package that can match all the functionality of LEM 
eg fitting equality constraints to model parameters a la LISREL.


WRT dumping tables, I would have thought that as.data.frame.table does 
pretty much what you want, [not tested]


newtab <- as.data.frame(table(a,b,c))
cat("dim\n")
for(i in seq(1, ncol(newtab)-1) {
  cat(nlevels(newtab[,1]," ")
}
cat("\nlab ")
for(i in seq(1, ncol(newtab)-1) {
  cat(letters[i], " ")
}
cat("\ndat [", newtab[,"Freq"], " ]\n")




--
| David Duffy (MBBS PhD) ,-_|\
| email: dav...@qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  / *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

__
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] metaMDS and envfit: Help reading output

2011-05-11 Thread Michael Denslow
Hi Katie,

On Tue, May 10, 2011 at 4:51 PM, Songer, Katherine B - DNR
 wrote:
> Hello R experts,
>
> I've used metaMDS to run NMDS on some fish abundance data, and am also 
> working on correlating environmental data to the NMDS coordinates. I'm fairly 
> new to metaMDS and NMDS in general, so I have what are probably some very 
> basic questions. My fish abundance data consists of 66 sites for which up to 
> 20 species of fish were identified and counted. I ran metaMDS on this data in 
> 3 dimensions (after using a scree plot to check for stress levels in the 
> different dimensions). I then used envfit to correlate a predictor dataset of 
> environmental variables with the NMDS results, using the following code.
>
>>Fish<-as.data.frame(read.csv("Fish.csv",header=TRUE, sep = ","))
>>Fish.mds<-metaMDS(Fish,zerodist = "add",k=3,trymax=20)
>
>>Predictors<-as.data.frame(read.csv("Predictors.csv",header=TRUE, sep = ","))
>>Fish.fit <- envfit(Fish.mds$points, Predictors, k=3, 1000, na.rm = TRUE)

Have a look at the choices argument in envfit, etc. This is how you
specify which axes you want to plot.

ord <- metaMDS(varespec, k=3)
fit <- envfit(ord, varechem,
perm = 999, choices=c(1:3))
fit
plot(ord, choices=c(1,3))
plot(fit, choices=c(1,3))

>>Fish.fit
>
> The output of Fish.fit was as follows (table truncated):
>
>                        Dim1            Dim2            r2      Pr(>r)
> DrainArea       -0.5923233      -0.8057004      0.7674  0.000999 ***
> Flow            -0.5283236      -0.8490431      0.7847  0.000999 ***
> StrmWidth       -0.6993457      -0.7147836      0.6759  0.000999 ***
> Gradient        0.4541225       0.8909392       0.2085  0.010989 *
>
> I'd like to better understand how to read this table. I understand that Dim1 
> and Dim2 refer to the dimensions of the vectors produced by envfit, and r2 is 
> the r-squared of those vectors. But how do I visualize these vectors in a 3-d 
> plot? To which of the 3 NMDS dimensions are these vectors being correlated? 
> Is there code to produce the x, y, and z coordinates of each of the sites in 
> Fish.mds?
>
> Thanks very much.
> Katie
>
>
>        [[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.
>



-- 
Michael Denslow

I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.
-- AND --
Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

36.214177, -81.681480 +/- 3103 meters

__
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] Adding reference line or plane to cloud or wireframe

2011-05-11 Thread Riley, Steve
All,

 

I am wondering how one might add a reference line or plane to a cloud or
wireframe plot. I have been unable to figure this out. Let's say I would
like to draw a reference for some value of wt in the example below:

 

cl <- 54.1

age <- 10:80

wt <- 25:160

 

sim <- expand.grid(age = age,wt = wt)

 

sim$cl <- cl*(sim$wt/70)**0.412 * (sim$age/50)**0.152

 

library(lattice)

 

print(cloud(cl~wt*age, data = sim))

 

 

Any thoughts you could provide are greatly appreciated. Thank you!

Steve

 

Steve Riley, PharmD, PhD

Clinical Pharmacology

Specialty Care Medicines Development Group

Pfizer Inc.

445 Eastern Point Rd MS 8260-2513

Groton, CT 06340

 

Email: steve.ri...@pfizer.com  

Phone: (860) 441-3435

Fax: (860) 686-5672

 

 


[[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 with contrasts

2011-05-11 Thread peter dalgaard

On May 11, 2011, at 12:51 , Lars Bishop wrote:

> Hi,
> 
> I need to build a function to generate one column for each level of a factor
> in the model matrix created on an arbitrary formula (instead of using the
> available contrasts options such as contr.treatment, contr.SAS, etc).
> 
> My approach to this was first to use the built-in function for
> contr.treatment but changing the default value of the contrasts argument to
> FALSE (I named this function "contr.identity" and it shown at the bottom of
> the email for reference).
> 
> So this function works fine,
> 
>> contr.identity(4)
> 
>  1 2 3 4
> 1 1 0 0 0
> 2 0 1 0 0
> 3 0 0 1 0
> 4 0 0 0 1
> 
>> contr.treatment(4)
>  2 3 4
> 1 0 0 0
> 2 1 0 0
> 3 0 1 0
> 4 0 0 1
> 
> However, when I try to create a model matrix using contr.identity specified
> in options(), it actually uses the contr.treatment option. Why is that? Any
> hint on how can I do this?


It's not actually using contr.treatment, it's just calling contr.identity with 
contrasts=TRUE...

I don't think there's a painless way to avoid this. The closest I can think of 
is

cI <- contr.treatment
formals(cI)$contrasts <- FALSE
dd <- data.frame(a = gl(3,4), b = gl(4,1,12))
model.matrix(~ C(a,cI,3) + C(b,cI,4), dd)



-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] Adding reference line or plane to cloud or wireframe

2011-05-11 Thread Duncan Murdoch

On 11/05/2011 7:12 AM, Riley, Steve wrote:

All,



I am wondering how one might add a reference line or plane to a cloud or
wireframe plot. I have been unable to figure this out. Let's say I would
like to draw a reference for some value of wt in the example below:



cl<- 54.1

age<- 10:80

wt<- 25:160



sim<- expand.grid(age = age,wt = wt)



sim$cl<- cl*(sim$wt/70)**0.412 * (sim$age/50)**0.152



library(lattice)



print(cloud(cl~wt*age, data = sim))





Any thoughts you could provide are greatly appreciated. Thank you!


It is tricky in lattice or classic graphics, because they depend on 
using the painter's algorithm to handle occlusion of some objects by 
others.  You need to draw the part of the line or plane that is in front 
of the surface after you draw the surface, but the part behind it needs 
to be drawn first (or not at all).


If you use rgl, these calculations are done in hardware, and it's 
somewhat easier.  For example, with your data as above,


open3d()
persp3d(age, wt, sim$cl, col="blue")

fit <- lm(cl ~ wt + age, data=sim)
coefs <- coef(fit)

planes3d(coefs["wt"], coefs["age"], -1, coefs["(Intercept)"], alpha=0.5)

(The planes3d function is new.  It's still only on the R-forge 
development version of rgl, not on CRAN yet.  Similarly, abclines3d is a 
new addition for drawing reference lines.)


Duncan Murdoch

__
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] Recompile a package

2011-05-11 Thread Prof Brian Ripley

On Wed, 11 May 2011, Uwe Ligges wrote:


1. Upgrade to a recent version of R.
2. download the whole source package and untar it
3. change the files
4. R CMD build it
5. R CMD INSTALL it

For more details see the manual R Installation and Administration as well as 
Writing R Extensions if the Fortran changes are not trivial or you need other 
details for applying changes.


It seems this is about package LogicReg, not LogicForest.

Google suggests that this is about the following page:
http://kooperberg.fhcrc.org/logic/helpfiles/logreg.myown.html
and my guess is that you are supposed to rename condlogic.ff.
But (as the posting guide asked) you need to ask the authors
of the confusing documentation for clarification.

R 2.10.1 is seriously old now: please update as the posting guide 
suggested.




Uwe Ligges


On 11.05.2011 10:53, Yuliya Matveyeva wrote:

Hello, dear R community.
  The thing is that I am not in the least a developer, neither do I want to
create a package of my own.
But recently I have found a package LogicForest, which is in the base
written in Fortran I think. And well,
in its manual it is written that there are several parameters there that 
had

had to be "hard coded", but which
in essence actually have no restrictions. So if one needs to change them, 
he

sure can, only that he has to change
a file with an .f or .ff extension (I believe that it stands for Fortran
code, but I am not sure) and then recompile it.

http://finzi.psych.upenn.edu/R/library/LogicReg/html/logreg.html

I have found several posts in the mailing-archive, but they seem to deal
with Windows.
And I have a Gentoo-based distro.

I have also found a manual "Installation and Administration".
But it all seems to be destined for developers... and usually talks about
creating your own package,
or about installing a package anew.
What I need is just recompile a package, in which I have manually changed
several files.
I really am kinda silly in these kinds of things... So any hints and help
would be greatly appreciated.

I have tried R CMD COMPILE condlogic.ff
But it tells me:
ERROR: don't know how to compile 'condlogic.ff'
I am probably not getting something...

And there is no `src` subdirectory for this package, nor
any .cpp files in the package directory either... Can somebody please
explain to me on which kinds of files can I and should I use R CMD COMPILE 
?


/*The Fortran compiler is installed*/


My sessionInfo() :

R version 2.10.1 (2009-12-14)
x86_64-pc-linux-gnu

locale:
[1] C

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



Thank you in advance.
Yulia.


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


[R] Parantheses highlighting

2011-05-11 Thread Sascha Wolfer
Dear list,

is it just me or is everybody experiencing this?
Since the upgrade to R 2.13.0 on my Mac (OS X 10.6.7, R GUI 1.40 (5751)) the 
highlighting of matching parantheses doesn't work the way it used to. It 
doesn't highlight the matching parantheses while typing, but it still does 
while scrolling over it with the cursor with the arrow keys. This is quite 
inconvenient since I have to go back after each bracket if I want to know which 
one's the matching bracket.

I experience this problem with every kind of bracket (round, curly ...).

I really like the built-in Mac OS editor for R, so I hope this will be fixed 
soon or I can easily fix it myself.

Thanks,
Sascha W. 

---
Sascha A. Wolfer, M.A.
Centre for Cognitive Science
University of Freiburg

__
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] Vermunt's LEM in R

2011-05-11 Thread Ingmar Visser
depmixS4 can fit equality constraints in latent class and latent markov
models, best, Ingmar

On Wed, May 11, 2011 at 1:04 PM, David Duffy  wrote:

> I don't know of any R package that can match all the functionality of LEM
> eg fitting equality constraints to model parameters a la LISREL.
>
> WRT dumping tables, I would have thought that as.data.frame.table does
> pretty much what you want, [not tested]
>
> newtab <- as.data.frame(table(a,b,c))
> cat("dim\n")
> for(i in seq(1, ncol(newtab)-1) {
>  cat(nlevels(newtab[,1]," ")
> }
> cat("\nlab ")
> for(i in seq(1, ncol(newtab)-1) {
>  cat(letters[i], " ")
> }
> cat("\ndat [", newtab[,"Freq"], " ]\n")
>
>
>
>
> --
> | David Duffy (MBBS PhD) ,-_|\
> | email: dav...@qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  / *
> | Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
> | 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] filtering out unwanted words in a Term Document Matrix

2011-05-11 Thread Heiman, Thomas J.
Hi Y'all,

I am using the text mining package (tm). I am trying to filter out all of the 
words in a Term Document Matrix that are not in a list of words that I am 
interested in.  I am using the following code:

z<-tm_intersect(txt.dtm, c("communications", "safety", "climate", "blood", 
"surface", "cleanliness", "amenities", "monitoring", "staff", "competency", 
"policy", "procedure", "inconsistency", "physician", "orders", "treatment", 
"times", "care", "plan", "strategies", "concerns", "meetings", "equipment", 
"treatment", "options", "delivery", "care", "discharge", "welfare", 
"violations", "HIPPS", "professionalism", "lack", "boundaries crossing", 
"transportation", "benefits", "assistance", "beneficiary", "complaint", 
"grievance", "inquiry", "formal", "data", "processing", "concern", "facility", 
"abuse", "data", "request", "disruptive", "information", "patient", 
"discharge", "transfer", "physical", "ethics", "resolution", 
"professional","reimbursement", "financial", "request", "status", 
"educational", "material", "forms", "technical", "assistance", "staff", 
"related", "quality", 
"care","disruptive","behavior","special","needs","mental","illness","noncompliance","illegal",
 "immigrant!
 ", "abusive", "violent","litigation", "prisoner", "corporate", "lockout", 
"disposition", "discharge", "reason"))

I get the following error:

  "no applicable method for 'tm_intersect' applied to an object of class 
"c('TermDocumentMatrix', 'simple_triplet_matrix')" "

What am I doing wrong?  I'd greatly appreciate any ideas or thoughts on 
this  Thank you!!

Thomas Heiman, PhD
Info Systems Eng, Sr
The MITRE Corporation | Center for Enterprise Modernization
Office: 703-983-2951 | thei...@mitre.org

[[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] Vermunt's LEM in R

2011-05-11 Thread David Joubert

Thanks for the info. It would be nice to transition LEM to R (make it a 
package), but I don't know how much work that would take. It's not updated 
anymore and as far as I know it's not open source. Perhaps Vermunt would be 
open to share his code. In R it's just a question of finding the right packages 
for running similar functions as LEM, hence my original question.

Best,

David Joubert

> From: h...@udel.edu
> Subject: Vermunt's LEM in R
> To: jo...@hotmail.com
> CC: "Cc: r-help"@r-project.org
> Date: Tue, 10 May 2011 17:43:43 -0400
> 
> In addition to other suggestions, have you looked at gnm, which does (or can 
> do) many of the things LEM does? Also vcd and vcdExtra provide additional 
> tools.
> 
> I stopped using LEM and similar packages because I found R has roughly 
> similar tools. In fact, has LEM been updated or revised recently? I thought 
> its authors were pushing Latent Gold, which seems to be more actively 
> developed than LEM.
> 
> I hope this helps.
  
[[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] Vermunt's LEM in R

2011-05-11 Thread David Joubert

Thanks, I will definitely give it a try.

David J

> Date: Wed, 11 May 2011 21:04:23 +1000
> From: dav...@qimr.edu.au
> To: r-help@r-project.org
> CC: jo...@hotmail.com
> Subject: Re: [R] Vermunt's LEM in R
> 
> I don't know of any R package that can match all the functionality of LEM 
> eg fitting equality constraints to model parameters a la LISREL.
> 
> WRT dumping tables, I would have thought that as.data.frame.table does 
> pretty much what you want, [not tested]
> 
> newtab <- as.data.frame(table(a,b,c))
> cat("dim\n")
> for(i in seq(1, ncol(newtab)-1) {
>cat(nlevels(newtab[,1]," ")
> }
> cat("\nlab ")
> for(i in seq(1, ncol(newtab)-1) {
>cat(letters[i], " ")
> }
> cat("\ndat [", newtab[,"Freq"], " ]\n")
> 
> 
> 
> 
> -- 
> | David Duffy (MBBS PhD) ,-_|\
> | email: dav...@qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  / *
> | Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
> | 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v
  
[[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] Vermunt's LEM in R

2011-05-11 Thread David Joubert

Thanks, I have looked at this package but I am still trying to understand some 
of the features. It looks interesting, though.

David J

> Date: Wed, 11 May 2011 15:05:32 +0200
> From: i.vis...@uva.nl
> To: dav...@qimr.edu.au
> CC: r-help@r-project.org
> Subject: Re: [R] Vermunt's LEM in R
> 
> depmixS4 can fit equality constraints in latent class and latent markov
> models, best, Ingmar
> 
> On Wed, May 11, 2011 at 1:04 PM, David Duffy  wrote:
> 
> > I don't know of any R package that can match all the functionality of LEM
> > eg fitting equality constraints to model parameters a la LISREL.
> >
> > WRT dumping tables, I would have thought that as.data.frame.table does
> > pretty much what you want, [not tested]
> >
> > newtab <- as.data.frame(table(a,b,c))
> > cat("dim\n")
> > for(i in seq(1, ncol(newtab)-1) {
> >  cat(nlevels(newtab[,1]," ")
> > }
> > cat("\nlab ")
> > for(i in seq(1, ncol(newtab)-1) {
> >  cat(letters[i], " ")
> > }
> > cat("\ndat [", newtab[,"Freq"], " ]\n")
> >
> >
> >
> >
> > --
> > | David Duffy (MBBS PhD) ,-_|\
> > | email: dav...@qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  / *
> > | Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
> > | 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v
> >
> >
> > __
> > 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.
  
[[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] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread David Winsemius


On May 11, 2011, at 4:26 AM, Michael Haenlein wrote:


Dear all,

this is probably more a statistics question than an R question but  
probably

there is somebody who can help me nevertheless.

I'm running a regression with four predictors (a, b, c, d) and all  
their
interaction effects using lm. Based on theory I assume that a  
influences y
positively. In my output (see below) I see, however, a negative  
regression
coefficient for a. But several of the interaction effects of a with  
b, c and
d have positive signs. I don't really understand this. Do I have to  
add up
the coefficient for the main effect and the ones of all interaction  
effects

to get a total effect of a on y? Or am I doing something wrong here?


In the presence of interactions there is little point in attempting to  
assign meaning to individual coefficients. You need to use predict()  
(possibly with graphical or tabular displays) and produce estimates of  
one or two variable at relevant levels of  the other variables.


The other aspect about which your model is not informative, is the  
possibility that some of these predictors have non-linear associations  
with `y`.


(The coefficient for `a` examined in isolation might apply to a group  
of subjects (or other units of analysis) in which the values of `b`,  
`c`, and `d` were all held at zero. Is that even a situation that  
would occur in your domain of investigation?)


--
David.


Thanks very much for your answer in advance,

Regards,

Michael


Michael Haenlein
Associate Professor of Marketing
ESCP Europe
Paris, France



Call:
lm(formula = y ~ a * b * c * d)

Residuals:
   Min  1Q  Median  3Q Max
-44.919  -5.184   0.294   5.232 115.984

Coefficients:
   Estimate Std. Error t value Pr(>|t|)
(Intercept)  27.3067 0.8181  33.379  < 2e-16 ***
a   -11.0524 2.0602  -5.365 8.25e-08 ***
b-2.5950 0.4287  -6.053 1.47e-09 ***
c   -22.0025 2.8833  -7.631 2.50e-14 ***
d20.5037 0.3189  64.292  < 2e-16 ***
a:b  15.1411 1.1862  12.764  < 2e-16 ***
a:c  26.8415 7.2484   3.703 0.000214 ***
b:c   8.3127 1.5080   5.512 3.61e-08 ***
a:d   6.6221 0.8061   8.215 2.33e-16 ***
b:d  -2.0449 0.1629 -12.550  < 2e-16 ***
c:d  10.0454 1.1506   8.731  < 2e-16 ***
a:b:c 1.4137 4.1579   0.340 0.733862
a:b:d-6.1547 0.4572 -13.463  < 2e-16 ***
a:c:d   -20.6848 2.8832  -7.174 7.69e-13 ***
b:c:d-3.4864 0.6041  -5.772 8.05e-09 ***
a:b:c:d   5.6184 1.6539   3.397 0.000683 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.913 on 12272 degrees of freedom
Multiple R-squared: 0.8845, Adjusted R-squared: 0.8844
F-statistic:  6267 on 15 and 12272 DF,  p-value: < 2.2e-16

[[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, MD
West Hartford, CT

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


Re: [R] Dotplot (package Hmisc) with groups: colours and symbols

2011-05-11 Thread Hugo Mildenberger
Hello Esther,

you left out the ellipsis argument (...) to the panel function.
That argument serves a placeholder for the rest of the parameters 
you did not want to name and pass explicitely. If you don't pass the
ellipsis to panel.Dotplot, all unnamed parameters will get default 
values. You can see these defaults by typing panel.dotplot or 
edit(panel.dotplot) on the command line.

Dotplot( site~Cbind(yield, yield+5, yield-5)|variety,
 groups = year,
 data   = barley,
 pch= c(1,2),
 panel  = function(x,y,...){
   panel.Dotplot(x,y,col="black",...);
})
 
Best 



On Wednesday 11 May 2011 11:11:50 E Hofstadler wrote:
> Hello all,
> 
> This question concerns the function Dotplot from the Hmisc package.
> 
> My aim is to compare values between groups in each panel of the
> Dotplot, with the values of different groups clearly distinguishable
> by different symbols. All lines and symbols should be coloured in
> black.
> 
> Before adding the panel function to the Dotplot, the groups behaved as
> desired and were marked by different symbols, but the error bands were
> blue instead of black. After adding the panel function and changing
> the trellis colour settings, the error bars are now black, but now the
> groups are suddenly marked by the same rather than different symbols.
> I've tried several ways to change the group symbols but to no avail.
> 
> ## set CI lines to black
> t1 = trellis.par.get("plot.line")
> t1$col <- "black"
> trellis.par.set("plot.line",t1)
> 
> ## load example data
> require(lattice)
> data(barley)
> 
> ## example plot (problem: groups marked by the same symbol)
> 
> require(Hmisc)
> Dotplot(site~Cbind(yield, yield+5, yield-5)|variety, groups=year,
> data=barley, pch=c(1,2), col="black",
> panel=function(x,y){
> panel.Dotplot(x,y,col="black")})
> Key()
> 
> 
> 
> 
> What am I doing wrong?
> 
> Many thanks in advance.
> Esther
> 
> __
> 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] displaying derived coefficients in lm

2011-05-11 Thread James Lawrence

Hello R-help,

Is there a way to get R to tell you the coefficients in a lm that it 
wouldn't normally tell you because of identifiability constraints? For 
instance, if you use contr.sum() to generate contrasts for a factor, say


## y <- some data
## x <- a factor with levels 1:6
contrasts(x) <- contr.sum(levels(x))
lm.1 <- lm(y ~ x)

how would one persuade summary.lm to give the coefficient for x6 as well 
as x1 up to x5? I know in this case that x6 is minus the sum of x1 to 
x5, but I am working on a problem where the constraints are very 
complicated and it would be a real help to see all the coefficients.


Thanks in advance

James Lawrence.

__
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] deleting rows containing a letter

2011-05-11 Thread chris20
Hi
I have dataframe with different plot numbers in and different subplots as
letters at the end of the plot number i.e. 1a, 1b 2-1a etc.
I want to delete all rows that end in a specific letter eg...

treat<-c("1a","1b","1c","2a","2b","2c","2-1a","2-1b","2-1c")
a1<-1:9
b1<-9:1
d1<-data.frame(treat,a1,b1)

How do I remove all rows where treat ends in "c" ?  I have tried the usual
ways of deleting rows but nothing works.

Thanks
Chris 

--
View this message in context: 
http://r.789695.n4.nabble.com/deleting-rows-containing-a-letter-tp3514473p3514473.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] Repeating an MLE experiement

2011-05-11 Thread NUFC09
Ive been given an normal distribution, and have calculated the maximum
likelihood function. I need to repeat this experiment 50 times, and 200
times, and plot the results in two histograms and compare them.

I need to create a code to repeat this experiment. How do i go about doing
this? Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Repeating-an-MLE-experiement-tp3514690p3514690.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] deleting rows containing a letter

2011-05-11 Thread David Winsemius


On May 11, 2011, at 7:55 AM, chris20 wrote:


Hi
I have dataframe with different plot numbers in and different  
subplots as

letters at the end of the plot number i.e. 1a, 1b 2-1a etc.
I want to delete all rows that end in a specific letter eg...

treat<-c("1a","1b","1c","2a","2b","2c","2-1a","2-1b","2-1c")
a1<-1:9
b1<-9:1
d1<-data.frame(treat,a1,b1)


> d1[-grep("c$", d1$treat), ]
  treat a1 b1
11a  1  9
21b  2  8
42a  4  6
52b  5  5
7  2-1a  7  3
8  2-1b  8  2

How do I remove all rows where treat ends in "c" ?  I have tried the  
usual

ways of deleting rows but nothing works.


Not sure what the usual ways are for you but negative indexing is the  
usual way for me.


(Could also use subset, I suppose)



Thanks
Chris
e.


David Winsemius, MD
West Hartford, CT

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


Re: [R] deleting rows containing a letter

2011-05-11 Thread David Winsemius


On May 11, 2011, at 10:01 AM, David Winsemius wrote:



On May 11, 2011, at 7:55 AM, chris20 wrote:


Hi
I have dataframe with different plot numbers in and different  
subplots as

letters at the end of the plot number i.e. 1a, 1b 2-1a etc.
I want to delete all rows that end in a specific letter eg...

treat<-c("1a","1b","1c","2a","2b","2c","2-1a","2-1b","2-1c")
a1<-1:9
b1<-9:1
d1<-data.frame(treat,a1,b1)


> d1[-grep("c$", d1$treat), ]
 treat a1 b1
11a  1  9
21b  2  8
42a  4  6
52b  5  5
7  2-1a  7  3
8  2-1b  8  2

How do I remove all rows where treat ends in "c" ?  I have tried  
the usual

ways of deleting rows but nothing works.


Not sure what the usual ways are for you but negative indexing is  
the usual way for me.


(Could also use subset, I suppose)


As here with grepl rather than grep:

> subset(d1, !grepl("c$", d1$treat))
  treat a1 b1
11a  1  9
21b  2  8
42a  4  6
52b  5  5
7  2-1a  7  3
8  2-1b  8  2

In case you are new to grepping, the $ indicates the end of a string  
and therefore 'c' will match any 'c' at the end of the string. grepl  
creates a logical vector that flags matches and non-matches and the  
'!' operator logically inverts it.




David Winsemius, MD
West Hartford, CT

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


Re: [R] Repeating an MLE experiement

2011-05-11 Thread David Winsemius


On May 11, 2011, at 9:28 AM, NUFC09 wrote:


Ive been given an normal distribution, and have calculated the maximum
likelihood function. I need to repeat this experiment 50 times, and  
200

times, and plot the results in two histograms and compare them.

I need to create a code to repeat this experiment. How do i go about  
doing

this? Thanks


This appears to be homework and homework submissions are deprecated on  
the list, especially those that do not show what progress has bee made  
up to the point of being 'stuck'.


--

David Winsemius, MD
West Hartford, CT

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


[R] Problems with tcltk

2011-05-11 Thread Arnaud Mosnier
Dear R-helpers,

I am using R x64 and when I want to load the tcltk library, it gives
me the following error:

Loading Tcl/Tk interface ...Error : .onLoad failed in loadNamespace()
for 'tcltk', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Program
Files/R/R-2.13.0/library/tcltk/libs/x64/tcltk.dll':
  LoadLibrary failure:  This application has failed to start because
the application configuration is incorrect. Reinstalling the
application may fix this problem.



I tried to reinstall tcltk
(ActiveTcl8.5.9.2.294317-win32-x86_64-threaded.exe) but it does not
solve my problem.

Here is my sessionInfo()

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-mingw32/x64 (64-bit)

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

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

Arnaud

__
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] Parantheses highlighting

2011-05-11 Thread Ista Zahn
This question is probably more appropriate for R-sig-mac
(https://stat.ethz.ch/mailman/listinfo/r-sig-mac).

Best,
Ista

On Wed, May 11, 2011 at 8:45 AM, Sascha Wolfer
 wrote:
> Dear list,
>
> is it just me or is everybody experiencing this?
> Since the upgrade to R 2.13.0 on my Mac (OS X 10.6.7, R GUI 1.40 (5751)) the 
> highlighting of matching parantheses doesn't work the way it used to. It 
> doesn't highlight the matching parantheses while typing, but it still does 
> while scrolling over it with the cursor with the arrow keys. This is quite 
> inconvenient since I have to go back after each bracket if I want to know 
> which one's the matching bracket.
>
> I experience this problem with every kind of bracket (round, curly ...).
>
> I really like the built-in Mac OS editor for R, so I hope this will be fixed 
> soon or I can easily fix it myself.
>
> Thanks,
> Sascha W.
>
> ---
> Sascha A. Wolfer, M.A.
> Centre for Cognitive Science
> University of Freiburg
>
> __
> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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] Reading a large netCDF file using R

2011-05-11 Thread David William Pierce
On Tue, May 10, 2011 at 10:17 AM, Sulochan Dhungel <
sulochandhun...@gmail.com> wrote:

> Hi Dave,
>
> I asked for the climate group for one particular day's data so that I could
> match it up with the data I got from the codes for the same day. It did not
> match. So I knew it was not working. Also time is the first thing on the
> list of summary for "nc" , but when I saw other netCDF files, time was the
> last thing.
>
> Thanks again for looking into my problem.
>
> Sulochan
>

Hi Sulochan,

whether time is listed first or last depends on the application ... in R,
it's listed last.  In some other applications, it's listed first.  So that's
just one of those things, and doesn't mean anything is wrong.

Re the data not matching, I fear that is some other problem then start and
count in the R get.var.ncdf() call not working correctly.  I suggest you
check the exact values you use for start and count.  Using a time index of 1
in R gives you the first time entry.

--Dave

[[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] ggplot2 and add circle

2011-05-11 Thread Dennis Murphy
Hi:

Here's a slight modification of the earlier code .

plot_shad <- function(d, r, dtxt) {
  require('ggplot2')
  plotdata <- melt(d)
  names(plotdata)<-c('x','y','z')
  xc <- mean(range(plotdata$x))
  yc <- mean(range(plotdata$y))
  theta <- seq(-pi, pi, length = 200)
  circ <- data.frame(xv = xc + r * cos(theta),
 yv = yc + r * sin(theta))
  v <- ggplot(plotdata)
  print(v + geom_tile(aes(x = x, y = y, fill = z)) +
geom_path(data = circ, aes(x = xv, y = yv),
  color = 'white', size = 1) +
geom_text(data = dtxt, aes(x = x, y = y, label = lab),
  color = 'white') +
coord_equal()
   )
 }

f <- matrix(data=seq(1:1), nrow=100, ncol=100)
dftxt <- data.frame(x = 80, y = 90, lab = 'r = 0.227')

plot_shad(f, 10, dftxt)


It's not hard to create a separate text string with paste() and then
use it for the lab argument in the dftxt data frame, something like

txt <- paste('r =', with(mydata, round(cor(x, y), 3))
dftxt <- data.frame(x = 80, y = 90, lab = txt)
plot_shad(...)

HTH,
Dennis

On Tue, May 10, 2011 at 11:43 PM, Alaios  wrote:
> Thanks a lot this worked nice.
> It it possible also in ggplot2 to add a small figure? Let's say that I want 
> to have somewhere in the plot the value of r printed.
>
> How can I do that with ggplot 2?
>
> Regards
> Alex
>
> --- On Tue, 5/10/11, Dennis Murphy  wrote:
>
>> From: Dennis Murphy 
>> Subject: Re: [R] ggplot2 and add circle
>> To: "Alaios" 
>> Cc: R-help@r-project.org
>> Date: Tuesday, May 10, 2011, 7:12 PM
>> Hi:
>>
>> Here's one way:
>>
>> plot_shad <- function(d, r) {
>>    require('ggplot2')
>>    plotdata <- melt(d)
>>    names(plotdata)<-c('x','y','z')
>>    xc <- mean(range(plotdata$x))
>>    yc <- mean(range(plotdata$y))
>>    theta <- seq(-pi, pi, length = 200)
>>    circ <- data.frame(xv = xc + r *
>> cos(theta),
>>
>>       yv = yc + r * sin(theta))
>>    v <- ggplot(plotdata)
>>    print(v + geom_tile(aes(x = x, y = y,
>> fill = z)) +
>>          geom_path(data =
>> circ, aes(x = xv, y = yv), color = 'white',
>> size = 1) +
>>          coord_equal()
>>         )
>>  }
>>
>> plot_shad(f, 10)
>>
>> HTH,
>> Dennis
>>
>> On Tue, May 10, 2011 at 10:15 AM, Alaios 
>> wrote:
>> > Here you are :)
>> >
>> >
>> > plot_shad_f<-function(f){
>> >   library(ggplot2)
>> >   dev.new()
>> >   plotdata<-melt(f)
>> >   names(plotdata)<-c('x','y','z')
>> >   v<-ggplot(plotdata, aes(x, y, z = z))
>> >   print(v + geom_tile(aes(fill=z)))
>> >
>> > }
>> >
>> >
>> > f<-matrix(data=seq(1:1),nrow=100,ncol=100)
>> > plot_shad_f(f)
>> >
>> >
>> > I would like to add a circle at the middle of this
>> region with a range of 10.
>> >
>> > Best Regards
>> >
>> > Alex
>> >
>> > --- On Tue, 5/10/11, Scott Chamberlain 
>> wrote:
>> >
>> > From: Scott Chamberlain 
>> > Subject: Re: [R] ggplot2 and add circle
>> > To: "Alaios" 
>> > Cc: R-help@r-project.org
>> > Date: Tuesday, May 10, 2011, 5:59 PM
>> >
>> >
>> >
>> >                You should provide reproducible
>> data in addition to your code.
>> > S
>> >
>> >
>> >
>> >
>> >
>> >                On Tuesday, May 10, 2011 at
>> 11:54 AM, Alaios wrote:
>> >
>> >                    Dear all,
>> > today I have writted the following code,
>> > to plot the contents of some matrices I have
>> >
>> > plot_shad_f
>> > function(f){
>> >  library(ggplot2)
>> >  dev.new()
>> >  plotdata<-melt(f)
>> >  names(plotdata)<-c('x','y','z')
>> >  v<-ggplot(plotdata, aes(x, y, z = z))
>> >  print(v + geom_tile(aes(fill=z)))
>> > }
>> >
>> > I would like to ask your help add a small circle in
>> this plotting. What would be the easiest way to do that in
>> ggplot2?
>> >
>> > Best Regards
>> > Alex
>> >
>> > __
>> > R-help@r-project.org
>> mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained,
>> reproducible code.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> >
>> > __
>> > R-help@r-project.org
>> mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained,
>> reproducible code.
>> >
>> >
>>
>
> __
> R-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 

[R] Init nnetTs (or nnet?) with a former Neural Net

2011-05-11 Thread c2r
I am new to R and use nnetTs - calls.
If a time series of let's say 8 Datapoints and did call nnetTs I want
make a new net
for the old ponts plus the next 1000 points (81000 datapoints total) what
would again 
cost much calculation time.
So I want to pre-init the new net with the former wonnen net to reduce the
necessary 
iteration numbers. 
Is thee a possibility to do that and how?

i.e.:
x=ts(scan("C:/mydata1.csv"))
mod.nnet<-nnetTs(x,m=2,size=8)
x=ts(scan("C:/mydata2.csv"))
mod.nnetnew<-nnetTs(x,m=2,size=8,control=list(init=mod.nnet)) ???

Thanks for any help !!


--
View this message in context: 
http://r.789695.n4.nabble.com/Init-nnetTs-or-nnet-with-a-former-Neural-Net-tp3514825p3514825.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] ANOVA 1 too few degrees of freedom

2011-05-11 Thread Rovinpiper


Please read the first two paragraphs of Details from ?formula

Ok, I just did.

So, If I understand this properly, the term Plot*Day would include both the
main effects of a and b and their second order interactions. So it could be
written Plot + Day + Plot:Day. 

The term Plot:Day includes only the second order interactions of Plot and
Day. 

So would that make this model redundant:

Rs ~ Plot + Day + Plot:Day

Since it includes the main effects of Plot and Day twice?

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-1-too-few-degrees-of-freedom-tp3493349p3514828.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] Adding legend to heatmap

2011-05-11 Thread rugma gopakumar
Hello,

 Myself Rugma Gopakumar.I would like to know how to add a legend to
a heatmap..



Regards,

Rugma Gopakumar.

[[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] deleting rows containing a letter

2011-05-11 Thread chris20
Excellant! Thanks both for your replies.  I've never used grep, I do use
negative indexing but usually:

-which(. %in% 

--
View this message in context: 
http://r.789695.n4.nabble.com/deleting-rows-containing-a-letter-tp3514473p3514829.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] issue with graph package in using RBGL -‘'graph' is not a valid installed package’"

2011-05-11 Thread joe j
Dear all,

I am trying to run the function "lambdaSets" using the package "RBGL".
This package uses another package "graph" which has been removed from
the CRAN repository, but is available at the archive
(http://cran.r-project.org/src/contrib/Archive/graph/).

I installed the package from the R menu at "install packages from
local zip files" (after downloading the "graph_1.30.0.tar.gz" file,
unzipping it and making it a zip file; gz is not recognized by R.). I
get no warning here so I assumed installation went well. However, when
I type "require(RBGL)" I get the error message that: "Failed with
error:  ‘'graph' is not a valid installed package’".

I am using R version 2.12.2 (2011-2-25). I am a new user so your
advice would be of great help.

Best wishes,
Joe

__
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] sample weights in ols

2011-05-11 Thread jour4life
I have a follow up question. When using svyglm, it does not matter that I am
not using survey design and only weights? 
In other words,

fit<-svyglm(y~x1+x2+...xk,data=dataset,weights=weightvariable)

Or am I going to have to construct a survey design variable, using only the
weight variable?

Thanks,

Carlos

--
View this message in context: 
http://r.789695.n4.nabble.com/sample-weights-in-ols-tp3510865p3514920.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] R versions for Red Hat Linux

2011-05-11 Thread Marta Avalos
Dear all,
The latest R version available for Red Hat Linux is 2.10 (from November 
2009), whereas the latest version available for Debian, Suse or Ubuntu Linux 
is 2.13 (from May 2011). 
Has someone some information about the development/release of new R versions 
for Red Hat?
 
Thank you in advance,
Marta 
 

[[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] ddply with mean and max...

2011-05-11 Thread Justin
I'm trying to use ddply to compute summary statistics for many variables
splitting on the variable site.  however, it seems to work fine for mean() but
if i use max() or min() things fall apart.  whats going on?

 test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
 means<-ddply(test.set,.(site),mean)
 means
   site  x   y
1 1  -97459496 -0.14826303
2 2 -150246922 -0.29279556
3 3  471813178  0.13090210
4 4 -655451621  0.07908207
5 5 -229505843  0.10239588
6 6 -667025397 -0.34930275
7 7  510041943  0.20547460
8 8  270993292 -0.63658199
9 9  264989314  0.09695455
10   10 -199965142 -0.07202699
 maxes<-ddply(test.set,.(site),max)
 maxes
   site V1
1 1 1942437227
2 2 2066224792
3 3 2146619846
4 4 1381954134
5 5 1802867123
6 6 1786627153
7 7 1951106534
8 8 1498358582
9 9 2022046126
10   10 1670904926

Can you all shed some light on this? I'm stumped!

Thanks,
Justin

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


[R] Help with gam

2011-05-11 Thread Zsolt Macskasi
Hi,

I am a brand new user of R and I am trying to use the gam procedure with the 
package mgcv. I did a bit of my homework by consulting the R-manual, as well as 
the mgcv manual written by Simon Wood. I admit it was just a few hours, but 
what I am trying to do is really basic. Essentially, what I am trying to do is 
to generate the fitted values after the execution of the gam procedure and 
export them into Excel.

Here is my program:

ABC <- read.table("Incidence Data.csv", header=TRUE, sep=",")
incidence <- ABC[,1]
age <- ABC[,2]
birthyear <- ABC[,3]
fit<-gam(incidence~te(age,birthyear), family=poisson, fit=TRUE)

All this works. Now, how can I see the fitted values and copy them back to 
Excel?

Thank you very much,

Zsolt

[[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] Uploading CSV file into R

2011-05-11 Thread Me
Hi, I'm trying to upload two CSV files into R, and I'm having some trouble.
I've used the instructions I've found on the Web, but they haven't helped so
far. I'm worried this could be because I'm using a Mac.

The two data sets are here:
http://data.un.org/Data.aspx?d=WDI&f=Indicator_Code%3aNY.GNP.PCAP.PP.CD
http://data.un.org/Data.aspx?d=UNODC&f=tableCode%3a1

Thanks for your help. Let me know if you need more information.

--
View this message in context: 
http://r.789695.n4.nabble.com/Uploading-CSV-file-into-R-tp3515237p3515237.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] R versions for Red Hat Linux

2011-05-11 Thread Uwe Ligges



On 11.05.2011 17:12, Marta Avalos wrote:

Dear all,
The latest R version available for Red Hat Linux is 2.10 (from November
2009), whereas the latest version available for Debian, Suse or Ubuntu Linux
is 2.13 (from May 2011).
Has someone some information about the development/release of new R versions
for Red Hat?


Well, just get the sources and install yourself from sources. Then you 
do not need to worry.


Uwe Ligges




Thank you in advance,
Marta


[[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] R versions for Red Hat Linux

2011-05-11 Thread Marc Schwartz
On May 11, 2011, at 10:12 AM, Marta Avalos wrote:

> Dear all,
> The latest R version available for Red Hat Linux is 2.10 (from November 
> 2009), whereas the latest version available for Debian, Suse or Ubuntu Linux 
> is 2.13 (from May 2011). 
> Has someone some information about the development/release of new R versions 
> for Red Hat?
> 
> Thank you in advance,
> Marta 


R for RHEL based Linux distributions has been available for some time via the 
EPEL:

  http://fedoraproject.org/wiki/EPEL

You can review the instructions there for configuring your system to use the 
EPEL and then use 'yum' to install R:

  sudo yum install R

If by Red Hat, you are actually referring to Fedora, R is available via the 
regular Fedora repos. Just use the same command line incantation as above.

Also, just an FYI that there is a R-SIG-Fedora list, which focused on RH and 
Fedora specific issues. More info at:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

HTH,

Marc Schwartz

__
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 with gam

2011-05-11 Thread Uwe Ligges



On 11.05.2011 17:22, Zsolt Macskasi wrote:

Hi,

I am a brand new user of R and I am trying to use the gam procedure with the 
package mgcv. I did a bit of my homework by consulting the R-manual, as well as 
the mgcv manual written by Simon Wood. I admit it was just a few hours, but 
what I am trying to do is really basic. Essentially, what I am trying to do is 
to generate the fitted values after the execution of the gam procedure and 
export them into Excel.

Here is my program:

ABC<- read.table("Incidence Data.csv", header=TRUE, sep=",")


probably the next three lines can be omitted if you just say:

fit <- gam(incidence~te(age,birthyear), data=ABC, family=poisson, fit=TRUE)



incidence<- ABC[,1]
age<- ABC[,2]
birthyear<- ABC[,3]
fit<-gam(incidence~te(age,birthyear), family=poisson, fit=TRUE)




All this works. Now, how can I see the fitted values and copy them back to 
Excel?



As for most fitted models, you can get

Fitted values:

  predict(fit)

Coefficients:

 coef(fit)

etc.


Uwe Ligges




Thank you very much,

Zsolt

[[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] Adding legend to heatmap

2011-05-11 Thread Uwe Ligges

See ?legend and
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html and provide commented, 
minimal, self-contained, reproducible code.


Uwe Ligges




On 11.05.2011 16:23, rugma gopakumar wrote:

Hello,

  Myself Rugma Gopakumar.I would like to know how to add a legend to
a heatmap..



Regards,

Rugma Gopakumar.

[[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] issue with graph package in using RBGL -‘'graph' is not a valid installed package’"

2011-05-11 Thread Uwe Ligges



On 11.05.2011 16:51, joe j wrote:

Dear all,

I am trying to run the function "lambdaSets" using the package "RBGL".
This package uses another package "graph" which has been removed from
the CRAN repository, but is available at the archive
(http://cran.r-project.org/src/contrib/Archive/graph/).



They are removed in order not to double host them. In the first place, 
both are BioConductor packages and you can get them using 
install.packages(c("graph", RBGL"), dependencies=TRUE)) after 
chooseBioCmirror() and setRepositories().






I installed the package from the R menu at "install packages from
local zip files" (after downloading the "graph_1.30.0.tar.gz" file,
unzipping it and making it a zip file; gz is not recognized by R.). I
get no warning here so I assumed installation went well. However, when
I type "require(RBGL)" I get the error message that: "Failed with
error:  ‘'graph' is not a valid installed package’".


You downloaded the source package (in a tar.gz file) but used the 
mechanism to install a binary package (in a zip file). Either learn how 
to install from sources (see manual R Installation and Administration) 
or use BioConductor mirrors.


Uwe Ligges



I am using R version 2.12.2 (2011-2-25). I am a new user so your
advice would be of great help.

Best wishes,
Joe

__
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] issue with graph package in using RBGL -‘'graph' is not a valid installed package’"

2011-05-11 Thread Duncan Murdoch

On 11/05/2011 10:51 AM, joe j wrote:

Dear all,

I am trying to run the function "lambdaSets" using the package "RBGL".
This package uses another package "graph" which has been removed from
the CRAN repository, but is available at the archive
(http://cran.r-project.org/src/contrib/Archive/graph/).

I installed the package from the R menu at "install packages from
local zip files" (after downloading the "graph_1.30.0.tar.gz" file,
unzipping it and making it a zip file; gz is not recognized by R.). I
get no warning here so I assumed installation went well. However, when
I type "require(RBGL)" I get the error message that: "Failed with
error:  ‘'graph' is not a valid installed package’".


Installing a package is not that simple.  R does various processing when 
taking the source tar.gz file and producing the binary image that it 
puts in the .zip.  You would need to run


R CMD INSTALL graph_1.30.0.tar.gz

to do the install, but you probably don't have the tools installed to 
get this to work.


However, graph is available on the Bioconductor web site, so if you 
select "BioC software" as a repository selection, the regular menu entry 
for installing packages should work.  I just tested it on Windows, which 
I assume you're using (since other platforms don't use .zip).


Duncan Murdoch

I am using R version 2.12.2 (2011-2-25). I am a new user so your
advice would be of great help.

Best wishes,
Joe

__
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] ddply with mean and max...

2011-05-11 Thread Scott Chamberlain
How about this:

ddply(test.set, .(site), colwise(max))
On Wednesday, May 11, 2011 at 11:46 AM, Justin wrote: 
> test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
> means<-ddply(test.set,.(site),mean)
> means 


[[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] Uploading CSV file into R

2011-05-11 Thread peter dalgaard

On May 11, 2011, at 18:54 , Me wrote:

> Hi, I'm trying to upload two CSV files into R,

What kind of misconception leads you to consider a simple read operation as an 
"upload", I wonder.

> and I'm having some trouble.
> I've used the instructions I've found on the Web, but they haven't helped so
> far.

Not very informative.

> I'm worried this could be because I'm using a Mac.

Not likely, so am I 

> 
> The two data sets are here:
> http://data.un.org/Data.aspx?d=WDI&f=Indicator_Code%3aNY.GNP.PCAP.PP.CD
> http://data.un.org/Data.aspx?d=UNODC&f=tableCode%3a1
> 

> 
> DD <- read.csv("Downloads/UNdata_Export_20110511_130705015.csv")
> summary(DD)
   Country.or.Area  Year  Value   Value.Footnotes
 Algeria   :  29   Min.   :1980   Min.   :  180   Mode:logical   
 Argentina :  29   1st Qu.:1988   1st Qu.: 1282   NA's:5050  
 Australia :  29   Median :1995   Median : 3645  
 Austria   :  29   Mean   :1995   Mean   : 7517  
 Bangladesh:  29   3rd Qu.:2002   3rd Qu.: 9825  
 Belgium   :  29   Max.   :2008   Max.   :65050  
 (Other)   :4876 
> 




> Thanks for your help. Let me know if you need more information.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] Uploading CSV file into R

2011-05-11 Thread David Winsemius



On May 11, 2011, at 12:54 PM, Me wrote:


Hi, I'm trying to upload two CSV files into R,


Those are not csv files. They are webpages with query interfaces. They  
present the option of downloading the data as zipped files in various  
formats.




and I'm having some trouble.
I've used the instructions I've found on the Web, but they haven't  
helped so

far. I'm worried this could be because I'm using a Mac.

The two data sets are here:
http://data.un.org/Data.aspx?d=WDI&f=Indicator_Code 
%3aNY.GNP.PCAP.PP.CD

http://data.un.org/Data.aspx?d=UNODC&f=tableCode%3a1

Thanks for your help. Let me know if you need more information.

--
View this message in context: 
http://r.789695.n4.nabble.com/Uploading-CSV-file-into-R-tp3515237p3515237.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.


David Winsemius, MD
West Hartford, CT

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


Re: [R] ddply with mean and max...

2011-05-11 Thread Justin
Scott Chamberlain  gmail.com> writes:

> 
> How about this:
> 
> ddply(test.set, .(site), colwise(max))
> On Wednesday, May 11, 2011 at 11:46 AM, Justin wrote: 
> > test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
> > means<-ddply(test.set,.(site),mean)
> > means 
> 
>   [[alternative HTML version deleted]]
> 
> 

Thats the ticket!  So mean is already set up to operate on columns but max and
min are not?  I guess its not too important now I know ... but whats going on in
the background that makes that happen?

__
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] hierarchical clustering within a size limit

2011-05-11 Thread rna seq
Hello List,

I am trying to implement a hierarchical cluster using the hclust method
agglomerative single linkage method with a small wrinkle. I would like to
cluster a set of numbers on a number line only if they are within a distance
of 500. I would then like to print out the members of this list.

So far I can put a vector:
> x<-c(2,10,200,300,600,700)
into a distance matrix:
> dist(x,method="manhattan")
1   2   3   4   5
2   8
3 198 190
4 298 290 100
5 598 590 400 300
6 698 690 500 400 100

I can then cluster these distances using:
>hc<-hclust(v, method = "complete")

Next, I "believe" I set my distance limit in the cluster using the command

>cutree(hc, h=500)
1 1 1 1 2 2 1 3
[1] 1 1 1 1 2 2

This seems to produce the correct result however, whatt I am unable to do is
go back and extract and print out the members of each cluster. Any herp
would be greatly appreciated.

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] ddply with mean and max...

2011-05-11 Thread Dennis Murphy
Hi:

Try this:

test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
str(test.set)
'data.frame':   100 obs. of  3 variables:
 $ site: int  1 2 3 4 5 6 7 8 9 10 ...
 $ x   : int  403 10 -74327032 10380982 -951011855 1368411171
-390937486 -1081698620 -812257145 -1354214307 ...
 $ y   : num  -0.414 -0.851 -1.67 -0.315 1.934 ...

# It's easier to use numcolwise() if the grouping variables are not numeric,
# so change site to be a factor variable:
> test.set$site <- factor(test.set$site)
> ddply(test.set, .(site), numcolwise(mean))
   site  x   y
1 1 -207083133 -0.01895802
2 2  321488067  0.19581351
3 3   46121295 -0.41734140
4 4  321915795 -0.08254519
5 5 -416497845 -0.10543154
6 6  -27745056 -0.38855565
7 7  515863199 -0.54731714
8 8  412917654  0.05438913
9 9 -327132515  0.26896930
10   10   74689545 -0.45381880
> ddply(test.set, .(site), numcolwise(max))
   site  x y
1 1 1997725565 0.8473888
2 2 2018830674 1.6600380
3 3 1909893732 2.4445523
4 4 1365543339 1.3697428
5 5 1688291226 2.2145275
6 6 1368411171 1.5141589
7 7 1974894876 1.2868469
8 8 2054615743 0.7917823
9 9 1091060578 2.4678820
10   10 2055409475 2.4488190
> ddply(test.set, .(site), numcolwise(min))



I imagine you'd want to put all this together, so an easier way in
ddply() is to create a function that reads a data frame and outputs a
data frame, as follows:

f <- function(d) data.frame(mean.x = mean(d$x), mean.y = mean(d$y),
min.x = min(d$x), min.y = min(d$y),
max.x = max(d$x), max.y = max(d$y))
ddply(test.set, .(site), f)

In this case, aggregate() would be a little bit simpler (R-2.11.0 +):

aggregate(cbind(x, y) ~ site, data = test.set,
  FUN = function(x) c(mean = mean(x), min = min(x), max = max(x)))

On Wed, May 11, 2011 at 9:46 AM, Justin  wrote:
> I'm trying to use ddply to compute summary statistics for many variables
> splitting on the variable site.  however, it seems to work fine for mean() but
> if i use max() or min() things fall apart.  whats going on?
>

The problem in your code is that you don't specify to what the
mean/min/max is supposed to refer.

HTH,
Dennis

>  test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
>  means<-ddply(test.set,.(site),mean)
>  means
>   site          x           y
> 1     1  -97459496 -0.14826303
> 2     2 -150246922 -0.29279556
> 3     3  471813178  0.13090210
> 4     4 -655451621  0.07908207
> 5     5 -229505843  0.10239588
> 6     6 -667025397 -0.34930275
> 7     7  510041943  0.20547460
> 8     8  270993292 -0.63658199
> 9     9  264989314  0.09695455
> 10   10 -199965142 -0.07202699
>  maxes<-ddply(test.set,.(site),max)
>  maxes
>   site         V1
> 1     1 1942437227
> 2     2 2066224792
> 3     3 2146619846
> 4     4 1381954134
> 5     5 1802867123
> 6     6 1786627153
> 7     7 1951106534
> 8     8 1498358582
> 9     9 2022046126
> 10   10 1670904926
>
> Can you all shed some light on this? I'm stumped!
>
> Thanks,
> Justin
>
> __
> 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] ddply with mean and max...

2011-05-11 Thread Scott Chamberlain
That's beyond my knowledge of plyr...S
On Wednesday, May 11, 2011 at 12:31 PM, Justin wrote: 
> Scott Chamberlain  gmail.com> writes:
> 
> > 
> > How about this:
> > 
> > ddply(test.set, .(site), colwise(max))
> > On Wednesday, May 11, 2011 at 11:46 AM, Justin wrote: 
> > > test.set<-data.frame(site=1:10,x=.Random.seed[1:100],y=rnorm(100))
> > > means<-ddply(test.set,.(site),mean)
> > > means 
> > 
> >  [[alternative HTML version deleted]]
> 
> Thats the ticket! So mean is already set up to operate on columns but max and
> min are not? I guess its not too important now I know ... but whats going on 
> in
> the background that makes that happen?
> 
> __
> 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] hierarchical clustering within a size limit

2011-05-11 Thread Peter Langfelder
On Wed, May 11, 2011 at 10:12 AM, rna seq  wrote:
> Hello List,
>
> I am trying to implement a hierarchical cluster using the hclust method
> agglomerative single linkage method with a small wrinkle. I would like to
> cluster a set of numbers on a number line only if they are within a distance
> of 500. I would then like to print out the members of this list.
>
> So far I can put a vector:
>> x<-c(2,10,200,300,600,700)
> into a distance matrix:
>> dist(x,method="manhattan")
>    1   2   3   4   5
> 2   8
> 3 198 190
> 4 298 290 100
> 5 598 590 400 300
> 6 698 690 500 400 100
>
> I can then cluster these distances using:
>>hc<-hclust(v, method = "complete")
>
> Next, I "believe" I set my distance limit in the cluster using the command
>
>>cutree(hc, h=500)
> 1 1 1 1 2 2 1 3
> [1] 1 1 1 1 2 2
>
> This seems to produce the correct result however, whatt I am unable to do is
> go back and extract and print out the members of each cluster. Any herp
> would be greatly appreciated.

Very simple.

labels = cutree(hc, h=500)
# members of cluster 1:
x[labels==1]
# members of cluster 2:
x[labels==2]

HTH,

Peter

__
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] ddply with mean and max...

2011-05-11 Thread Hadley Wickham
> Thats the ticket!  So mean is already set up to operate on columns but max and
> min are not?  I guess its not too important now I know ... but whats going on 
> in
> the background that makes that happen?

Basically, this:

> mean.data.frame
function (x, ...)
sapply(x, mean, ...)

> min.data.frame
Error: object 'min.data.frame' not found

There was some discussion on r-devel recently about removing
mean.data.frame to be consistent with the other summary functions
(plus the way it's currently written makes it prone to problems)

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] Reordering inputs

2011-05-11 Thread Dat Mai
Hello All,

I have 2 matrices consisting of the same inputs, but having different
outputs. I created a heatmap for both of them; the point is to compare them
side by side. The best way to organize the inputs is to make sure that the
order of the inputs are the same for both heatmaps. How would I go about
making sure that the order of inputs of both heatmaps are the same?

As it is right now, I can only control the the order of the inputs by using
the decreasing=TRUE/FALSE function, but that only serves to reorder the
matrix by the output values.

-- 
Best,
Dat Mai
PhD Rotation Student
Albert Einstein College of Medicine

[[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 with contrasts

2011-05-11 Thread Guelman, Leo
Or alternatively (though very similar to Peter's idea) you can do

ci <- contrasts
formals(ci)$contrasts <- FALSE
dd <- data.frame(a = gl(3,4), b = gl(4,1,12))
mm <- model.matrix(~ a + b, dd, contrasts = list(a=ci(dd$a),
b=ci(dd$b))) 

Best,
Leo.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of peter dalgaard
Sent: 2011, May, 11 7:31 AM
To: Lars Bishop
Cc: R-help@r-project.org Help
Subject: Re: [R] Help with contrasts


On May 11, 2011, at 12:51 , Lars Bishop wrote:

> Hi,
> 
> I need to build a function to generate one column for each level of a 
> factor in the model matrix created on an arbitrary formula (instead of

> using the available contrasts options such as contr.treatment,
contr.SAS, etc).
> 
> My approach to this was first to use the built-in function for 
> contr.treatment but changing the default value of the contrasts 
> argument to FALSE (I named this function "contr.identity" and it shown

> at the bottom of the email for reference).
> 
> So this function works fine,
> 
>> contr.identity(4)
> 
>  1 2 3 4
> 1 1 0 0 0
> 2 0 1 0 0
> 3 0 0 1 0
> 4 0 0 0 1
> 
>> contr.treatment(4)
>  2 3 4
> 1 0 0 0
> 2 1 0 0
> 3 0 1 0
> 4 0 0 1
> 
> However, when I try to create a model matrix using contr.identity 
> specified in options(), it actually uses the contr.treatment option. 
> Why is that? Any hint on how can I do this?


It's not actually using contr.treatment, it's just calling
contr.identity with contrasts=TRUE...

I don't think there's a painless way to avoid this. The closest I can
think of is

cI <- contr.treatment
formals(cI)$contrasts <- FALSE
dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) model.matrix(~ C(a,cI,3) +
C(b,cI,4), dd)



--
Peter Dalgaard
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000
Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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.
___

This e-mail may be privileged and/or confidential, and the sender does not waive
any related rights and obligations. Any distribution, use or copying of this 
e-mail or the information
it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or 
otherwise) immediately.

Ce courriel peut contenir des renseignements protégés et confidentiels.
L’expéditeur ne renonce pas aux droits et obligations qui s’y rapportent.
Toute diffusion, utilisation ou copie de ce courriel ou des renseignements 
qu’il contient
par une personne autre que le destinataire désigné est interdite.
Si vous recevez ce courriel par erreur, veuillez m’en aviser immédiatement, 
par retour de courriel ou par un autre moyen.
__
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] sample weights in ols

2011-05-11 Thread Thomas Lumley
On Thu, May 12, 2011 at 2:43 AM, jour4life  wrote:
> I have a follow up question. When using svyglm, it does not matter that I am
> not using survey design and only weights?
> In other words,
>
> fit<-svyglm(y~x1+x2+...xk,data=dataset,weights=weightvariable)
>
> Or am I going to have to construct a survey design variable, using only the
> weight variable?

You will have to construct a survey design.  It's not difficult.

my.first.survey.design <- svydesign(id=~1, weights=~weightvariable,
data=dataset)

fit<-svyglm(y~x1+x2+...xk, design=my.first.survey.design)

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

__
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] Cumsum in Lattice Panel Function

2011-05-11 Thread Elliot Joel Bernstein
That worked perfectly. Thanks!

- Elliot

On Mon, May 09, 2011 at 12:20:36AM +0530, Deepayan Sarkar wrote:
> On Fri, May 6, 2011 at 9:24 PM, Elliot Joel Bernstein
>  wrote:
> > I'm trying to create an xyplot with a "groups" argument where the y-variable
> > is the cumsum of the values stored in the input data frame. I almost have
> > it, but I can't get it to automatically adjust the y-axis scale. How do I
> > get the y-axis to automatically scale as it would have if the cumsum values
> > had been stored in the data frame?
> >
> > Here is the code I have so far:
> >
> > require(lattice)
> >
> >
> >
> > dates <- seq(as.Date("2011-01-01"), as.Date("2011-04-30"), "days")
> > g <- 1:3
> >
> >
> > dat <- data.frame(date = rep(dates, length(g)),
> >                  group = rep(g, each = length(dates)),
> >                  value = rnorm(length(dates)*length(g)) + 0.05)
> >
> >
> > xyplot(value ~ date, data = dat, group = group, type = 'l', grid = TRUE,
> >       panel = panel.superpose,
> >       panel.groups = function(x, y, ...) { panel.xyplot(x, cumsum(y), ...)
> > })
> >
> >
> > I want the result to look the same as if I had done
> >
> > dat$cumvalue <- with(dat, unsplit(lapply(split(value, group), cumsum),
> > group))
> > xyplot(cumvalue ~ date, data = dat, group = group, type = 'l', grid = TRUE)
> 
> You need something along the lines of
> 
> xyplot(value ~ date, data = dat, group = group, type = 'l', grid = TRUE,
>panel = panel.superpose,
>panel.groups = function(x, y, ...) {
>panel.xyplot(x, cumsum(y), ...)
>},
>prepanel = function(x, y, groups, ...) {
>yy <- unlist(tapply(y, groups, cumsum))
>list(ylim = range(yy, finite = TRUE))
>})
> 
> -Deepayan

-- 
Elliot Joel Bernstein, Ph.D. | Research Associate | FDO Partners, LLC
134 Mount Auburn Street | Cambridge, MA | 02138
Phone: (617) 503-4619 | Email: elliot.bernst...@fdopartners.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] Problem with constrained optimization with maxBFGS

2011-05-11 Thread Leonardo Monasterio
Dear all,

I need to maximize the v:

 v= D' W D


D is a column vector ( n , 1)
W is a given matrix (n, n)

subject to:
 sum D= 1

(BTW, n is less than 300)
I´ve tried to use maxBFGS, as follows:

#
objectiveFunction<-function(x)
{
  return(t(D)%*%W%*%D)
}

Amat<-diag(nrow(D))
Amat<-rbind((rep(-1, nrow(D))), Amat)
bvec<-matrix( c(0), nrow(D)+1, 1)
bvec[1,1]<-c(1)
startValues=rep(1/nrow(D),nrow(D)) #Istart value is homogeneous distribution
res <<- maxBFGS(objectiveFunction, start=startValues,
constraints=list(ineqA=Amat, ineqB=bvec))

The outcome is equal to the startValues. I´ve tried several initial values
and nothing changes.
Please, what am I doing wrong? Any suggestion?

Thanks a lot!

Leo.

[[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] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread Greg Snow
Just to add to what David already said, you might want to look at the 
Predict.Plot and TkPredict functions in the TeachingDemos package for a simple 
interface for visualizing predicted values in regression models.

These plots are much more informative than a single number trying to capture 
total effect.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of David Winsemius
> Sent: Wednesday, May 11, 2011 7:48 AM
> To: Michael Haenlein
> Cc: r-help@r-project.org
> Subject: Re: [R] Total effect of X on Y under presence of interaction
> effects
> 
> 
> On May 11, 2011, at 4:26 AM, Michael Haenlein wrote:
> 
> > Dear all,
> >
> > this is probably more a statistics question than an R question but
> > probably
> > there is somebody who can help me nevertheless.
> >
> > I'm running a regression with four predictors (a, b, c, d) and all
> > their
> > interaction effects using lm. Based on theory I assume that a
> > influences y
> > positively. In my output (see below) I see, however, a negative
> > regression
> > coefficient for a. But several of the interaction effects of a with
> > b, c and
> > d have positive signs. I don't really understand this. Do I have to
> > add up
> > the coefficient for the main effect and the ones of all interaction
> > effects
> > to get a total effect of a on y? Or am I doing something wrong here?
> 
> In the presence of interactions there is little point in attempting to
> assign meaning to individual coefficients. You need to use predict()
> (possibly with graphical or tabular displays) and produce estimates of
> one or two variable at relevant levels of  the other variables.
> 
> The other aspect about which your model is not informative, is the
> possibility that some of these predictors have non-linear associations
> with `y`.
> 
> (The coefficient for `a` examined in isolation might apply to a group
> of subjects (or other units of analysis) in which the values of `b`,
> `c`, and `d` were all held at zero. Is that even a situation that
> would occur in your domain of investigation?)
> 
> --
> David.
> >
> > Thanks very much for your answer in advance,
> >
> > Regards,
> >
> > Michael
> >
> >
> > Michael Haenlein
> > Associate Professor of Marketing
> > ESCP Europe
> > Paris, France
> >
> >
> >
> > Call:
> > lm(formula = y ~ a * b * c * d)
> >
> > Residuals:
> >Min  1Q  Median  3Q Max
> > -44.919  -5.184   0.294   5.232 115.984
> >
> > Coefficients:
> >Estimate Std. Error t value Pr(>|t|)
> > (Intercept)  27.3067 0.8181  33.379  < 2e-16 ***
> > a   -11.0524 2.0602  -5.365 8.25e-08 ***
> > b-2.5950 0.4287  -6.053 1.47e-09 ***
> > c   -22.0025 2.8833  -7.631 2.50e-14 ***
> > d20.5037 0.3189  64.292  < 2e-16 ***
> > a:b  15.1411 1.1862  12.764  < 2e-16 ***
> > a:c  26.8415 7.2484   3.703 0.000214 ***
> > b:c   8.3127 1.5080   5.512 3.61e-08 ***
> > a:d   6.6221 0.8061   8.215 2.33e-16 ***
> > b:d  -2.0449 0.1629 -12.550  < 2e-16 ***
> > c:d  10.0454 1.1506   8.731  < 2e-16 ***
> > a:b:c 1.4137 4.1579   0.340 0.733862
> > a:b:d-6.1547 0.4572 -13.463  < 2e-16 ***
> > a:c:d   -20.6848 2.8832  -7.174 7.69e-13 ***
> > b:c:d-3.4864 0.6041  -5.772 8.05e-09 ***
> > a:b:c:d   5.6184 1.6539   3.397 0.000683 ***
> > ---
> > Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> >
> > Residual standard error: 7.913 on 12272 degrees of freedom
> > Multiple R-squared: 0.8845, Adjusted R-squared: 0.8844
> > F-statistic:  6267 on 15 and 12272 DF,  p-value: < 2.2e-16
> >
> > [[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, MD
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-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] displaying derived coefficients in lm

2011-05-11 Thread Greg Snow
Look at the dummy.coef function.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of James Lawrence
> Sent: Wednesday, May 11, 2011 5:43 AM
> To: r-help@r-project.org
> Subject: [R] displaying derived coefficients in lm
> 
> Hello R-help,
> 
> Is there a way to get R to tell you the coefficients in a lm that it
> wouldn't normally tell you because of identifiability constraints? For
> instance, if you use contr.sum() to generate contrasts for a factor,
> say
> 
> ## y <- some data
> ## x <- a factor with levels 1:6
> contrasts(x) <- contr.sum(levels(x))
> lm.1 <- lm(y ~ x)
> 
> how would one persuade summary.lm to give the coefficient for x6 as
> well
> as x1 up to x5? I know in this case that x6 is minus the sum of x1 to
> x5, but I am working on a problem where the constraints are very
> complicated and it would be a real help to see all the coefficients.
> 
> Thanks in advance
> 
> James Lawrence.
> 
> __
> 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] Reordering inputs

2011-05-11 Thread Carl Witthoft
Matrices just *are* . They don't have inputs or outputs.  Can you 
provide an example of what you are trying to do?




From: Dat Mai 
Date: Wed, 11 May 2011 19:43:23 +


Hello All,

I have 2 matrices consisting of the same inputs, but having different 
outputs. I created a heatmap for both of them; the point is to compare 
them side by side. The best way to organize the inputs is to make sure 
that the order of the inputs are the same for both heatmaps. How would I 
go about making sure that the order of inputs of both heatmaps are the same?


As it is right now, I can only control the the order of the inputs by 
using the decreasing=TRUE/FALSE function, but that only serves to 
reorder the matrix by the output values.





__
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] foreach(): how to do calculations "between" two foreach loops?

2011-05-11 Thread Marius Hofert
Dear expeRts,

is it possible to carry out calculations between different foreach() calls? 
As for nested loops, you want to carry out calcuations not depending on the 
inner
loop only once and not for each iteration of the innermost loop.

Cheers,

Marius


library(foreach)

foreach(i=1:3) %:% 
foreach(j=1:2) %do% {
i <- i+1 
print(paste(i,j))
}

foreach(i=1:3) %:% 
i <- i+1 # lengthy calculation which has to be done only once, not for each 
j 
foreach(j=1:2) %do% {
print(paste(i,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] selecting data from table with timestamp

2011-05-11 Thread Pablo Rosado
Hi,
I am using read.table to get this data that has a timestamp.  The data is
for many days, but I only want to run the code I wrote only for specific
day/days/times.  I can´t figure out how to select a timeframe from the
list.
I have tried using subset() and didn't work

I then used:
* timestamp[for(timestamp==as.character("2011-03-15 00:00:00" )  |
timestamp==as.character("2011-03-15 00:01:30"))]*
but it gives me the list of the timestamp for that interval, but I want the
complete data.table for that interval, not just the values of the TIMESTAMP
column.

Here is the script I use to read the table and select the timestamp
interval:

*full <- read.table("March_15.dat", sep=",",row.names=NULL, as.is=TRUE,skip=1,
header=TRUE)
minusrows <- full[-1:-2,]
names(minusrows)
timestamp <- minusrows[,1]
timestamp3 <- timestamp[for(timestamp==as.character("2011-03-15 00:00:00" )
| timestamp==as.character("2011-03-15 00:01:30"))]
timestamp3*

An example of what minusrows look like:
*
> minusrows[1:5,1:4]
TIMESTAMP RECORD Batt_Volt_Avg attic.air_temp_cool_north
3 2011-03-15 00:00:00  0 13.35 17.99
4 2011-03-15 00:00:30  1 13.35 18.00
5 2011-03-15 00:01:00  2 13.35 17.98
6 2011-03-15 00:01:30  3 13.35 17.99
7 2011-03-15 00:02:00  4 13.35 17.97*

Thank You so much for your help and time,


-- 
*Pablo J. Rosado*, *Ph.D. Student*
*Graduate Student Researcher Assistant*
*University of California - Berkeley*

[[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] pass character vector in instrument field of get.hist.quote function

2011-05-11 Thread MatAra
Hello gentlemen,

This is a great discussion. Thank you all for providing useful answers. 
I am also new to R, was working mostly with SAS before, and have a question
regarding passing arguments to R functions that are wrapped in quotes.

Using the previous example: 
getSymbols(tickers, from="start", to="end") 

Given that "start/end" are quoted, how can I pass a date xx-xx- to R
when I am invoking a custom function, like:

flex<- (start, end){ 
getSymbols(tickers, from="start", to="end") 
}
flex(xx-xx-,xx-xx-)  

I have tried different combinations but I haven't been able to pass the
correct date, R simply doesn't capture the value. The same issue was
happening with tickers, although there is a way around the issue, the
original problem remainspassing an argument that's quoted in the
function.

Any help would be greatly appreciated!
Cheers!



--
View this message in context: 
http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3515936.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] Line feed for a long character string

2011-05-11 Thread Lisa
Dear all,

Does anyone know how to make a line feed automatically based on the width of
console window? For example, when you cat() a long character string just
like this:

cat("Seminar series is an opportunity for students to learn about ongoing
researches in the field of mathematics, computer science, physics,
chemistry, and some other related programs. Students must complete a seminar
attendance form and return to their mentors.\n")

In my computer, about half of the string is displayed with a symbol “$”at
the end that looks like this:

> cat("Seminar series is an opportunity for students to learn about ongoing
> researches in the field of mathematics, computer science, physics,
> chemistry, a$

Any help will be appreciated!

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-feed-for-a-long-character-string-tp3515824p3515824.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] mtext text size (cex) doesn't match plot

2011-05-11 Thread George Locke
Hi,

I am using mtext instead of the ylab argument in some plots because i
want to move it away from the numbers in the axis.  However, the text
in the X axis,

for example:
par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

This works fine, but if I then set

par(mfrow=c(3,2));

the text produced by mtext becomes much larger than the text "X axis"
produced by plot, despite their having identical cex specifications.
In this case, the words "Y axis" become much larger than "plot name".
Note that without par(mfrow) the size of "X axis" and "Y axis" match
iff their cex(.lab) arguments match.

How can I make mtext produce text that exactly matches the xlab?  In
my limited experience fiddling around with this problem, the size of
the mtext does not depend on par(mfrow), whereas the size of the xlab
does, so if there were a formula that relates the actual size of text,
cex argument, and par(mfrow), then I could use that to attenuate the
cex argument of mtext.  Any solution will do, so long as it maintains
the relative sizes of the plot and the three text fields (main, x axis
label, y axis label).


example code to demonstrate the problem is below.

Thanks!

data = c(1:10);
par(mfrow=c(3,2));

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

par(mar=c(5, 5.5, 4, 2));
plot(data, main="plot name", xlab= 'X axis', ylab="",
 font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
mtext('Y axis', side=2, cex=1.5, line=4, font=2);

__
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] issue with graph package in using RBGL -‘'graph' is not a valid installed package’"

2011-05-11 Thread joe j
Thank you very much Dan, Uwe and Duncan. First suggestion by Dan
itself worked so I didn't have to try the other ones. But those
suggestions and comments are of much value and are appreciated.

Regards,
Joe

On Wed, May 11, 2011 at 7:14 PM, Duncan Murdoch
 wrote:
> On 11/05/2011 10:51 AM, joe j wrote:
>>
>> Dear all,
>>
>> I am trying to run the function "lambdaSets" using the package "RBGL".
>> This package uses another package "graph" which has been removed from
>> the CRAN repository, but is available at the archive
>> (http://cran.r-project.org/src/contrib/Archive/graph/).
>>
>> I installed the package from the R menu at "install packages from
>> local zip files" (after downloading the "graph_1.30.0.tar.gz" file,
>> unzipping it and making it a zip file; gz is not recognized by R.). I
>> get no warning here so I assumed installation went well. However, when
>> I type "require(RBGL)" I get the error message that: "Failed with
>> error:  ‘'graph' is not a valid installed package’".
>
> Installing a package is not that simple.  R does various processing when
> taking the source tar.gz file and producing the binary image that it puts in
> the .zip.  You would need to run
>
> R CMD INSTALL graph_1.30.0.tar.gz
>
> to do the install, but you probably don't have the tools installed to get
> this to work.
>
> However, graph is available on the Bioconductor web site, so if you select
> "BioC software" as a repository selection, the regular menu entry for
> installing packages should work.  I just tested it on Windows, which I
> assume you're using (since other platforms don't use .zip).
>
> Duncan Murdoch
>>
>> I am using R version 2.12.2 (2011-2-25). I am a new user so your
>> advice would be of great help.
>>
>> Best wishes,
>> Joe
>>
>> __
>> 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] Reordering inputs

2011-05-11 Thread Steven Kennedy
You can order each matrix by any column you choose like:

a<-matrix(rnorm(20),ncol=2)
> a[order(a[,1]),] #orders by column 1
 [,1]   [,2]
 [1,] -1.86523489 -1.6920270
 [2,] -0.94488744  0.2815087
 [3,]  0.02380494  0.2491136
 [4,]  0.37295795  0.8156993
 [5,]  0.55533366 -0.7053233
 [6,]  0.79799294 -0.8224082
 [7,]  0.80497452  0.4260842
 [8,]  1.12438976 -0.1567863
 [9,]  1.29213037 -1.6783762
[10,]  1.33496542  0.7807943

__
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] Line feed for a long character string

2011-05-11 Thread Duncan Murdoch

On 11/05/2011 4:46 PM, Lisa wrote:

Dear all,

Does anyone know how to make a line feed automatically based on the width of
console window? For example, when you cat() a long character string just
like this:


You can use the strwrap() function to insert line breaks.  If it's not 
under your control, and the function you're using tries to print 
something wider than the console, what happens depends on what console 
you're using.  The Windows Rgui does what you describe.  Windows Rterm 
will send all the characters, and cmd.exe or whatever shell you're using 
will probably insert breaks when it hits the end of the line.


Duncan Murdoch


cat("Seminar series is an opportunity for students to learn about ongoing
researches in the field of mathematics, computer science, physics,
chemistry, and some other related programs. Students must complete a seminar
attendance form and return to their mentors.\n")

In my computer, about half of the string is displayed with a symbol “$”at
the end that looks like this:


cat("Seminar series is an opportunity for students to learn about ongoing
researches in the field of mathematics, computer science, physics,
chemistry, a$


Any help will be appreciated!

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-feed-for-a-long-character-string-tp3515824p3515824.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.


Re: [R] R versions for Red Hat Linux

2011-05-11 Thread Shi, Tao
I second Marc on this.  I just installed R2.12.2 on my linux box running RHEL.  
Now I also see R2.13.0 available by typing "yum info R".

...Tao




- Original Message 
> From: Marc Schwartz 
> To: Marta Avalos 
> Cc: r-help@r-project.org
> Sent: Wed, May 11, 2011 10:08:00 AM
> Subject: Re: [R] R versions for Red Hat Linux
> 
> On May 11, 2011, at 10:12 AM, Marta Avalos wrote:
> 
> > Dear all,
> >  The latest R version available for Red Hat Linux is 2.10 (from November 
> >  2009), whereas the latest version available for Debian, Suse or Ubuntu 
> > Linux 
>
> > is 2.13 (from May 2011). 
> > Has someone some information about  the development/release of new R 
> > versions 
>
> > for Red Hat?
> > 
> >  Thank you in advance,
> > Marta 
> 
> 
> R for RHEL based Linux  distributions has been available for some time via 
> the 
>EPEL:
> 
>http://fedoraproject.org/wiki/EPEL
> 
> You can review the instructions there  for configuring your system to use the 
>EPEL and then use 'yum' to install  R:
> 
>   sudo yum install R
> 
> If by Red Hat, you are actually  referring to Fedora, R is available via the 
>regular Fedora repos. Just use the  same command line incantation as above.
> 
> Also, just an FYI that there is a  R-SIG-Fedora list, which focused on RH and 
>Fedora specific issues. More info  at:
> 
>   https://stat.ethz.ch/mailman/listinfo/r-sig-fedora
> 
> HTH,
> 
> Marc  Schwartz
> 
> __
> 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] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread Matthew Keller
Not to rehash an old statistical argument, but I think David's reply
here is too strong ("In the presence of interactions there is little
point in attempting to assign meaning to individual coefficients.").
As David notes, the "simple effect" of your coefficients (e.g., a) has
an interpretation: it is the predicted effect of a when b, c, and d
are zero. If the zero-level of b, c, and d are meaningful (e.g., if
you have centered all your variables such that the mean of each one is
zero), then the coefficient of a is the predicted slope of a at the
mean level of all other predictors...

Matt



On Wed, May 11, 2011 at 2:40 PM, Greg Snow  wrote:
> Just to add to what David already said, you might want to look at the 
> Predict.Plot and TkPredict functions in the TeachingDemos package for a 
> simple interface for visualizing predicted values in regression models.
>
> These plots are much more informative than a single number trying to capture 
> total effect.
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of David Winsemius
>> Sent: Wednesday, May 11, 2011 7:48 AM
>> To: Michael Haenlein
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Total effect of X on Y under presence of interaction
>> effects
>>
>>
>> On May 11, 2011, at 4:26 AM, Michael Haenlein wrote:
>>
>> > Dear all,
>> >
>> > this is probably more a statistics question than an R question but
>> > probably
>> > there is somebody who can help me nevertheless.
>> >
>> > I'm running a regression with four predictors (a, b, c, d) and all
>> > their
>> > interaction effects using lm. Based on theory I assume that a
>> > influences y
>> > positively. In my output (see below) I see, however, a negative
>> > regression
>> > coefficient for a. But several of the interaction effects of a with
>> > b, c and
>> > d have positive signs. I don't really understand this. Do I have to
>> > add up
>> > the coefficient for the main effect and the ones of all interaction
>> > effects
>> > to get a total effect of a on y? Or am I doing something wrong here?
>>
>> In the presence of interactions there is little point in attempting to
>> assign meaning to individual coefficients. You need to use predict()
>> (possibly with graphical or tabular displays) and produce estimates of
>> one or two variable at relevant levels of  the other variables.
>>
>> The other aspect about which your model is not informative, is the
>> possibility that some of these predictors have non-linear associations
>> with `y`.
>>
>> (The coefficient for `a` examined in isolation might apply to a group
>> of subjects (or other units of analysis) in which the values of `b`,
>> `c`, and `d` were all held at zero. Is that even a situation that
>> would occur in your domain of investigation?)
>>
>> --
>> David.
>> >
>> > Thanks very much for your answer in advance,
>> >
>> > Regards,
>> >
>> > Michael
>> >
>> >
>> > Michael Haenlein
>> > Associate Professor of Marketing
>> > ESCP Europe
>> > Paris, France
>> >
>> >
>> >
>> > Call:
>> > lm(formula = y ~ a * b * c * d)
>> >
>> > Residuals:
>> >    Min      1Q  Median      3Q     Max
>> > -44.919  -5.184   0.294   5.232 115.984
>> >
>> > Coefficients:
>> >            Estimate Std. Error t value Pr(>|t|)
>> > (Intercept)  27.3067     0.8181  33.379  < 2e-16 ***
>> > a           -11.0524     2.0602  -5.365 8.25e-08 ***
>> > b            -2.5950     0.4287  -6.053 1.47e-09 ***
>> > c           -22.0025     2.8833  -7.631 2.50e-14 ***
>> > d            20.5037     0.3189  64.292  < 2e-16 ***
>> > a:b          15.1411     1.1862  12.764  < 2e-16 ***
>> > a:c          26.8415     7.2484   3.703 0.000214 ***
>> > b:c           8.3127     1.5080   5.512 3.61e-08 ***
>> > a:d           6.6221     0.8061   8.215 2.33e-16 ***
>> > b:d          -2.0449     0.1629 -12.550  < 2e-16 ***
>> > c:d          10.0454     1.1506   8.731  < 2e-16 ***
>> > a:b:c         1.4137     4.1579   0.340 0.733862
>> > a:b:d        -6.1547     0.4572 -13.463  < 2e-16 ***
>> > a:c:d       -20.6848     2.8832  -7.174 7.69e-13 ***
>> > b:c:d        -3.4864     0.6041  -5.772 8.05e-09 ***
>> > a:b:c:d       5.6184     1.6539   3.397 0.000683 ***
>> > ---
>> > Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>> >
>> > Residual standard error: 7.913 on 12272 degrees of freedom
>> > Multiple R-squared: 0.8845,     Adjusted R-squared: 0.8844
>> > F-statistic:  6267 on 15 and 12272 DF,  p-value: < 2.2e-16
>> >
>> >     [[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, MD
>> W

[R] changes in coxph in "survival" from older version?

2011-05-11 Thread Shi, Tao
Hi all,

I found that the two different versions of "survival" packages, namely 2.36-5 
vs. 2.36-8 or later, give different results for coxph function.  Please see 
below and the data is attached.  The second one was done on Linux, but Windows 
gave the same results.  Could you please let me know which one I should trust?

Thanks,

...Tao





# R2.13.0, survival 2.36-9 
=
> dat=read.csv("tmp1.csv", header=T)
> fit2 <- coxph(Surv(tt, cens) ~., data=dat)
Warning message:
In fitter(X, Y, strats, offset, init, control, weights = weights,  :
  Ran out of iterations and did not converge
> summary(fit2)
## the estimates are different
.
> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

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


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


other attached packages:
[1] svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2  Hmisc_3.8-3 
survival_2.36-9

loaded via a namespace (and not attached):
[1] cluster_1.13.3  grid_2.13.0 lattice_0.19-23 svMisc_0.9-61   
tools_2.13.0  

# 
=


# R2.12.2, survival 2.36-5 
=
> dat=read.csv("tmp1.csv", header=T)
> fit2 <- coxph(Surv(tt, cens) ~., data=dat)
> summary(fit2)
## the estimates are different
.
> 
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
[1] survival_2.36-5
# 
=__
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] selecting data from table with timestamp

2011-05-11 Thread MacQueen, Don
Try something similar to this:

## unchanged
full <- read.table("March_15.dat", sep=",",row.names=NULL,
as.is=TRUE,skip=1,header=TRUE)


## then convert TIMESTAMP to a date-time class
full$TIMESTAMP <- as.POSIXct(full$TIMESTAMP)

## now you can use subset()
atimeframe <- subset(full,
 TIMESTAMP >= as.POSIXct('2011-03-15 00:00:00') &
 TIMESTAMP <= as.POSIXct('2011-03-15 00:01:30')
 )

Hope this helps.

And a couple of comments on your example.

In an expression like you used,
   timestamp==as.character("2011-03-15 00:01:30")
just do
   timestamp=="2011-03-15 00:01:30"

"2011-03-15 00:01:30" is already a character string, so you don't have to
use

as.character() on it.

You used for(), but for() is used to
make loops, as in
  for (i in 1:10) { }
which has basically nothing to do with extracting a subset of rows from a
dataframe.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





-Original Message-
From: Pablo Rosado 
Date: Wed, 11 May 2011 14:21:00 -0700
To: "r-help@r-project.org" 
Subject: [R] selecting data from table with timestamp

>Hi,
>I am using read.table to get this data that has a timestamp.  The data is
>for many days, but I only want to run the code I wrote only for specific
>day/days/times.  I can´t figure out how to select a timeframe from the
>list.
>I have tried using subset() and didn't work
>
>I then used:
>* timestamp[for(timestamp==as.character("2011-03-15 00:00:00" )  |
>timestamp==as.character("2011-03-15 00:01:30"))]*
>but it gives me the list of the timestamp for that interval, but I want
>the
>complete data.table for that interval, not just the values of the
>TIMESTAMP
>column.
>
>Here is the script I use to read the table and select the timestamp
>interval:
>
>*full <- read.table("March_15.dat", sep=",",row.names=NULL,
>as.is=TRUE,skip=1,
>header=TRUE)
>minusrows <- full[-1:-2,]
>names(minusrows)
>timestamp <- minusrows[,1]
>timestamp3 <- timestamp[for(timestamp==as.character("2011-03-15 00:00:00"
>)
>| timestamp==as.character("2011-03-15 00:01:30"))]
>timestamp3*
>
>An example of what minusrows look like:
>*
>> minusrows[1:5,1:4]
>TIMESTAMP RECORD Batt_Volt_Avg attic.air_temp_cool_north
>3 2011-03-15 00:00:00  0 13.35 17.99
>4 2011-03-15 00:00:30  1 13.35 18.00
>5 2011-03-15 00:01:00  2 13.35 17.98
>6 2011-03-15 00:01:30  3 13.35 17.99
>7 2011-03-15 00:02:00  4 13.35 17.97*
>
>Thank You so much for your help and time,
>
>
>-- 
>*Pablo J. Rosado*, *Ph.D. Student*
>*Graduate Student Researcher Assistant*
>*University of California - Berkeley*
>
>   [[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] map.market - font customisation

2011-05-11 Thread Hasan Diwan
How would I go about customising the font -- colour and size -- of the
font used in portfolio's map.market function? The existing fonts are a
bit small, when embedded into a PDF using Sweave generated latex. Many
thanks!

-- 
Sent from my mobile device
Envoyait de mon telephone mobil

__
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] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread David Winsemius


On May 11, 2011, at 6:26 PM, Matthew Keller wrote:


Not to rehash an old statistical argument, but I think David's reply
here is too strong ("In the presence of interactions there is little
point in attempting to assign meaning to individual coefficients.").
As David notes, the "simple effect" of your coefficients (e.g., a) has
an interpretation: it is the predicted effect of a when b, c, and d
are zero. If the zero-level of b, c, and d are meaningful (e.g., if
you have centered all your variables such that the mean of each one is
zero), then the coefficient of a is the predicted slope of a at the
mean level of all other predictors...


And there is internal evidence that such a procedure was not performed  
in this instance. I think my advice applies here.


--
David.


Matt



On Wed, May 11, 2011 at 2:40 PM, Greg Snow   
wrote:
Just to add to what David already said, you might want to look at  
the Predict.Plot and TkPredict functions in the TeachingDemos  
package for a simple interface for visualizing predicted values in  
regression models.


These plots are much more informative than a single number trying  
to capture total effect.


--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of David Winsemius
Sent: Wednesday, May 11, 2011 7:48 AM
To: Michael Haenlein
Cc: r-help@r-project.org
Subject: Re: [R] Total effect of X on Y under presence of  
interaction

effects


On May 11, 2011, at 4:26 AM, Michael Haenlein wrote:


Dear all,

this is probably more a statistics question than an R question but
probably
there is somebody who can help me nevertheless.

I'm running a regression with four predictors (a, b, c, d) and all
their
interaction effects using lm. Based on theory I assume that a
influences y
positively. In my output (see below) I see, however, a negative
regression
coefficient for a. But several of the interaction effects of a with
b, c and
d have positive signs. I don't really understand this. Do I have to
add up
the coefficient for the main effect and the ones of all interaction
effects
to get a total effect of a on y? Or am I doing something wrong  
here?


In the presence of interactions there is little point in  
attempting to

assign meaning to individual coefficients. You need to use predict()
(possibly with graphical or tabular displays) and produce  
estimates of

one or two variable at relevant levels of  the other variables.

The other aspect about which your model is not informative, is the
possibility that some of these predictors have non-linear  
associations

with `y`.

(The coefficient for `a` examined in isolation might apply to a  
group

of subjects (or other units of analysis) in which the values of `b`,
`c`, and `d` were all held at zero. Is that even a situation that
would occur in your domain of investigation?)

--
David.


Thanks very much for your answer in advance,

Regards,

Michael


Michael Haenlein
Associate Professor of Marketing
ESCP Europe
Paris, France



Call:
lm(formula = y ~ a * b * c * d)

Residuals:
   Min  1Q  Median  3Q Max
-44.919  -5.184   0.294   5.232 115.984

Coefficients:
   Estimate Std. Error t value Pr(>|t|)
(Intercept)  27.3067 0.8181  33.379  < 2e-16 ***
a   -11.0524 2.0602  -5.365 8.25e-08 ***
b-2.5950 0.4287  -6.053 1.47e-09 ***
c   -22.0025 2.8833  -7.631 2.50e-14 ***
d20.5037 0.3189  64.292  < 2e-16 ***
a:b  15.1411 1.1862  12.764  < 2e-16 ***
a:c  26.8415 7.2484   3.703 0.000214 ***
b:c   8.3127 1.5080   5.512 3.61e-08 ***
a:d   6.6221 0.8061   8.215 2.33e-16 ***
b:d  -2.0449 0.1629 -12.550  < 2e-16 ***
c:d  10.0454 1.1506   8.731  < 2e-16 ***
a:b:c 1.4137 4.1579   0.340 0.733862
a:b:d-6.1547 0.4572 -13.463  < 2e-16 ***
a:c:d   -20.6848 2.8832  -7.174 7.69e-13 ***
b:c:d-3.4864 0.6041  -5.772 8.05e-09 ***
a:b:c:d   5.6184 1.6539   3.397 0.000683 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 7.913 on 12272 degrees of freedom
Multiple R-squared: 0.8845, Adjusted R-squared: 0.8844
F-statistic:  6267 on 15 and 12272 DF,  p-value: < 2.2e-16

[[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, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-
guide.html
and provide comment

Re: [R] pass character vector in instrument field of get.hist.quote function

2011-05-11 Thread jim holtman
Depends on what you want to do with the date.  If it is a character
string, then just quote it:

 flex("xx-xx-","xx-xx-")

If you want it as a Date or POSIXct object, then convert it:

flex(as.Date('2011-05-01"), as.Date('2011;05-31"))

It all depends on how you are using it in your custom function.  In
either case you still enclose it in quotes.

On Wed, May 11, 2011 at 5:44 PM, MatAra  wrote:
> Hello gentlemen,
>
> This is a great discussion. Thank you all for providing useful answers.
> I am also new to R, was working mostly with SAS before, and have a question
> regarding passing arguments to R functions that are wrapped in quotes.
>
> Using the previous example:
> getSymbols(tickers, from="start", to="end")
>
> Given that "start/end" are quoted, how can I pass a date xx-xx- to R
> when I am invoking a custom function, like:
>
> flex<- (start, end){
> getSymbols(tickers, from="start", to="end")
> }
> flex(xx-xx-,xx-xx-)
>
> I have tried different combinations but I haven't been able to pass the
> correct date, R simply doesn't capture the value. The same issue was
> happening with tickers, although there is a way around the issue, the
> original problem remainspassing an argument that's quoted in the
> function.
>
> Any help would be greatly appreciated!
> Cheers!
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3515936.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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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] sample weights in ols

2011-05-11 Thread jour4life
Thanks so much. I really appreciate it.

Carlos

On 5/11/2011 3:18 PM, Thomas Lumley-2 [via R] wrote:
> On Thu, May 12, 2011 at 2:43 AM, jour4life <[hidden email] 
> > wrote:
> > I have a follow up question. When using svyglm, it does not matter 
> that I am
> > not using survey design and only weights?
> > In other words,
> >
> > fit<-svyglm(y~x1+x2+...xk,data=dataset,weights=weightvariable)
> >
> > Or am I going to have to construct a survey design variable, using 
> only the
> > weight variable?
>
> You will have to construct a survey design.  It's not difficult.
>
> my.first.survey.design <- svydesign(id=~1, weights=~weightvariable,
> data=dataset)
>
> fit<-svyglm(y~x1+x2+...xk, design=my.first.survey.design)
>
>-thomas
>
> -- 
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>
> __
> [hidden email]  
> 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.
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://r.789695.n4.nabble.com/sample-weights-in-ols-tp3510865p3515742.html 
>
> To unsubscribe from sample weights in ols, click here 
> .
>  
>



--
View this message in context: 
http://r.789695.n4.nabble.com/sample-weights-in-ols-tp3510865p3516252.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.


[R] Row names and matrixs

2011-05-11 Thread nielsen4897
Hi all - 
I am NEW to R and NEW to any type of programming.  I am making heatmaps
using the heatmap.2 function within gplots package.  At present, when the
heatmap is plotted it uses the row identifiers as 1,2,3,4...etc.  However, I
much rather use my own labels.  I was told my another well-versed R
programmer to use the follow script:
x<-as.matrix(test1[,-1])  ## skip column 1
rownames(x)<- test[1,]
heatmap(x, scale="none")  

This was for data set up in 4 columns such as when you read the data in R it
looks like:
Loci  Cont NaCl Peg
1  0231 2.1   4.2   4.1
2  1253 4.1   2.3  2.3
3  8167 5.7   1.1  3.4

Using the script above and this dataset it worked well - the Loci was used
as the row labels rather than the numbers assigned by R.  
Looking at the data after this script it looks like:
 Loci  Cont NaCl Peg
0231 0231 2.1   4.2   4.1
1253  1253 4.1   2.3  2.3
8167  8167 5.7   1.1  3.4


Now, I want to do the same thing BUT my dataset looks like this:
   Loci   NaCl Peg
1  0231 23.2   34.1
2  1253 25.3  21.3
3  8167 21.1  38.4

When I put in the script
x<-as.matrix(test1[,-1])  ## skip column 1
rownames(x)<- test[1,]
heatmap(x, scale="none")  
 
This is what follows (after looking at the dataset change)
  NaCl   Peg
[1,]23.2   34.1
[2,]25.3   21.3
[3,]21.1   38.4

If I alter the -1 in the x<-as.matrix(test1[,-1])  line it will 'skip' other
columns but not the first one.

What do I need to enter to make the dataset look like ?
  Loci   NaCl Peg
0231  0231 23.2   34.1
1253  1253 25.3  21.3
8167  8167 21.1  38.4

Please explain the answer and WHAT the #'s inside the [] mean!

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/Row-names-and-matrixs-tp3516372p3516372.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] How to fit a random data into Beta distribution?

2011-05-11 Thread MikeK
I am also trying to fit data to a beta distribution. 

In Ang and Tang, Probability Concepts in Engineering, 2nd Ed., page 127-9,
they describe a variant of a beta distribution with additional parameters
than the standard beta distribution, enabling specification of a max and min
value other than 0,1. This would be very useful for my purposes. 

Any thoughts on how to fit a distribution directly to this variant of the
beta distribution, without starting from scratch? 


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-fit-a-random-data-into-Beta-distribution-tp3492528p3516425.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] Line feed for a long character string

2011-05-11 Thread Lisa
Hi, Duncan,

On your and  William Dunlap’s suggestion, I tried this:

cat(sep="\n", strwrap("my long character string")),
 
and it works very well. Thanks so much for your help.

Lisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Line-feed-for-a-long-character-string-tp3515824p3516426.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] Row names and matrixs

2011-05-11 Thread Bert Gunter
Dear Anonymous/Lindsey Nielsen(?):

While it would not be hard to answer your questions, given your
admitted lack of programming or R experience, approaching your
ignorance piecemeal in this fashion does not seem to be a sensible way
to learn either. Instead, please start by reading the "Introduction to
R" tutorial that comes with the software and working through its
examples carefully. More than likely, this will get you well on your
way and also allow you gain access to many more or R's capabilities.
If you analyze data as part of your career, you won't regret this
investment.  You will also be able to use R's native Help system and
search capabilities, which much of the time will provide you the
information you need to solve your difficulties.

After you have done this, you should also be able to seek the help of
this list more effectively when you are stumped (as most of us are
from time to time), thus wasting both less of both your time and ours.

Cheers,
Bert

On Wed, May 11, 2011 at 7:23 PM, nielsen4897  wrote:
> Hi all -
> I am NEW to R and NEW to any type of programming.  I am making heatmaps
> using the heatmap.2 function within gplots package.  At present, when the
> heatmap is plotted it uses the row identifiers as 1,2,3,4...etc.  However, I
> much rather use my own labels.  I was told my another well-versed R
> programmer to use the follow script:
> x<-as.matrix(test1[,-1])  ## skip column 1
> rownames(x)<- test[1,]
> heatmap(x, scale="none")
>
> This was for data set up in 4 columns such as when you read the data in R it
> looks like:
>        Loci      Cont     NaCl     Peg
> 1      0231     2.1       4.2       4.1
> 2      1253     4.1       2.3      2.3
> 3      8167     5.7       1.1      3.4
>
> Using the script above and this dataset it worked well - the Loci was used
> as the row labels rather than the numbers assigned by R.
> Looking at the data after this script it looks like:
>             Loci      Cont     NaCl     Peg
> 0231     0231     2.1       4.2       4.1
> 1253      1253     4.1       2.3      2.3
> 8167      8167     5.7       1.1      3.4
>
>
> Now, I want to do the same thing BUT my dataset looks like this:
>       Loci       NaCl     Peg
> 1      0231     23.2       34.1
> 2      1253     25.3      21.3
> 3      8167     21.1      38.4
>
> When I put in the script
> x<-as.matrix(test1[,-1])  ## skip column 1
> rownames(x)<- test[1,]
> heatmap(x, scale="none")
>
> This is what follows (after looking at the dataset change)
>          NaCl       Peg
> [1,]    23.2       34.1
> [2,]    25.3       21.3
> [3,]    21.1       38.4
>
> If I alter the -1 in the x<-as.matrix(test1[,-1])  line it will 'skip' other
> columns but not the first one.
>
> What do I need to enter to make the dataset look like ?
>              Loci       NaCl     Peg
> 0231      0231     23.2       34.1
> 1253      1253     25.3      21.3
> 8167      8167     21.1      38.4
>
> Please explain the answer and WHAT the #'s inside the [] mean!
>
> Thanks
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Row-names-and-matrixs-tp3516372p3516372.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.
>



-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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] mtext text size (cex) doesn't match plot

2011-05-11 Thread Prof Brian Ripley

On Wed, 11 May 2011, George Locke wrote:


Hi,

I am using mtext instead of the ylab argument in some plots because i
want to move it away from the numbers in the axis.  However, the text
in the X axis,

for example:
   par(mar=c(5, 5.5, 4, 2));
   plot(data, main="plot name", xlab= 'X axis', ylab="",
font=2, cex.lab=1.5, font.lab=2, cex.main=1.8);
   mtext('Y axis', side=2, cex=1.5, line=4, font=2);

This works fine, but if I then set

   par(mfrow=c(3,2));

the text produced by mtext becomes much larger than the text "X axis"
produced by plot, despite their having identical cex specifications.
In this case, the words "Y axis" become much larger than "plot name".
Note that without par(mfrow) the size of "X axis" and "Y axis" match
iff their cex(.lab) arguments match.

How can I make mtext produce text that exactly matches the xlab?  In
my limited experience fiddling around with this problem, the size of
the mtext does not depend on par(mfrow), whereas the size of the xlab
does, so if there were a formula that relates the actual size of text,


Please do read the help!  ?mtext says

 cex: character expansion factor.  ‘NULL’ and ‘NA’ are equivalent
  to ‘1.0’.  This is an absolute measure, not scaled by
  ‘par("cex")’ or by setting ‘par("mfrow")’ or ‘par("mfcol")’.

so no 'limited experience fiddling around with this problem' was 
needed.  And see ?par:


 ‘cex’ A numerical value giving the amount by which plotting text
  and symbols should be magnified relative to the default.
  This starts as ‘1’ when a device is opened, and is reset when
  the layout is changed, e.g. by setting ‘mfrow’.

 ‘mfcol, mfrow’ A vector of the form ‘c(nr, nc)’.  Subsequent
  figures will be drawn in an ‘nr’-by-‘nc’ array on the device
  by _columns_ (‘mfcol’), or _rows_ (‘mfrow’), respectively.

  In a layout with exactly two rows and columns the base value
  of ‘"cex"’ is reduced by a factor of 0.83: if there are three
  or more of either rows or columns, the reduction factor is
  0.66.


cex argument, and par(mfrow), then I could use that to attenuate the
cex argument of mtext.  Any solution will do, so long as it maintains
the relative sizes of the plot and the three text fields (main, x axis
label, y axis label).


library(fortunes); fortune(14) applies -- see the posting guide.

--
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] Total effect of X on Y under presence of interaction effects

2011-05-11 Thread vioravis
This is what I believe is referred to as "supression" in regression, where
the correlation correlation between the independent and the dependent
variable turns out to be of one sign whereas the regression coefficient
turns out to be of the opposite sign. 

Read here about supression:

http://www.uvm.edu/~dhowell/gradstat/psych341/lectures/MultipleRegression/multreg3.html

HTH



--
View this message in context: 
http://r.789695.n4.nabble.com/Total-effect-of-X-on-Y-under-presence-of-interaction-effects-tp3514137p3516446.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.