Re: [R] Could you manually replicate execution of a R function

2023-09-22 Thread Brian Smith
Hi Ivan,

Thanks for pointing this out. It now matches.

Thanks and regards,

On Thu, 21 Sept 2023 at 13:04, Ivan Krylov  wrote:
>
> On Tue, 19 Sep 2023 23:09:18 +0530
> Brian Smith  wrote:
>
> > C = rep(0, length(D))
> > N = length(D)
>
> In the VaRDurTest function, there's additional code between these two
> expressions that deals with censoring if head(VaR.ind, 1) == 0 or
> tail(VaR.ind, 1) == 0. Both of these are true for your input data.
>
> --
> Best regards,
> Ivan

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


[R] Unable to manually replicate execution of a R function

2023-09-20 Thread Brian Smith
Hi,

** In may earlier post there were some typo, so reposting the same
after correction**

I am trying to replicate a function from rugarch package manually.
Below is the calculation based on the function,

library(rugarch)
data(dji30ret)
spec = ugarchspec(mean.model = list(armaOrder = c(1,1), include.mean = TRUE),
variance.model = list(model = "gjrGARCH"), distribution.model = "sstd")
fit = ugarchfit(spec, data = dji30ret[1:1000, 1, drop = FALSE])
spec2 = spec
setfixed(spec2)<-as.list(coef(fit))
filt = ugarchfilter(spec2, dji30ret[1001:2500, 1, drop = FALSE], n.old = 1000)
actual = dji30ret[1001:2500,1]
# location+scale invariance allows to use [mu + sigma*q(p,0,1,skew,shape)]
VaR = fitted(filt) + sigma(filt)*qdist("sstd", p=0.05, mu = 0, sigma = 1,
skew = coef(fit)["skew"], shape=coef(fit)["shape"])
alpha = 0.05
conf.level = 0.95

VaRDurTest(0.05, actual, VaR)$b ## 1.019356


Now I want to replicate the calculation manually as below,


VaR.ind = ifelse(actual < VaR, 1, 0)
N = sum(VaR.ind)
TN = length(VaR.ind)
D = diff(which(VaR.ind == 1))
C = rep(0, length(D))
N = length(D)

pweibull = function (D, a, b, survival = FALSE)
{
cdf = 1 - exp(-(a * D)^b)
if (survival)
cdf = 1 - cdf
return(cdf)
}
dweibull = function (D, a, b, log = FALSE)
{
pdf = (b * log(a) + log(b) + (b - 1) * log(D) - (a * D)^b)
if (!log)
pdf = exp(pdf)
return(pdf)
}
likDurationW = function (pars, D, C, N)
{
b = pars[1]
a = ((N - C[1] - C[N])/(sum(D^b)))^(1/b)
lik = C[1] * log(pweibull(D[1], a, b, survival = TRUE)) +
(1 - C[1]) * dweibull(D[1], a, b, log = TRUE) + sum(dweibull(D[2:(N -
1)], a, b, log = TRUE)) + C[N] * log(pweibull(D[N],
a, b, survival = TRUE)) + (1 - C[N]) * dweibull(D[N],
a, b, log = TRUE)
if (!is.finite(lik) || is.nan(lik))
lik = 100
else lik = -lik
return(lik)
}
optim(par = 2, fn = likDurationW, gr = NULL, D = D, C = C, N = N,
method = "L-BFGS-B", lower = 0.001, upper = 10, control = list(trace =
0))$par  ## 1.029628

I fail to understand why there has to be a difference. Could you
please help to find the reason?

> sessionInfo()

R version 4.2.2 (2022-10-31)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Big Sur ... 10.16


Matrix products: default

BLAS:   
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib

LAPACK: 
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib


locale:

[1] C/UTF-8/C/C/C/C


attached base packages:

[1] parallel  stats graphics  grDevices utils datasets  methods

[8] base


other attached packages:

[1] rugarch_1.4-9


loaded via a namespace (and not attached):

 [1] Rcpp_1.0.9  mclust_6.0.0

 [3] lattice_0.20-45 mvtnorm_1.1-3

 [5] zoo_1.8-12  MASS_7.3-58.1

 [7] GeneralizedHyperbolic_0.8-4 truncnorm_1.0-9

 [9] grid_4.2.2  pracma_2.4.2

[11] KernSmooth_2.23-20  SkewHyperbolic_0.4-0

[13] Matrix_1.5-1xts_0.12.1

[15] spd_2.0-1   tools_4.2.2

[17] ks_1.14.1   numDeriv_2016.8-1.1

[19] compiler_4.2.2  DistributionUtils_0.6-1

[21] Rsolnp_1.16

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


[R] Could you manually replicate execution of a R function

2023-09-19 Thread Brian Smith
Hi,

I have trying to replicate a function from rugarch package manually.
Below is the calculation based on the function,

library(rugarch)
data(dji30ret)
spec = ugarchspec(mean.model = list(armaOrder = c(1,1), include.mean = TRUE),
variance.model = list(model = "gjrGARCH"), distribution.model = "sstd")
fit = ugarchfit(spec, data = dji30ret[1:1000, 1, drop = FALSE])
spec2 = spec
setfixed(spec2)<-as.list(coef(fit))
filt = ugarchfilter(spec2, dji30ret[1001:2500, 1, drop = FALSE], n.old = 1000)
actual = dji30ret[1001:2500,1]
# location+scale invariance allows to use [mu + sigma*q(p,0,1,skew,shape)]
VaR = fitted(filt) + sigma(filt)*qdist("sstd", p=0.05, mu = 0, sigma = 1,
skew = coef(fit)["skew"], shape=coef(fit)["shape"])
alpha = 0.05
conf.level = 0.95

VaRDurTest(0.05, actual, VaR)$b ## 1.019356


Now I want to replicate the calculation manually as below,


VaR.ind = ifelse(actual < VaR, 1, 0)
N = sum(VaR.ind)
TN = length(VaR.ind)
D = diff(which(VaR.ind == 1))
C = rep(0, length(D))
N = length(D)

pweibull = function (D, a, b, survival = FALSE)
{
cdf = 1 - exp(-(a * D)^b)
if (survival)
cdf = 1 - cdf
return(cdf)
}
dweibull = function (D, a, b, log = FALSE)
{
pdf = (b * log(a) + log(b) + (b - 1) * log(D) - (a * D)^b)
if (!log)
pdf = exp(pdf)
return(pdf)
}
likDurationW = function (pars, D, C, N)
{
b = pars[1]
a = ((N - C[1] - C[N])/(sum(D^b)))^(1/b)
lik = C[1] * log(pweibull(D[1], a, b, survival = TRUE)) +
(1 - C[1]) * dweibull(D[1], a, b, log = TRUE) + sum(dweibull(D[2:(N -
1)], a, b, log = TRUE)) + C[N] * log(pweibull(D[N],
a, b, survival = TRUE)) + (1 - C[N]) * dweibull(D[N],
a, b, log = TRUE)
if (!is.finite(lik) || is.nan(lik))
lik = 100
else lik = -lik
return(lik)
}
optim(par = 2, fn = likDurationW, gr = NULL, D = D, C = C, N = N,
method = "L-BFGS-B", lower = 0.001, upper = 10, control = list(trace =
0))$par  ## 1.029628

I fail to understand why there has to be a difference. Could you
please help to find the reason?

> sessionInfo()

R version 4.2.2 (2022-10-31)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Big Sur ... 10.16


Matrix products: default

BLAS:   
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib

LAPACK: 
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib


locale:

[1] C/UTF-8/C/C/C/C


attached base packages:

[1] parallel  stats graphics  grDevices utils datasets  methods

[8] base


other attached packages:

[1] rugarch_1.4-9


loaded via a namespace (and not attached):

 [1] Rcpp_1.0.9  mclust_6.0.0

 [3] lattice_0.20-45 mvtnorm_1.1-3

 [5] zoo_1.8-12  MASS_7.3-58.1

 [7] GeneralizedHyperbolic_0.8-4 truncnorm_1.0-9

 [9] grid_4.2.2  pracma_2.4.2

[11] KernSmooth_2.23-20  SkewHyperbolic_0.4-0

[13] Matrix_1.5-1xts_0.12.1

[15] spd_2.0-1   tools_4.2.2

[17] ks_1.14.1   numDeriv_2016.8-1.1

[19] compiler_4.2.2  DistributionUtils_0.6-1

[21] Rsolnp_1.16

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


[R] igraph: layout help

2022-06-11 Thread Brian Smith
Hi,

I was trying to make a network plot of this data:


library(igraph)
library(network)

df1 <- data.frame(from="A",to=c("B","C","D","E","F","G"),value=1)
df2 <- data.frame(from="K",to=c("L","M","N"),value=1)
df3 <- data.frame(from="A",to="K",value=3)
my.df <- rbind(df1,df2,df3)

my.graph <- graph_from_data_frame(my.df,directed = F)
plot(my.graph)


What I wanted was for nodes A to G to be very close together (touching each
other). Similarly, nodes K to N should be very close together. The
connecting edge (A to K) between these sets of points/vertices should be
the only edge visible. How should I go about doing this?

Also, how can I change the parameters (node label, node color, etc.) of the
graph?

Any help or link to documentation would be helpful. Or would

thanks!

[[alternative HTML version deleted]]

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


[R] Using R to analyse Court documents

2021-07-20 Thread Brian Smith
Hi,

I am wondering if there is some references on how R can be used to
analyse legal/court documents. I searched a bit in internet but unable
to get anything meaningful.

Any reference will be very appreciated.

Thanks for your time.

Thanks and regards,

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


[R] grep

2018-07-16 Thread Brian Smith
Hi,

I was trying to find a pattern ("ABHD14A") in a character string ('xgen' in
example below) using grepl. Note that the individual members may be
separated by a semi-colon.

The correct answer should return:

"ABHD-ACY1 ; ABHD14A" "ABHD14A ; YYY"

I have tried three approaches, but still seem a bit off. Attempt 2 below
gets closest, but it also returns a hit where my pattern is a substring.
Here is my code:

===


  xgen <- c("XYZ","ABHD-ACY1 ; ABHD14A","ABHD14AXX","ABHD14A ; YYY")
  ga <- "ABHD14A"

  # 1.
  kx <- grepl(paste0("^",ga,"$"),xgen)
  xgen[kx]

  # 2.
  ky <- grepl(ga,xgen)
  xgen[ky]


==

What do I need to add/change in #2 above?

many thanks!

[[alternative HTML version deleted]]

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


[R] numeric comparison error

2018-06-18 Thread Brian Smith
Hi,

I am a little bit perplexed at why I am getting some values as FALSE:

> cpgbins <- seq(0,1,0.05)

> cpgbins
 [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65
0.70 0.75 0.80 0.85 0.90 0.95 1.00

> cpgbins[1] == 0.00
[1] TRUE
> cpgbins[2] == 0.05
[1] TRUE
> cpgbins[3] == 0.10
[1] TRUE
> cpgbins[4] == 0.15
[1] FALSE
> cpgbins[5] == 0.20
[1] TRUE
> cpgbins[6] == 0.25
[1] TRUE
> cpgbins[7] == 0.30
[1] FALSE

> class(cpgbins)
[1] "numeric"

> class(cpgbins[7])
[1] "numeric"

What is the cause for this?

thanks!!

[[alternative HTML version deleted]]

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


[R] par(mfrow) for heatmap plots

2017-07-23 Thread Brian Smith
Hi,

I was trying to use par(mfrow) to put 4 heatmaps on a single page. However,
I get one plot per page and not one page with 4 plots. What should I
modify? Test code is given below:

test = matrix(rnorm(60), 20, 3)

pdf(file='test.pdf',width=10,height=8)
par(mfrow=c(2,2))
heatmap(test)
heatmap(test)
heatmap(test)
heatmap(test)
dev.off()

thanks!

[[alternative HTML version deleted]]

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


Re: [R] ggplot2 geom_bar arrangement

2017-06-27 Thread Brian Smith
Thanks Jean, that worked!

On Tue, Jun 27, 2017 at 3:58 PM, Adams, Jean <jvad...@usgs.gov> wrote:

> You just have to change the levels of the factor ...
>
> library(ggplot2)
>
> Lab = c(letters[4:6], letters[1:3])
> valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
> df <- data.frame(Lab,valuex)
>
> # set the factor levels to the same order as observed in the data frame
> df$Lab <- factor(df$Lab, levels=unique(df$Lab))
>
> px <- ggplot(df,aes(Lab,valuex,label=Lab)) +
>   geom_text(aes(y=0)) +
>   geom_bar(stat = "identity")
> px
>
> Jean
>
> On Tue, Jun 27, 2017 at 1:43 PM, Brian Smith <bsmith030...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I was trying to draw a geom_bar plot. However, by default, the bars are
>> arranged according to the label, which I don't want. I want the bars to
>> appear exactly as they appear in the data frame. For example in the code:
>>
>>  Lab=c(letters[4:6],letters[1:3])
>>  valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
>>  df <- data.frame(Lab,valuex)
>>  px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) +
>> geom_bar(stat = "identity")
>>  px
>>
>>
>> The default arranges the bars in order 'a' through 'f', but I want them
>> arranged as per df.
>>
>> How can I do this?
>>
>> thanks!
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

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


[R] ggplot2 geom_bar label justification

2017-06-27 Thread Brian Smith
Hi,

I was trying to make a horizontal bar plot. The barplot works when the text
labels are of reasonable length, but not if some of them are slightly long.
I think the long ones get 'squeezed' by default before the plot is flipped
and keep the skew after the flip. Is there a way I can get around this?

In the code below, plot px looks just fine, but the labels get staggered in
plot py.

#

  Lab1 = c("Tom","Harry","Brad","Helen","Julie","Steve")

Lab2=c('abracadabra','rumplestiltskin','adadf','asddsdfsdsfsds','sdfsdfsfsfs','sddf')
  valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
  df1 <- data.frame(Lab1,Lab2,valuex)
  df1$hjust <- ifelse(df1$valuex > 0, 1.3, -0.3)
  df1$Lab1 <- factor(df1$Lab1, levels = unique(df1$Lab1))
  df1$Lab2 <- factor(df1$Lab2, levels = unique(df1$Lab2))

  ## plot 1
  px <- ggplot(df1,aes(Lab,valuex,label=Lab1,hjust = hjust)) +
geom_text(aes(y=0,size=5)) +
geom_bar(stat = "identity")
  px <- px + coord_flip()

  ## plot 2
  py <- ggplot(df1,aes(Lab,valuex,label=Lab2,hjust = hjust)) +
geom_text(aes(y=0,size=5)) +
geom_bar(stat = "identity")
  py <- py + coord_flip()

#

many thanks for your help!

[[alternative HTML version deleted]]

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


[R] ggplot2 geom_bar arrangement

2017-06-27 Thread Brian Smith
Hi,

I was trying to draw a geom_bar plot. However, by default, the bars are
arranged according to the label, which I don't want. I want the bars to
appear exactly as they appear in the data frame. For example in the code:

 Lab=c(letters[4:6],letters[1:3])
 valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
 df <- data.frame(Lab,valuex)
 px <- ggplot(df,aes(Lab,valuex,label=Lab)) + geom_text(aes(y=0)) +
geom_bar(stat = "identity")
 px


The default arranges the bars in order 'a' through 'f', but I want them
arranged as per df.

How can I do this?

thanks!

[[alternative HTML version deleted]]

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


Re: [R] Jagged ROC curves?

2017-06-26 Thread Brian Smith
Hi Marc,

I tried to attache the png file of the plot, but the mailing list blocked
it!


"For the attached two png files (test_roc.png & test_roc_smooth.png)

1. Using 'plot' function:

plot(c(1,0),c(0,1), type='l', lty=3, xlim=c(1.01,-0.01),
ylim=c(-0.01,1.01), xaxs='i', yaxs='i', ylab='', xlab='')
plot(roc_1,col="brown3", lwd=2, add=T, lty=1)

2. Using the 'smooth' function:

plot(c(1,0),c(0,1), type='l', lty=3, xlim=c(1.01,-0.01),
ylim=c(-0.01,1.01), xaxs='i', yaxs='i', ylab='', xlab='')
plot(smooth(roc_1),col="brown3", lwd=2, add=T, lty=1)


I guess most ROCs that I've seen are somewhere in between, i.e. they have a
little jaggedness, but not as much as in plot #1 above"


thanks!

On Mon, Jun 26, 2017 at 12:59 PM, Marc Schwartz <marc_schwa...@me.com>
wrote:

>
> > On Jun 26, 2017, at 11:40 AM, Brian Smith <bsmith030...@gmail.com>
> wrote:
> >
> > Hi,
> >
> > I was trying to draw some ROC curves (prediction of case/control status),
> > but seem to be getting a somewhat jagged plot. Can I do something that
> > would 'smooth' it somewhat? Most roc curves seem to have many incremental
> > changes (in x and y directions), but my plot only has 4 or 5 steps even
> > though there are 22 data points. Should I be doing something differently?
> >
> > How can I provide a URL/attachment for my plot? Not sure if I can provide
> > reproducible code, but here is some pseudocode, let me know if you'd like
> > more details:
> >
> > #
> > ## generate roc and auc values
> > #
> > library(pROC)
> > library(AUCRF)
> >
> > getROC <- function(d1train,d1test){
> > my_model <- AUCRF(formula= status ~ ., data=d1train,
> > ranking='MDA',ntree=1000,pdel=0.05)
> >  my_opt_model <- my_model$RFopt
> >
> >  my_probs <- predict(my_opt_model, d1test, type = 'prob')
> >  my_roc <- roc(d1test[,resp_col] ~ my_probs[,2])
> >  aucval <- round(as.numeric(my_roc$auc),4)
> > return(my_roc)
> > }
> >
> >
> > roc_1 <- getROC(dat1,dat1test)
> > plot.roc(roc_1,col="brown3")
> >
> >
> >> roc_1
> >
> > Call:
> > roc.formula(formula = d1test[, resp_col] ~ ibd_probs[, 2])
> >
> > Data: ibd_probs[, 2] in 3 controls (d1test[, resp_col] 0) < 19 cases
> > (d1test[, resp_col] 1).
> > Area under the curve: 0.8596
> >
> >
> >> roc_1$sensitivities
> > [1] 1. 0.94736842 0.94736842 0.94736842 0.89473684 0.84210526
> > 0.78947368 0.73684211 0.68421053 0.68421053
> > [11] 0.63157895 0.57894737 0.52631579 0.47368421 0.42105263 0.36842105
> > 0.31578947 0.26315789 0.21052632 0.15789474
> > [21] 0.10526316 0.05263158 0.
> >
> >
> >> roc_1$specificities
> > [1] 0.000 0.000 0.333 0.667 0.667 0.667 0.667
> > 0.667 0.667 1.000 1.000
> > [12] 1.000 1.000 1.000 1.000 1.000 1.000
> 1.000
> > 1.000 1.000 1.000 1.000
> > [23] 1.000
> >
> >
> > many thanks!
>
>
> ROC curves are typically step functions of some nature, depending upon
> your thresholds, so the default behavior is not going to be smoothed.
>
> I am not sure how they (AUCRF and pROC) may interact, but look at the
> ?smooth function in the latter package to see if it might help.
>
> To your second point, if your plot is a png/jpg file, you could attach it
> to your post here, if that was your desire. Otherwise, you could post it to
> a cloud based repository, like Dropbox, and provide the URL for public
> sharing here. The R lists support limited binary attachment types and
> png/jpg/pdf/ps are supported.
>
> Regards,
>
> Marc Schwartz
>
>

[[alternative HTML version deleted]]

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


[R] Jagged ROC curves?

2017-06-26 Thread Brian Smith
Hi,

I was trying to draw some ROC curves (prediction of case/control status),
but seem to be getting a somewhat jagged plot. Can I do something that
would 'smooth' it somewhat? Most roc curves seem to have many incremental
changes (in x and y directions), but my plot only has 4 or 5 steps even
though there are 22 data points. Should I be doing something differently?

How can I provide a URL/attachment for my plot? Not sure if I can provide
reproducible code, but here is some pseudocode, let me know if you'd like
more details:

#
## generate roc and auc values
#
library(pROC)
library(AUCRF)

getROC <- function(d1train,d1test){
my_model <- AUCRF(formula= status ~ ., data=d1train,
ranking='MDA',ntree=1000,pdel=0.05)
  my_opt_model <- my_model$RFopt

  my_probs <- predict(my_opt_model, d1test, type = 'prob')
  my_roc <- roc(d1test[,resp_col] ~ my_probs[,2])
  aucval <- round(as.numeric(my_roc$auc),4)
return(my_roc)
}


roc_1 <- getROC(dat1,dat1test)
plot.roc(roc_1,col="brown3")


> roc_1

Call:
roc.formula(formula = d1test[, resp_col] ~ ibd_probs[, 2])

Data: ibd_probs[, 2] in 3 controls (d1test[, resp_col] 0) < 19 cases
(d1test[, resp_col] 1).
Area under the curve: 0.8596


> roc_1$sensitivities
 [1] 1. 0.94736842 0.94736842 0.94736842 0.89473684 0.84210526
0.78947368 0.73684211 0.68421053 0.68421053
[11] 0.63157895 0.57894737 0.52631579 0.47368421 0.42105263 0.36842105
0.31578947 0.26315789 0.21052632 0.15789474
[21] 0.10526316 0.05263158 0.


> roc_1$specificities
 [1] 0.000 0.000 0.333 0.667 0.667 0.667 0.667
0.667 0.667 1.000 1.000
[12] 1.000 1.000 1.000 1.000 1.000 1.000 1.000
1.000 1.000 1.000 1.000
[23] 1.000


many thanks!

[[alternative HTML version deleted]]

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


Re: [R] x-axis tick marks on log scale plot

2016-05-19 Thread Brian Smith
Thanks all !!

On Thu, May 19, 2016 at 9:55 AM, Ivan Calandra <ivan.calan...@univ-reims.fr>
wrote:

> Hi,
>
> You can do it by first plotting your values without the x-axis:
> plot(x,y,log="xy", xaxt="n")
>
> and then plotting the x-axis with ticks where you need to:
> axis(side=1, at=seq(2000,8000,1000))
>
> HTH,
> Ivan
>
> --
> Ivan Calandra, PhD
> Scientific Mediator
> University of Reims Champagne-Ardenne
> GEGENAA - EA 3795
> CREA - 2 esplanade Roland Garros
> 51100 Reims, France
> +33(0)3 26 77 36 89
> ivan.calan...@univ-reims.fr
> --
> https://www.researchgate.net/profile/Ivan_Calandra
> https://publons.com/author/705639/
>
>
> Le 19/05/2016 à 15:40, Brian Smith a écrit :
>
>> Hi,
>>
>> I have a plot with log scale on the axes. How do I add ticks and labels in
>> addition to the ones provided by default? Can I specify where I want the
>> ticks and labels?
>>
>> For example:
>>
>> set.seed(12345)
>> x <- sample(1:1,10)
>> y <- sample(1:1,10)
>>
>> plot(x,y,log="xy")
>>
>>
>> For me, this plot has tick marks (and labels) at 2000, 4000, 6000, 8000.
>> How can I make the axes so that it has marks and labels at 1000 intervals
>> (i.e. 2000, 3000, 4000, etc.)
>>
>> thanks!
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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

[R] x-axis tick marks on log scale plot

2016-05-19 Thread Brian Smith
Hi,

I have a plot with log scale on the axes. How do I add ticks and labels in
addition to the ones provided by default? Can I specify where I want the
ticks and labels?

For example:

set.seed(12345)
x <- sample(1:1,10)
y <- sample(1:1,10)

plot(x,y,log="xy")


For me, this plot has tick marks (and labels) at 2000, 4000, 6000, 8000.
How can I make the axes so that it has marks and labels at 1000 intervals
(i.e. 2000, 3000, 4000, etc.)

thanks!

[[alternative HTML version deleted]]

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


[R] ggplot2: remove axis ticks

2015-12-07 Thread Brian Smith
Hi,

I was trying to remove the axis tick marks and their values using theme()
but haven't had much success. Here is sample code:

rx <- sample(1:100,10)
ry <- sample(1:100,10)
rz <- sample(letters[1:3],10,replace=T)
rdf <- data.frame(rx,ry,rz)

p <- ggplot(rdf,aes(x=rx,y=ry))
p1 <- p + geom_point(aes(shape=factor(rz),colour=factor(rz)),size=6) +
theme(axis.ticks = element_blank(), axis.text.x =
element_blank(),axis.text.y = element_blank()) +
scale_shape_manual(values=rz)  + theme_bw() +
labs(colour='rz',shape='rz')
p1


My session info:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] IlluminaHumanMethylation450kmanifest_0.4.0 biomaRt_2.26.1

 [3] data.table_1.9.6   foreign_0.8-65

 [5] preprocessCore_1.32.0  gtools_3.5.0

 [7] BiocInstaller_1.20.1   ggdendro_0.1-17

 [9] reshape_0.8.5  RnBeads_1.2.0

[11] plyr_1.8.3 methylumi_2.16.0

[13] minfi_1.16.0   bumphunter_1.10.0

[15] locfit_1.5-9.1 iterators_1.0.8

[17] foreach_1.4.3  Biostrings_2.38.2

[19] XVector_0.10.0 SummarizedExperiment_1.0.1

[21] lattice_0.20-33
 FDb.InfiniumMethylation.hg19_2.2.0
[23] org.Hs.eg.db_3.2.3 RSQLite_1.0.0

[25] DBI_0.3.1
 TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
[27] GenomicFeatures_1.22.5 AnnotationDbi_1.32.0

[29] reshape2_1.4.1 scales_0.3.0

[31] Biobase_2.30.0 illuminaio_0.12.0

[33] matrixStats_0.15.0 limma_3.26.3

[35] gridExtra_2.0.0gplots_2.17.0

[37] ggplot2_1.0.1  fields_8.3-5

[39] maps_3.0.0-2   spam_1.3-0

[41] ff_2.2-13  bit_1.1-12

[43] cluster_2.0.3  RColorBrewer_1.1-2

[45] MASS_7.3-43GenomicRanges_1.22.1

[47] GenomeInfoDb_1.6.1 IRanges_2.4.4

[49] S4Vectors_0.8.3BiocGenerics_0.16.1


loaded via a namespace (and not attached):
 [1] nlme_3.1-121bitops_1.0-6tools_3.2.2
  doRNG_1.6
 [5] nor1mix_1.2-1   KernSmooth_2.23-15  colorspace_1.2-6
 base64_1.1
 [9] chron_2.3-47pkgmaker_0.22   labeling_0.3
 rtracklayer_1.30.1
[13] caTools_1.17.1  genefilter_1.52.0   quadprog_1.5-5
 stringr_1.0.0
[17] digest_0.6.8Rsamtools_1.22.0siggenes_1.44.0
  GEOquery_2.36.0
[21] mclust_5.1  BiocParallel_1.4.0  RCurl_1.95-4.7
 magrittr_1.5
[25] futile.logger_1.4.1 Rcpp_0.12.2 munsell_0.4.2
  proto_0.3-10
[29] stringi_1.0-1   zlibbioc_1.16.0 gdata_2.17.0
 splines_3.2.2
[33] multtest_2.26.0 annotate_1.48.0 beanplot_1.2
 igraph_1.0.1
[37] corpcor_1.6.8   rngtools_1.2.4  codetools_0.2-14
 mixOmics_5.2.0
[41] futile.options_1.0.0XML_3.98-1.3lambda.r_1.1.7
 gtable_0.1.2
[45] xtable_1.8-0survival_2.38-3 ellipse_0.3-8
  GenomicAlignments_1.6.1
[49] registry_0.3rgl_0.95.1201


Am I setting the arguments for theme() incorrectly?

many thanks,

[[alternative HTML version deleted]]

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


[R] ChAMP: champ.runCombat error with methylation 450k data

2015-12-07 Thread Brian Smith
Hi,

I was trying to run COMBAT on methylation data, but keep on getting an
error:

Error in while (change > conv) { : missing value where TRUE/FALSE needed

The error occurs irrespective of whether I give the entire or reduced
(variation filter keeps only about 140k CpGs) datasets.

Is there any other preprocessing that I should be doing?

thanks!!

my code and sessionInfo():



> betacombat <- champ.runCombat(beta.c = beta3, pd = ss, logitTrans = TRUE)
Preparing files for ComBat
Zeros in your dataset have been replaced with 0.01
Your data is being logit transformed before batch correction
Beginning batch correction
Found 60 batches
Found 0  categorical covariate(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Error in while (change > conv) { : missing value where TRUE/FALSE needed
> traceback()
3: it.sol(s.data[, batches[[i]]], gamma.hat[i, ], delta.hat[i, ],
   gamma.bar[i], t2[i], a.prior[i], b.prior[i])
2: champ.ComBat(dat = log, batch = batch, mod = mod, par.prior = TRUE)
1: champ.runCombat(beta.c = betaASDnorm3, pd = ss_2ASD, logitTrans = TRUE)
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] ChAMP_1.8.0
 Illumina450ProbeVariants.db_1.6.0
 [3] ChAMPdata_1.8.0
 IlluminaHumanMethylation450kmanifest_0.4.0
 [5] biomaRt_2.26.1 data.table_1.9.6

 [7] foreign_0.8-65 preprocessCore_1.32.0

 [9] gtools_3.5.0   BiocInstaller_1.20.1

[11] ggdendro_0.1-17reshape_0.8.5

[13] RnBeads_1.2.0  plyr_1.8.3

[15] methylumi_2.16.0   minfi_1.16.0

[17] bumphunter_1.10.0  locfit_1.5-9.1

[19] iterators_1.0.8foreach_1.4.3

[21] Biostrings_2.38.2  XVector_0.10.0

[23] SummarizedExperiment_1.0.1 lattice_0.20-33

[25] FDb.InfiniumMethylation.hg19_2.2.0 org.Hs.eg.db_3.2.3

[27] RSQLite_1.0.0  DBI_0.3.1

[29] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2GenomicFeatures_1.22.5

[31] AnnotationDbi_1.32.0   reshape2_1.4.1

[33] scales_0.3.0   Biobase_2.30.0

[35] illuminaio_0.12.0  matrixStats_0.15.0

[37] limma_3.26.3   gridExtra_2.0.0

[39] gplots_2.17.0  ggplot2_1.0.1

[41] fields_8.3-5   maps_3.0.0-2

[43] spam_1.3-0 ff_2.2-13

[45] bit_1.1-12 cluster_2.0.3

[47] RColorBrewer_1.1-2 MASS_7.3-43

[49] GenomicRanges_1.22.1   GenomeInfoDb_1.6.1

[51] IRanges_2.4.4  S4Vectors_0.8.3

[53] BiocGenerics_0.16.1

loaded via a namespace (and not attached):
 [1] nlme_3.1-121bitops_1.0-6tools_3.2.2
  doRNG_1.6
 [5] nor1mix_1.2-1   KernSmooth_2.23-15  mgcv_1.8-7
 colorspace_1.2-6
 [9] DNAcopy_1.44.0  base64_1.1  chron_2.3-47
 wateRmelon_1.10.0
[13] RPMM_1.20   pkgmaker_0.22   labeling_0.3
 rtracklayer_1.30.1
[17] caTools_1.17.1  genefilter_1.52.0   quadprog_1.5-5
 stringr_1.0.0
[21] digest_0.6.8Rsamtools_1.22.0siggenes_1.44.0
  GEOquery_2.36.0
[25] impute_1.44.0   mclust_5.1  BiocParallel_1.4.0
 RCurl_1.95-4.7
[29] magrittr_1.5Matrix_1.2-2futile.logger_1.4.1
  Rcpp_0.12.2
[33] munsell_0.4.2   proto_0.3-10stringi_1.0-1
  zlibbioc_1.16.0
[37] gdata_2.17.0splines_3.2.2   multtest_2.26.0
  annotate_1.48.0
[41] beanplot_1.2igraph_1.0.1corpcor_1.6.8
  rngtools_1.2.4
[45] marray_1.48.0   codetools_0.2-14mixOmics_5.2.0
 futile.options_1.0.0
[49] XML_3.98-1.3lambda.r_1.1.7  gtable_0.1.2
 xtable_1.8-0
[53] survival_2.38-3 ellipse_0.3-8
GenomicAlignments_1.6.1 registry_0.3
[57] sva_3.18.0  rgl_0.95.1201

[[alternative HTML version deleted]]

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


[R] ggplot2: Controlling width of line

2015-10-30 Thread Brian Smith
Hi,

I was trying to increase the size of certain lines in my plot (samples 'B'
and 'D' in example below). However, when I try to modify the line size, I
seem to screw up the linetypes. Also, is there a way to reflect the line
size in the legend?

Here is some sample code for illustration:

library(reshape)
matx <- matrix(sample(1:1000),4,5)
colnames(matx) <-  LETTERS[1:5]
rownames(matx) <- 1:4

subset1 <- c('B','D')

ltyvect <- c("solid","longdash","longdash","solid","solid")
colvect <- c("red","black","orange","blue","lightblue")
lwdvect <- rep(1,ncol(matx))

## For subset of samples, increase line width size
fmakelwd <- function(set1,subset1,vals1,val2=2){
idx <- set1 %in% subset1
vals1[idx] <- val2
return(vals1)
}

maty <- melt(matx)
set1 <- maty$X2
vals1 <- rep(1,length(set1))

mylwd <- fmakelwd(set1,subset1,vals1,val2=1.5)
matz <- data.frame(maty,mylwd)

# code without trying to modify line size

p <- ggplot(data=matz,aes(x=X1, y = value,col=X2,lty=X2,shape=X2))
p <- p + geom_line(aes(group = X2)) + geom_point(aes(shape =
factor(X2)),size=3) +
scale_linetype_manual(values = ltyvect) +
scale_color_manual(values = colvect) +
theme(legend.title = element_blank())
p


#  modifying line size

p <- ggplot(data=matz,aes(x=X1, y =
value,col=X2,lty=X2,shape=X2,size=mylwd))
p <- p + geom_line(aes(group = X2,size=mylwd)) + geom_point(aes(shape =
factor(X2)),size=3) +
scale_linetype_manual(values = ltyvect) +
scale_color_manual(values = colvect) +
scale_size(range=c(0.1, 2), guide=FALSE) +
theme(legend.title = element_blank())
p


#


thanks!!

[[alternative HTML version deleted]]

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


[R] plot: rug colors

2015-05-24 Thread Brian Smith
Hi,

I wanted the rug (in plot) to have different colors. For example:

vals1 - sample(1:100,5)
vals2 - sample(1:100,5)

rugcols - c(red,blue,brown,red,yellow)

plot(vals1,vals2)
rug(vals1,col=rugcols,lwd=2)


However, with this code I only get 'red' for all the ticks. Is there a way
I can get the different colors for rug?

thanks!

[[alternative HTML version deleted]]

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


Re: [R] plot: rug colors

2015-05-24 Thread Brian Smith
Thanks Duncan! That works!

On Sun, May 24, 2015 at 8:09 AM, Duncan Murdoch murdoch.dun...@gmail.com
wrote:

 On 24/05/2015 7:47 AM, Brian Smith wrote:
  Hi,
 
  I wanted the rug (in plot) to have different colors. For example:
 
  vals1 - sample(1:100,5)
  vals2 - sample(1:100,5)
 
  rugcols - c(red,blue,brown,red,yellow)
 
  plot(vals1,vals2)
  rug(vals1,col=rugcols,lwd=2)
 
 
  However, with this code I only get 'red' for all the ticks. Is there a
 way
  I can get the different colors for rug?

 The rug() function is basically a wrapper for axis(), and it doesn't
 support multiple colours of tick marks.  So what you could do is call
 rug() once for each colour:

 # This line is not needed in your example, but might be in general...
 rugcols - rep(rugcols, length.out=length(vals1))

 for (col in unique(rugcols)) {
   show - rugcols == col
   rug(vals1[show], col=col, lwd=2)
 }

 Duncan Murdoch


[[alternative HTML version deleted]]

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


[R] ggplot: connect points with line (not in order)

2015-04-05 Thread Brian Smith
Hi,

I am trying to connect points, but not in a different order than the
default value in ggplot. For example:

 xx - sample(1:100,5)
  yy - sample(1:100,5)

  mydat - data.frame(xx,yy)
  print(mydat)

  ggplot(mydat,aes(xx,yy)) + geom_point() + geom_line()


I want to connect the points as they appear in mydat, and not necessarily
from the smallest value on the 'x' axis to the largest.

How can I do this?

thanks!

[[alternative HTML version deleted]]

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


Re: [R] ggplot: connect points with line (not in order)

2015-04-05 Thread Brian Smith
thanks!

On Sun, Apr 5, 2015 at 9:15 AM, billy am wickedpu...@gmail.com wrote:

 Will this do?

 ggplot(mydat,aes(xx,yy)) + geom_path()

 From :
 http://stackoverflow.com/questions/15706281/controlling-order-of-points-in-ggplot2-in-r



 --
 |

 http://billyam.com  || http://use-r.com  || http://shinyserver.com (BETA)

 SAS Certified Base Programmer for SAS 9
 Oracle SQL Expert(11g)



 On Sun, Apr 5, 2015 at 9:03 PM, Brian Smith bsmith030...@gmail.com
 wrote:
  Hi,
 
  I am trying to connect points, but not in a different order than the
  default value in ggplot. For example:
 
   xx - sample(1:100,5)
yy - sample(1:100,5)
 
mydat - data.frame(xx,yy)
print(mydat)
 
ggplot(mydat,aes(xx,yy)) + geom_point() + geom_line()
 
 
  I want to connect the points as they appear in mydat, and not necessarily
  from the smallest value on the 'x' axis to the largest.
 
  How can I do this?
 
  thanks!
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] hash - extract key values

2015-03-28 Thread Brian Smith
I deleted the 'hash' directory and re-installed (several times!) it, but it
is still wierd..


 sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] tools_3.1.2
 library(hash)
hash-3.0.1 provided by Decision Patterns

 myhash - hash(key=letters,values=1:26)
 myhash
hash containing 2 key-value pair(s).
  key : a b c d e f g h i j k l m n o p q r s t u v w x y z
  values :  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
22 23 24 25 26
 keys(myhash)
[1] keyvalues
 myhash$key
 [1] a b c d e f g h i j k l m n o p q
r s t u v w x y z
 myhash$values
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
24 25 26
 sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] hash_3.0.1

loaded via a namespace (and not attached):
[1] tools_3.1.2


On Sat, Mar 28, 2015 at 5:02 AM, Uwe Ligges lig...@statistik.tu-dortmund.de
 wrote:

 Try to reinstall hash. Sounds like a broken installation.

 Best,
 Uwe Ligges



 On 28.03.2015 07:03, Brian Smith wrote:

 Exactly. Used to work for me, but not anymore. I tried restarting session,
 installing the most recent package of 'hash' etc.

 Here is my sessionInfo():

  sessionInfo()

 R version 3.1.2 (2014-10-31)
 Platform: x86_64-apple-darwin10.8.0 (64-bit)

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

 attached base packages:
   [1] grid  parallel  stats4stats graphics  grDevices utils
 datasets  methods   base

 other attached packages:
   [1] mapdata_2.2-3maps_2.3-9   org.Hs.eg.db_3.0.0
 multicore_0.1-7  nlme_3.1-120 Rgraphviz_2.10.0
   [7] biomaRt_2.22.0   topGO_2.18.0 SparseM_1.6
   GO.db_3.0.0  graph_1.44.1 mouse4302.db_3.0.0
 [13] org.Mm.eg.db_3.0.0   RSQLite_1.0.0DBI_0.3.1
   AnnotationDbi_1.28.1 GenomeInfoDb_1.2.4   IRanges_2.0.1
 [19] S4Vectors_0.4.0  Biobase_2.26.0   BiocGenerics_0.12.1
   XML_3.98-1.1 gap_1.1-12   som_0.3-5
 [25] pvclust_1.3-2foreign_0.8-63   hash_3.0.1

 loaded via a namespace (and not attached):
 [1] bitops_1.0-6lattice_0.20-29 RCurl_1.95-4.5  tools_3.1.2




 On Fri, Mar 27, 2015 at 9:54 PM, Boris Steipe boris.ste...@utoronto.ca
 wrote:

  Works for me :

  library(hash)

 hash-2.2.6 provided by Decision Patterns

  hx - hash( c('a','b','c'), 1:3 )
 class(hx)

 [1] hash
 attr(,package)
 [1] hash

 hx$a

 [1] 1

 keys(hx)

 [1] a b c


 Maybe restart your session? Clear your workspace? Upgrade?

 B.





 On Mar 27, 2015, at 7:39 PM, Brian Smith bsmith030...@gmail.com wrote:

  Hi,

 I was trying to use hash, but can't seem to get the keys from the hash.
 According to the hash documentation ('hash' package pdf, the following
 should work:

  hx - hash( c('a','b','c'), 1:3 )
 class(hx)

 [1] hash
 attr(,package)
 [1] hash

 hx$a

 [1] 1

 keys(hx)

 Error in (function (classes, fdef, mtable)  :
   unable to find an inherited method for function ‘keys’ for signature
 ‘hash’

 How can I get the keys for my hash?

 thanks!

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide

 http://www.R-project.org/posting-guide.html

 and provide commented, minimal, self-contained, reproducible code.




 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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

Re: [R] hash - extract key values

2015-03-28 Thread Brian Smith
Hi William,

That's the point - the 'keys()' doesn't seem to work..


On Sat, Mar 28, 2015 at 7:36 PM, William Dunlap wdun...@tibco.com wrote:

 Try using the plural 'keys' instead of 'key' (as help(hash) says):
yourhash - hash(keys=letters, values=1:26)
 Then there will be 26 items in the hash table and keys(yourhash)
 will return the 26 lowercase letters.  Is that what you want?

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 On Sat, Mar 28, 2015 at 2:56 PM, Brian Smith bsmith030...@gmail.com
 wrote:

 I deleted the 'hash' directory and re-installed (several times!) it, but
 it
 is still wierd..


  sessionInfo()
 R version 3.1.2 (2014-10-31)
 Platform: x86_64-apple-darwin10.8.0 (64-bit)

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

 loaded via a namespace (and not attached):
 [1] tools_3.1.2
  library(hash)
 hash-3.0.1 provided by Decision Patterns

  myhash - hash(key=letters,values=1:26)
  myhash
 hash containing 2 key-value pair(s).
   key : a b c d e f g h i j k l m n o p q r s t u v w x y z
   values :  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
 22 23 24 25 26
  keys(myhash)
 [1] keyvalues
  myhash$key
  [1] a b c d e f g h i j k l m n o p q
 r s t u v w x y z
  myhash$values
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24 25 26
  sessionInfo()
 R version 3.1.2 (2014-10-31)
 Platform: x86_64-apple-darwin10.8.0 (64-bit)

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

 other attached packages:
 [1] hash_3.0.1

 loaded via a namespace (and not attached):
 [1] tools_3.1.2
 

 On Sat, Mar 28, 2015 at 5:02 AM, Uwe Ligges 
 lig...@statistik.tu-dortmund.de
  wrote:

  Try to reinstall hash. Sounds like a broken installation.
 
  Best,
  Uwe Ligges
 
 
 
  On 28.03.2015 07:03, Brian Smith wrote:
 
  Exactly. Used to work for me, but not anymore. I tried restarting
 session,
  installing the most recent package of 'hash' etc.
 
  Here is my sessionInfo():
 
   sessionInfo()
 
  R version 3.1.2 (2014-10-31)
  Platform: x86_64-apple-darwin10.8.0 (64-bit)
 
  locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
  attached base packages:
[1] grid  parallel  stats4stats graphics  grDevices utils
  datasets  methods   base
 
  other attached packages:
[1] mapdata_2.2-3maps_2.3-9   org.Hs.eg.db_3.0.0
  multicore_0.1-7  nlme_3.1-120 Rgraphviz_2.10.0
[7] biomaRt_2.22.0   topGO_2.18.0 SparseM_1.6
GO.db_3.0.0  graph_1.44.1 mouse4302.db_3.0.0
  [13] org.Mm.eg.db_3.0.0   RSQLite_1.0.0DBI_0.3.1
AnnotationDbi_1.28.1 GenomeInfoDb_1.2.4   IRanges_2.0.1
  [19] S4Vectors_0.4.0  Biobase_2.26.0   BiocGenerics_0.12.1
XML_3.98-1.1 gap_1.1-12   som_0.3-5
  [25] pvclust_1.3-2foreign_0.8-63   hash_3.0.1
 
  loaded via a namespace (and not attached):
  [1] bitops_1.0-6lattice_0.20-29 RCurl_1.95-4.5  tools_3.1.2
 
 
 
 
  On Fri, Mar 27, 2015 at 9:54 PM, Boris Steipe 
 boris.ste...@utoronto.ca
  wrote:
 
   Works for me :
 
   library(hash)
 
  hash-2.2.6 provided by Decision Patterns
 
   hx - hash( c('a','b','c'), 1:3 )
  class(hx)
 
  [1] hash
  attr(,package)
  [1] hash
 
  hx$a
 
  [1] 1
 
  keys(hx)
 
  [1] a b c
 
 
  Maybe restart your session? Clear your workspace? Upgrade?
 
  B.
 
 
 
 
 
  On Mar 27, 2015, at 7:39 PM, Brian Smith bsmith030...@gmail.com
 wrote:
 
   Hi,
 
  I was trying to use hash, but can't seem to get the keys from the
 hash.
  According to the hash documentation ('hash' package pdf, the
 following
  should work:
 
   hx - hash( c('a','b','c'), 1:3 )
  class(hx)
 
  [1] hash
  attr(,package)
  [1] hash
 
  hx$a
 
  [1] 1
 
  keys(hx)
 
  Error in (function (classes, fdef, mtable)  :
unable to find an inherited method for function ‘keys’ for
 signature
  ‘hash’
 
  How can I get the keys for my hash?
 
  thanks!
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 
  http://www.R-project.org/posting-guide.html
 
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/
  posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

 [[alternative HTML version deleted

Re: [R] hash - extract key values

2015-03-28 Thread Brian Smith
Exactly. Used to work for me, but not anymore. I tried restarting session,
installing the most recent package of 'hash' etc.

Here is my sessionInfo():

 sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
 [1] grid  parallel  stats4stats graphics  grDevices utils
datasets  methods   base

other attached packages:
 [1] mapdata_2.2-3maps_2.3-9   org.Hs.eg.db_3.0.0
multicore_0.1-7  nlme_3.1-120 Rgraphviz_2.10.0
 [7] biomaRt_2.22.0   topGO_2.18.0 SparseM_1.6
 GO.db_3.0.0  graph_1.44.1 mouse4302.db_3.0.0
[13] org.Mm.eg.db_3.0.0   RSQLite_1.0.0DBI_0.3.1
 AnnotationDbi_1.28.1 GenomeInfoDb_1.2.4   IRanges_2.0.1
[19] S4Vectors_0.4.0  Biobase_2.26.0   BiocGenerics_0.12.1
 XML_3.98-1.1 gap_1.1-12   som_0.3-5
[25] pvclust_1.3-2foreign_0.8-63   hash_3.0.1

loaded via a namespace (and not attached):
[1] bitops_1.0-6lattice_0.20-29 RCurl_1.95-4.5  tools_3.1.2




On Fri, Mar 27, 2015 at 9:54 PM, Boris Steipe boris.ste...@utoronto.ca
wrote:

 Works for me :

  library(hash)
 hash-2.2.6 provided by Decision Patterns

  hx - hash( c('a','b','c'), 1:3 )
  class(hx)
 [1] hash
 attr(,package)
 [1] hash
  hx$a
 [1] 1
  keys(hx)
 [1] a b c


 Maybe restart your session? Clear your workspace? Upgrade?

 B.





 On Mar 27, 2015, at 7:39 PM, Brian Smith bsmith030...@gmail.com wrote:

  Hi,
 
  I was trying to use hash, but can't seem to get the keys from the hash.
  According to the hash documentation ('hash' package pdf, the following
  should work:
 
  hx - hash( c('a','b','c'), 1:3 )
  class(hx)
  [1] hash
  attr(,package)
  [1] hash
  hx$a
  [1] 1
  keys(hx)
  Error in (function (classes, fdef, mtable)  :
   unable to find an inherited method for function ‘keys’ for signature
  ‘hash’
 
  How can I get the keys for my hash?
 
  thanks!
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

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

[R] hash - extract key values

2015-03-27 Thread Brian Smith
Hi,

I was trying to use hash, but can't seem to get the keys from the hash.
According to the hash documentation ('hash' package pdf, the following
should work:

 hx - hash( c('a','b','c'), 1:3 )
 class(hx)
[1] hash
attr(,package)
[1] hash
 hx$a
[1] 1
 keys(hx)
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘keys’ for signature
‘hash’

How can I get the keys for my hash?

thanks!

[[alternative HTML version deleted]]

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

[R] ggplot2 boxplot points (size,color,shape)

2015-03-17 Thread Brian Smith
Hi,

I am trying to create a boxplot (with geom_jitter) such that the points
from one set of values are shown as circles, and the second set of points
also as circles, but with no fill. In other words, how can I control the
shape and color for the points appearing in this boxplot?

===
library(ggplot2)

myvect1 - rnorm(100)
myvect2 - rnorm(100)

fill1 - rep('solid',100)
fill2 - rep('solid',100)

myvect - c(myvect1,myvect2)
myfill - c(fill1,fill2)

mydat - data.frame(myvect,myfill)

## How can I control the shape, color of the points in the boxplot based on
the values of myfill?
ggplot(data=mydat,aes(x='test',y=myvect)) + geom_boxplot() + geom_jitter()

==

thanks!!

[[alternative HTML version deleted]]

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


Re: [R] read.table - replaces 'T' with 'TRUE'

2015-01-27 Thread Brian Smith
Thanks!!

On Mon, Jan 26, 2015 at 5:23 PM, peter dalgaard pda...@gmail.com wrote:


  On 26 Jan 2015, at 23:10 , Duncan Murdoch murdoch.dun...@gmail.com
 wrote:
 
  read.table(other args as before, colClasses = character)
 
  (You might want factor instead of character.)

 Or maybe not. I'd expect trouble with getting the levels set to
 c(C,A,G,T) for all columns.

 Is this always one single line of CGAT? If so, scan(file, what=) might
 be a more straightforward approach.

 --
 Peter Dalgaard, Professor,
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@gmail.com










[[alternative HTML version deleted]]

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


[R] read.table - replaces 'T' with 'TRUE'

2015-01-26 Thread Brian Smith
Hi,

I had a table with 'T's in it. When I try to read the table, it replaces
all the 'T's with TRUE. Is there a way that I can retain the Ts?

thanks!


Sample table (test.txt):

xx1 xx2 0 0 2 2 A A G G A G A A C C G G G G G G A G A A A G A G A A G G A A
A G G G A G A G G G A G A G G G G G A G G G G G A A C C G G A C A G G G A G
G G A C C C A G A G G G G G G G A A A C A G G G G G G G G G A A G G G G T T
G G A A G G G G G G A A G G G G G G G G A G T T A G A G G G A G C G G G G G
G G A G A G A C G G G G A G A G G G G G G G G G G G C C G G G G A A A G A G
A G G G A G A A A G A G G G G G A A A G G G G G G G A A G G G G G G G G G G
G G A G A G G G G G A A G G G G G G G G G G A A G G G G A G G G A A C C G G
C C C G G G A A G G G G G G C C A A G G G G G G A G G G C C G G A A A A G G
A A G G A G G G A A A G A A G G G G C C G G G G A A G G A A A G G G G G G G
G G A A A G G G C C G G G G A A G G G G G G G G A A G G G G G G G G G G A A
G G C C A A A G A A A A A A A G G G G G A C G G G G A A A G A A T T A G A A
T T A A A A G G G G C C A G G G A G G G G G C C A C A G A G A G A G A G A G
C C A G G G A G A G A A A A A G A G A A A G A G A C A C A C C C A G A G G G
G G A G A G C C G G A G A G A G G G G G A G A G A G A G A G A G G G G G A G
A A A G G G G G A G G G G G G G A A A A G G G G A A A C A G G G A G C C A G
A G G G G G A T A G A G A C A A A G C C A G G G G G A G A A G G A G C C G G
A A G G C C C C G G G G T T C C


 r1 - read.table(paste(exdir,'test.txt',sep=''),na.strings=,fill=T)
 r1

 r1
   V1  V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20
V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32
1 xx1 xx2  0  0  2  2  A  A  G   G   A   G   A   A   C   C   G   G   G
G   G   G   A   G   A   A   A   G   A   G   A   A
  V33 V34 V35 V36 V37 V38 V39 V40 V41 V42 V43 V44 V45 V46 V47 V48 V49 V50
V51 V52 V53 V54 V55 V56 V57 V58 V59 V60 V61 V62
1   G   G   A   A   A   G   G   G   A   G   A   G   G   G   A   G   A   G
G   G   G   G   A   G   G   G   G   G   A   A
  V63 V64 V65 V66 V67 V68 V69 V70 V71 V72 V73 V74 V75 V76 V77 V78 V79 V80
V81 V82 V83 V84 V85 V86 V87 V88 V89 V90 V91 V92
1   C   C   G   G   A   C   A   G   G   G   A   G   G   G   A   C   C   C
A   G   A   G   G   G   G   G   G   G   A   A
  V93 V94 V95 V96 V97 V98 V99 V100 V101 V102 V103 V104 V105 V106 V107 V108
V109 V110 V111 V112 V113 V114 V115 V116 V117
1   A   C   A   G   G   G   GGGGGGAAG
GGG TRUE TRUEGGAAG
  V118 V119 V120 V121 V122 V123 V124 V125 V126 V127 V128 V129 V130 V131
V132 V133 V134 V135 V136 V137 V138 V139 V140 V141
1GGGGGAAGGGGGGG
GAG TRUE TRUE

[[alternative HTML version deleted]]

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


[R] package multicore: check progress?

2014-11-14 Thread Brian Smith
Hi,

I use multicore package quite a lot. However, I want to find a way to check
on the progress of my job. For example:

ftest - function(x){
if(x %% 100 == 0) print(x)
y - 2x

return(y)
}

res - mclapply(1:1000,ftest)


This would print the value of x in a for loop, but doesn't produce anything
when using the mclapply function.

Is there a way to check on the progress of the job?

thanks!

[[alternative HTML version deleted]]

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


[R] Basic plot density question

2014-06-18 Thread Brian Smith
Hi,

I wanted to plot two different density profiles. My code looks like:


x1 - rnorm(100,mean=0,sd=1)
x2 - rnorm(100,mean=1,sd=1)

plot(density(x1),xlab=,col=red,main=)
par(new=T)
plot(density(x2),xlab=,col=blue,main=)


However, the x-axis values don't match up for the two plots. Is there a way
I can fix the axis so that the two plots are comparable? Similarly for the
y-axis...

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] Basic plot density question

2014-06-18 Thread Brian Smith
Thanks Greg!


On Wed, Jun 18, 2014 at 11:15 AM, Greg Snow 538...@gmail.com wrote:

 First you should do your best to forget that you ever saw the command
 par(new=T), rip that page out of any book you saw it in, blacklist
 any webpage etc.  In general (as you see) it causes more problems than
 it solves.

 Now to do what you want there are a couple of options, one of the
 simplest is to use the lines function:

 d1 - density(x1)
 d2 - density(x2)
 plot(d1, xlab='', col='red',main='', ylim=range(d1$y,d2$y),
 xlim=range(d1$x,d2$x) )
 lines(d2, col='blue')

 Other options include the matplot function or tools in the lattice and
 ggplot2 packages.

 On Wed, Jun 18, 2014 at 8:48 AM, Brian Smith bsmith030...@gmail.com
 wrote:
  Hi,
 
  I wanted to plot two different density profiles. My code looks like:
 
 
  x1 - rnorm(100,mean=0,sd=1)
  x2 - rnorm(100,mean=1,sd=1)
 
  plot(density(x1),xlab=,col=red,main=)
  par(new=T)
  plot(density(x2),xlab=,col=blue,main=)
 
 
  However, the x-axis values don't match up for the two plots. Is there a
 way
  I can fix the axis so that the two plots are comparable? Similarly for
 the
  y-axis...
 
  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.



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


[[alternative HTML version deleted]]

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


[R] boxplot axis font size

2014-05-25 Thread Brian Smith
Hi,

I wanted to have a different font for my x-axis and y-axis. How can I use
the par function to specify different font sizes for x and y axis? For
example:

x - matrix(rnorm(2000),200,10)
colnames(x) - letters[1:10]
par(cex.axis=0.5)
boxplot(x,cex=0.2)

But this sets the font size to 0.5 for both the x and y axis? How can I
make the y-axis to 1.5?

thanks.

[[alternative HTML version deleted]]

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


[R] Question on 'get'

2014-03-06 Thread Brian Smith
Hi,

I was trying to get at some values from 'data' using the get function. Here
is my code:

 class(data)
[1] data.frame
 class(data$gender.factor)
[1] factor
 head(data$gender.factor)
[1] Male   Female Male   Female Male   Female
Levels: Male Female
 xx - get(data$gender.factor)
Error in get(data$gender.factor) :
  object 'data$gender.factor' not found
 traceback()
2: get(data$gender.factor)
1: get(data$gender.factor)


What should I be doing to read in the values using the get command?

thanks!

[[alternative HTML version deleted]]

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


[R] lapply?

2013-11-14 Thread Brian Smith
Hi,

I was trying to use lapply to create a matrix from a list:

uu - list()
uu[[1]] - c(1,2,3)
uu[[2]] - c(3,4,5)

The output I desire is a matrix with 2 rows and 3 columns, so I try:

xx - lapply(uu,rbind)

Obviously, I'm not doing something right, but what!?

[[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] lapply?

2013-11-14 Thread Brian Smith
Thanks all! So many ways


On Thu, Nov 14, 2013 at 10:35 AM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 You are applying rbind to each element of the list, not rbinding it with
 the others. Try instead

 do.call(rbind, uu)

 Hope this helps,

 Rui Barradas

 Em 14-11-2013 15:20, Brian Smith escreveu:

 Hi,

 I was trying to use lapply to create a matrix from a list:

 uu - list()
 uu[[1]] - c(1,2,3)
 uu[[2]] - c(3,4,5)

 The output I desire is a matrix with 2 rows and 3 columns, so I try:

 xx - lapply(uu,rbind)

 Obviously, I'm not doing something right, but what!?

 [[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] about mix type clust algorithm

2013-07-22 Thread Brian Smith
Thanks for the article, Jose! It looks very interesting.


On Mon, Jul 22, 2013 at 7:12 AM, Jose Iparraguirre 
jose.iparragui...@ageuk.org.uk wrote:

 Dear Cheng,

 This question exceeds the topics of this group. However, you may benefit
 from this recent (and excellent) paper along with the discussions:

 Henning, C. and T. Liao (2013). How to find an appropriate clustering for
 mixed-type variables with application to socio-economy stratification,
 Journal of Applied Statistics, Vol. 62, Part 3, pp. 309-369.

 Regards,

 José

 Prof. José Iparraguirre
 Chief Economist
 Age UK

 Profesor de Economía
 Universidad de Morón
 Morón, Buenos Aires, Argentina


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Cheng, Yi
 Sent: 22 July 2013 07:23
 To: r-help@r-project.org
 Subject: [R] about mix type clust algorithm

 Hi:
 I have tried to find the appropriate clust algorithm for mixed type of
 data.
 The suggested way I see is:

 1.   use daisy to get the dissimilarity matrix

 2.   use PAM/hclust by providing the dissimilarity matrix, to get the
 clusters
 but by following this, when the data set grows bigger say 10,000 rows of
 data, the dissimilarity matrix will be O(n^2), and out of memory will occur.
 I am wondering is there any better ways to do the mixed type cluster?

 Cheng Yi


 [[alternative HTML version deleted]]

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

 The Wireless from Age UK | Radio for grown-ups.

 www.ageuk.org.uk/thewireless


 If you’re looking for a radio station that offers real variety, tune in to
 The Wireless from Age UK.
 Whether you choose to listen through the website at
 www.ageuk.org.uk/thewireless, on digital radio (currently available in
 London and Yorkshire) or through our TuneIn Radio app, you can look forward
 to an inspiring mix of music, conversation and useful information 24 hours
 a day.




 ---
 Age UK is a registered charity and company limited by guarantee,
 (registered charity number 1128267, registered company number 6825798).
 Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

 For the purposes of promoting Age UK Insurance, Age UK is an Appointed
 Representative of Age UK Enterprises Limited, Age UK is an Introducer
 Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth
 Access for the purposes of introducing potential annuity and health
 cash plans customers respectively.  Age UK Enterprises Limited, JLT
 Benefit Solutions Limited and Simplyhealth Access are all authorised and
 regulated by the Financial Services Authority.
 --

 This email and any files transmitted with it are confidential and intended
 solely for the use of the individual or entity to whom they are
 addressed. If you receive a message in error, please advise the sender and
 delete immediately.

 Except where this email is sent in the usual course of our business, any
 opinions expressed in this email are those of the author and do not
 necessarily reflect the opinions of Age UK or its subsidiaries and
 associated companies. Age UK monitors all e-mail transmissions passing
 through its network and may block or modify mails which are deemed to be
 unsuitable.

 Age Concern England (charity number 261794) and Help the Aged (charity
 number 272786) and their trading and other associated companies merged
 on 1st April 2009.  Together they have formed the Age UK Group, dedicated
 to improving the lives of people in later life.  The three national
 Age Concerns in Scotland, Northern Ireland and Wales have also merged with
 Help the Aged in these nations to form three registered charities:
 Age Scotland, Age NI, Age Cymru.




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] ggplot2 error: Error in as.environment(where) : 'where' is missing

2013-06-11 Thread Brian Smith
Hmm...I think it used to work before, but it gives an error now. Here is
some sample code:

=
library(ggplot2)
Sample - rep(c('A','B'),rep(10,2))
Vals - sample(1:1000,20)
dataf - as.data.frame(cbind(Sample,Vals))
myplot - ggplot(dataf,aes(x=Vals,colour=Sample)) + geom_density()
myplot
=

I get the following error:

Error in as.environment(where) : 'where' is missing

Am I doing something wrong?

thanks!



 sessionInfo() ***

R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] gridExtra_0.9.1   sm_2.2-4.1imputation_2.0.1
locfit_1.5-9  TimeProjection_0.2.0  Matrix_1.0-12
timeDate_2160.97
 [8] lubridate_1.2.0   gbm_2.0-8 survival_2.37-4
gplots_2.11.0 MASS_7.3-23   KernSmooth_2.23-10
caTools_1.14
[15] gdata_2.12.0  heatmap.plus_1.3  ggdendro_0.1-12
ggplot2_0.9.3.1   hgu133a.db_2.7.1  affy_1.34.0
genefilter_1.38.0
[22] biomaRt_2.12.0org.Hs.eg.db_2.7.1GOstats_2.22.0
graph_1.34.0  Category_2.22.0   GO.db_2.7.1
RSQLite_0.11.2
[29] DBI_0.2-5 geneplotter_1.34.0lattice_0.20-15
annotate_1.34.1   AnnotationDbi_1.18.4  Biobase_2.16.0
BiocGenerics_0.2.0
[36] colorRamps_2.3RColorBrewer_1.0-5sparcl_1.0.3
gap_1.1-9 plotrix_3.4-6 som_0.3-5
pvclust_1.2-2
[43] RobustRankAggreg_1.0  impute_1.30.0 reshape_0.8.4
plyr_1.8  zoo_1.7-9 data.table_1.8.8
foreach_1.4.0
[50] foreign_0.8-53languageR_1.4 preprocessCore_1.18.0
gtools_2.7.1  BiocInstaller_1.4.9   hash_2.2.6

loaded via a namespace (and not attached):
 [1] affyio_1.24.0bitops_1.0-4.2   codetools_0.2-8  colorspace_1.2-1
dichromat_2.0-0  digest_0.6.3 GSEABase_1.18.0  gtable_0.1.2
IRanges_1.14.4
[10] iterators_1.0.6  labeling_0.1 munsell_0.4  proto_0.3-10
RBGL_1.32.1  RCurl_1.95-4.1   reshape2_1.2.2   scales_0.2.3
stats4_2.15.2
[19] stringr_0.6.2tools_2.15.2 tree_1.0-33  XML_3.96-1.1
xtable_1.7-1 zlibbioc_1.2.0

[[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 error: Error in as.environment(where) : 'where' is missing

2013-06-11 Thread Brian Smith
D'oh!


On Tue, Jun 11, 2013 at 2:26 PM, arun smartpink...@yahoo.com wrote:



 Hi,
 dataf - as.data.frame(cbind(Sample,Vals))
  str(dataf)
 #'data.frame':20 obs. of  2 variables:
 # $ Sample: Factor w/ 2 levels A,B: 1 1 1 1 1 1 1 1 1 1 ...
 # $ Vals  : Factor w/ 20 levels 121,154,159,..: 20 12 13 1 2 14 18 5
 17 10 ...
 ggplot(dataf,aes(x=Vals,colour=Sample))+geom_density()
 #Error in as.environment(where) : 'where' is missing


 dataf- data.frame(Sample,Vals)
  str(dataf)
 #'data.frame':20 obs. of  2 variables:
 # $ Sample: Factor w/ 2 levels A,B: 1 1 1 1 1 1 1 1 1 1 ...
 # $ Vals  : int  96 712 765 121 154 78 821 258 812 51 ...

 ggplot(dataf,aes(x=Vals,colour=Sample))+geom_density() #no error
 A.K.




 - Original Message -
 From: Brian Smith bsmith030...@gmail.com
 To: r-help Help r-help@r-project.org
 Cc:
 Sent: Tuesday, June 11, 2013 1:44 PM
 Subject: [R] ggplot2 error: Error in as.environment(where) : 'where' is
 missing

 Hmm...I think it used to work before, but it gives an error now. Here is
 some sample code:

 =
 library(ggplot2)
 Sample - rep(c('A','B'),rep(10,2))
 Vals - sample(1:1000,20)
 dataf - as.data.frame(cbind(Sample,Vals))
 myplot - ggplot(dataf,aes(x=Vals,colour=Sample)) + geom_density()
 myplot
 =

 I get the following error:

 Error in as.environment(where) : 'where' is missing

 Am I doing something wrong?

 thanks!



  sessionInfo() ***

 R version 2.15.2 (2012-10-26)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

 other attached packages:
 [1] gridExtra_0.9.1   sm_2.2-4.1imputation_2.0.1
 locfit_1.5-9  TimeProjection_0.2.0  Matrix_1.0-12
 timeDate_2160.97
 [8] lubridate_1.2.0   gbm_2.0-8 survival_2.37-4
 gplots_2.11.0 MASS_7.3-23   KernSmooth_2.23-10
 caTools_1.14
 [15] gdata_2.12.0  heatmap.plus_1.3  ggdendro_0.1-12
 ggplot2_0.9.3.1   hgu133a.db_2.7.1  affy_1.34.0
 genefilter_1.38.0
 [22] biomaRt_2.12.0org.Hs.eg.db_2.7.1GOstats_2.22.0
 graph_1.34.0  Category_2.22.0   GO.db_2.7.1
 RSQLite_0.11.2
 [29] DBI_0.2-5 geneplotter_1.34.0lattice_0.20-15
 annotate_1.34.1   AnnotationDbi_1.18.4  Biobase_2.16.0
 BiocGenerics_0.2.0
 [36] colorRamps_2.3RColorBrewer_1.0-5sparcl_1.0.3
 gap_1.1-9 plotrix_3.4-6 som_0.3-5
 pvclust_1.2-2
 [43] RobustRankAggreg_1.0  impute_1.30.0 reshape_0.8.4
 plyr_1.8  zoo_1.7-9 data.table_1.8.8
 foreach_1.4.0
 [50] foreign_0.8-53languageR_1.4 preprocessCore_1.18.0
 gtools_2.7.1  BiocInstaller_1.4.9   hash_2.2.6

 loaded via a namespace (and not attached):
 [1] affyio_1.24.0bitops_1.0-4.2   codetools_0.2-8  colorspace_1.2-1
 dichromat_2.0-0  digest_0.6.3 GSEABase_1.18.0  gtable_0.1.2
 IRanges_1.14.4
 [10] iterators_1.0.6  labeling_0.1 munsell_0.4  proto_0.3-10
 RBGL_1.32.1  RCurl_1.95-4.1   reshape2_1.2.2   scales_0.2.3
 stats4_2.15.2
 [19] stringr_0.6.2tools_2.15.2 tree_1.0-33  XML_3.96-1.1
 xtable_1.7-1 zlibbioc_1.2.0

 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


[R] Selecting divergent colors

2013-06-10 Thread Brian Smith
Hi,

I was trying to make a density plot with 13 samples. To distinguish each
sample, it would be good if each color is as different as possible from the
other colors. I could use the built in function, but that does not do more
than 8 colors and then goes back to recycling the cols. If I use a palette,
then it is really difficult to distinguish between the colors.

So, is there a way that I can select a large number of colors (i.e. perhaps
20) that are as different from each other as possible?

Here is my example code using the palette:

**
mat - matrix(sample(1:1000,1000,replace=T),nrow=20,ncol=20)
snames - paste('Sample_',1:ncol(mat),sep='')
colnames(mat) - snames

mycols - palette(rainbow(ncol(mat)))

for(k in 1:ncol(mat)){
  plot(density(mat[,k]),col=mycols[k],xlab='',ylab='',axes=F,main=F)
  par(new=T)
}

legend(x='topright',legend=snames,fill=mycols)



thanks!

[[alternative HTML version deleted]]

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


[R] scatterplot3d with densCols ?

2013-03-28 Thread Brian Smith
Hi,

I was trying to make a 3D plot using densCols. The documentation for
densCols doesn't look like it'll work for 3D. For example:

-
library(scatterplot3d)

v1 - rnorm(1)
v2 - rnorm(1)
v3 - rnorm(1)

## 2D with denscols
mat1 - cbind(v1,v2)
mcols1 - densCols(mat1)
plot(mat1,col=mcols1)

mat - cbind(v1,v2,v3)
mcols - densCols(mat) ## No go?

## 3D version with no densCols parameter
scatterplot3d(mat,pch=16)

## gives error
scatterplot3d(mat,col=mcols,pch=16)

-

Is there any workaround/modification to the densCols function that might
make this work?

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] scatterplot3d with densCols ?

2013-03-28 Thread Brian Smith
Ah, yes, correct - the option is color.

However, I think the problem (i.e. MY problem) is with densCols - I need it
to calculate the 3D density!

thanks!




On Thu, Mar 28, 2013 at 6:52 AM, Pascal Oettli kri...@ymail.com wrote:

 Hello,

 According to ?scatterplot3d, the option is 'color', not 'col'.

 scatterplot3d(mat,color=mcols,**pch=16)

 HTH,
 Pascal



 On 28/03/13 19:41, Brian Smith wrote:

 Hi,

 I was trying to make a 3D plot using densCols. The documentation for
 densCols doesn't look like it'll work for 3D. For example:

 --**---
 library(scatterplot3d)

 v1 - rnorm(1)
 v2 - rnorm(1)
 v3 - rnorm(1)

 ## 2D with denscols
 mat1 - cbind(v1,v2)
 mcols1 - densCols(mat1)
 plot(mat1,col=mcols1)

 mat - cbind(v1,v2,v3)
 mcols - densCols(mat) ## No go?

 ## 3D version with no densCols parameter
 scatterplot3d(mat,pch=16)

 ## gives error
 scatterplot3d(mat,col=mcols,**pch=16)

 --**---

 Is there any workaround/modification to the densCols function that might
 make this work?

 thanks!

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] Writing a hyperlink to a csv file

2013-03-16 Thread Brian Smith
Hi Marc,

Thanks for the reply.

The question is whether it is possible to write some text (with a
hyperlink) to a csv file, such that when you open the file in excel, it
shows the text as hyperlinked. I guess it boils down to whether there are
any 'tags' that you can put in the csv/txt file so that excel recognizes it
as hyperlinked text.

Does that make sense?

thanks!

On Sat, Mar 16, 2013 at 4:16 AM, Marc Girondot marc_...@yahoo.fr wrote:

 Le 15/03/13 12:53, Brian Smith a écrit :

  Hi,

 I was wondering if it is possible to create a hyperlink in a csv file
 using
 R code and some package. For example, in the following code:

 links - cbind(rep('Click for Google',3),google search address goes
 here)
 ## R Mailing list blocks if I put the actual web address here
 write.table(links,'test.csv',
 sep=',',row.names=F,col.names=**F)


 the web address should be linked to 'Click for Google'.

 The browseURL() function open your internet browser with the url indicated
 as parameter:
 browseURL(http://www.r-**project.org http://www.r-project.org)

 But I am not sure how you want call it. You should be more precise about
 the context you want to use it.
 For example:

 links - data.frame(c(' for Google', ' for Bing'),
c(http://www.google.com;, http://www.bing.com;),
 stringsAsFactors = FALSE)
 cat(Choose an option:\n, paste(1:2, links[,1],\n))
 f-scan(nmax=1, quiet=TRUE)

 browseURL(links[f,2])

 Sincerely
 Marc

 --
 __**
 Marc Girondot, Pr

 Laboratoire Ecologie, Systématique et Evolution
 Equipe de Conservation des Populations et des Communautés
 CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
 Bâtiment 362
 91405 Orsay Cedex, France

 Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
 e-mail: marc.giron...@u-psud.fr
 Web: 
 http://www.ese.u-psud.fr/epc/**conservation/Marc.htmlhttp://www.ese.u-psud.fr/epc/conservation/Marc.html
 Skype: girondot



[[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] Creating a hyperlink in a csv file

2013-03-15 Thread Brian Smith
Hi,

I was wondering if it is possible to create a hyperlink in a csv file using
R code and some package. For example, in the following code:

links - cbind(rep('Click for Google',3),http://www.google.com;)
write.table(links,'test.csv',sep=',',row.names=F,col.names=F)


the web address should be linked to 'Click for Google'.

many thanks!

[[alternative HTML version deleted]]

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


[R] Writing a hyperlink to a csv file

2013-03-15 Thread Brian Smith
Hi,

I was wondering if it is possible to create a hyperlink in a csv file using
R code and some package. For example, in the following code:

links - cbind(rep('Click for Google',3),google search address goes here)
## R Mailing list blocks if I put the actual web address here
write.table(links,'test.csv',
sep=',',row.names=F,col.names=F)


the web address should be linked to 'Click for Google'.

many thanks!

[[alternative HTML version deleted]]

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


[R] Testing for significance of overlap in three sets - mantelhaen test?

2013-03-12 Thread Brian Smith
Hi,

My apologies for the naive question!

I have three overlapping sets and I want to find the probability of finding
a larger/greater intersection for 'A intersect B intersect C' (in the
example below, I want to find the probability of finding more than 135
elements that are common in sets A, B  C). For a two set problem, I guess
I would do a Fisher or chi-square test. Here is what I have attempted so
far:

#

### Prepare a 3 way contingency table:
mytable - array(c(135,116,385,6256,
48,97,274,9555),
  dim = c(2,2,2),
  dimnames = list(
Is_C = c('Yes','No'),
Is_B = c('Yes','No'),
Is_A = c('Yes','No')))

## test
mantelhaen.test(myrabbit, exact = TRUE, alternative = greater)

## end code

Is this the right test (alongwith the current parameters) to determine what
I want or is there a more appropriate test for this?



many thanks!!

[[alternative HTML version deleted]]

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


[R] Changing default order of plots in par

2013-03-09 Thread Brian Smith
Hi,

I wanted to change the order of how the plots appear in a multiplot
scenario. For example, in the code below:

#

pdf('test.pdf',width=8,height=8)
par(mfrow = c(2,2))

for(i in 1:2){
  v1 - sample(1:1000,50)
  v2 - sample(1:1000,50)
  mat - cbind(v1,v2)

  plot(v1,v2)
  boxplot(mat)

}
dev.off()

###

The plot ordering is that the first row gets filled in first, then the
second row etc. But how can I change it so that in the code above, I get
both the plots in the first row and the both the boxplots in the second row?

many thanks!

[[alternative HTML version deleted]]

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


Re: [R] Changing default order of plots in par

2013-03-09 Thread Brian Smith
Thanks Rui! That worked.

On Sat, Mar 9, 2013 at 4:22 PM, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 Instead of mfrow use mfcol and the order becomes col by col.

 Hope this helps,

 Rui Barradas

 Em 09-03-2013 20:55, Brian Smith escreveu:

 Hi,

 I wanted to change the order of how the plots appear in a multiplot
 scenario. For example, in the code below:

 #

 pdf('test.pdf',width=8,height=**8)
 par(mfrow = c(2,2))

 for(i in 1:2){
v1 - sample(1:1000,50)
v2 - sample(1:1000,50)
mat - cbind(v1,v2)

plot(v1,v2)
boxplot(mat)

 }
 dev.off()

 ###

 The plot ordering is that the first row gets filled in first, then the
 second row etc. But how can I change it so that in the code above, I get
 both the plots in the first row and the both the boxplots in the second
 row?

 many thanks!

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] write.table and append

2013-02-08 Thread Brian Smith
Hi,

I am trying to append tables on file with this sample code:

for(i in 1:2){
mat - data.frame(sample(1:30,9),3,3)
colnames(mat) - letters[1:3]
ifelse(i ==
1,write.table(mat,paste('test.txt',sep=''),row.names=F),

write.table(mat,paste('test.txt',sep=''),row.names=F,col.names=F,append=TRUE))
}

However, this gives an error:

Error in ifelse(i == 1, write.table(mat, paste(test.txt, sep = ),  :
  replacement has length zero

- Should I be passing in some other parameters or using a different
function to append tables to file?

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] write.table and append

2013-02-08 Thread Brian Smith
Thanks Louis! That seems to work!

On Fri, Feb 8, 2013 at 10:06 AM, Louis Aslett lasl...@louisaslett.comwrote:

 I believe your problem stems from using ifelse() actually ... it
 requires the statements which it runs to return a value with the same
 shape as the test, which write.table() isn't doing.

 Just change it to a regular if with an else and you'll be fine:

 for(i in 1:2){
   mat - data.frame(sample(1:30,9),3,3)
   colnames(mat) - letters[1:3]
   if(i == 1){
 write.table(mat,paste('test.txt',sep=''),row.names=F)
   } else {

 write.table(mat,paste('test.txt',sep=''),row.names=F,col.names=F,append=TRUE)
   }
 }

 Hope that helps,

 Louis


 On Fri, Feb 8, 2013 at 2:40 PM, Brian Smith bsmith030...@gmail.com
 wrote:
 
  Hi,
 
  I am trying to append tables on file with this sample code:
 
  for(i in 1:2){
  mat - data.frame(sample(1:30,9),3,3)
  colnames(mat) - letters[1:3]
  ifelse(i ==
  1,write.table(mat,paste('test.txt',sep=''),row.names=F),
 
 
 write.table(mat,paste('test.txt',sep=''),row.names=F,col.names=F,append=TRUE))
  }
 
  However, this gives an error:
 
  Error in ifelse(i == 1, write.table(mat, paste(test.txt, sep = ),  :
replacement has length zero
 
  - Should I be passing in some other parameters or using a different
  function to append tables to file?
 
  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.


[[alternative HTML version deleted]]

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


Re: [R] write.table and append

2013-02-08 Thread Brian Smith
Ah, I didn't know this! Thanks Ben.

On Fri, Feb 8, 2013 at 10:18 AM, Ben Tupper btup...@bigelow.org wrote:

 Hi,

 On Feb 8, 2013, at 9:40 AM, Brian Smith wrote:

  Hi,
 
  I am trying to append tables on file with this sample code:
 
 for(i in 1:2){
 mat - data.frame(sample(1:30,9),3,3)
 colnames(mat) - letters[1:3]
 ifelse(i ==
  1,write.table(mat,paste('test.txt',sep=''),row.names=F),
 
 
 write.table(mat,paste('test.txt',sep=''),row.names=F,col.names=F,append=TRUE))
 }
 
  However, this gives an error:
 
  Error in ifelse(i == 1, write.table(mat, paste(test.txt, sep = ),  :
   replacement has length zero
 
  - Should I be passing in some other parameters or using a different
  function to append tables to file?


 You might try assign each parameter based upon the value of i instead of
 trying to manage two different calls to write.table through an ifelse
 function.  ifelse doesn't seem to like the value returned by write.table
 (NULL).  Here's a simply example...

  ok - ifelse( TRUE, NULL, NULL)
 Error in ifelse(TRUE, NULL, NULL) : replacement has length zero
  ok - ifelse( FALSE, NULL, NULL)
 Error in ifelse(FALSE, NULL, NULL) : replacement has length zero

 I think that is what the warning in ?ifelse is alluding to.  You would
 only know that write.table returns NULL if you have bitten by it before.  I
 have bite marks.

 for(i in 1:2){
mat - data.frame(sample(1:30,9),3,3)
colnames(mat) - letters[1:3]
write.table(mat, file = test.txt,
   row.names = FALSE,
   col.names = (i == 1),
   append = (i != 1) )
 }


 Cheers,
 Ben

 
  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.

 Ben Tupper
 Bigelow Laboratory for Ocean Sciences
 60 Bigelow Drive, P.O. Box 380
 East Boothbay, Maine 04544
 http://www.bigelow.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.


[R] Lattice/panel.bwplot and Gviz: Boxplot question

2012-07-22 Thread Brian Smith
Hi,

I was using Gviz package to create a boxplot. I understand that Gviz uses
panel.bwplot to create the boxplot.

Is there any way that I can remove the dashed line surrounding each pair of
boxplots?

Here is some sample code:

#

library(Gviz)

thisdata - matrix(sample(1:100,60),nrow=10,ncol=6)
positions - sample(1:100,6)
limit1 - min(positions)-1
limit2 - max(positions)+1
colnames(thisdata) - positions
dgroups - c(rep('sample1',6),rep('sample2',4))
chr - chr1


d4x - DataTrack(start=positions, width=2,
data=thisdata,chromosome=chr,
name=test,groups = dgroups,type = boxplot,
box.ratio=0.6,
box.width=1.5

)  #box and whisker plot

plotTracks(d4x,from=limit1,to=limit2)

###

many thanks!

[[alternative HTML version deleted]]

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


[R] ggplot2: legend for geom_rug() ..?

2012-06-06 Thread Brian Smith
Hi,

I was trying to make another legend for the rug plot. Sample code:


library(ggplo2)
ids - paste('id_',1:3,sep='')
before - sample(9)
after - sample(1:10,9)
dat - as.matrix(cbind(before,after))
rownames(dat) - rep(ids,3)
position - c(rep(10,3),rep(13,3),rep(19,3))

mdat - cbind(melt(dat),position)

ggplot(mdat, aes(position, value)) + geom_point(aes(colour = X2)) +
geom_rug(subset = .(position  14),aes(y=NULL),color=orange) +
geom_rug(subset = .(position  14),aes(y=NULL),color=black)




This gives the plot correctly, but how can I add another legend that would
give some more information on the rugplot (e.g. that 'orange' line =
'London', and 'black' line = 'NYC')?

thanks!!

[[alternative HTML version deleted]]

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


[R] ggplot2: Dendrogram text position

2012-05-14 Thread Brian Smith
Hi,

I was trying to create a dendrogram using ggplot2. Everything seems to be
looking ok except that the text labels are too close to the dendrogram (in
the example below, 'a','b', ..). Is there a way that I can put a little gap
between where the dendrogram ends and the label begins?

thanks!!

= code ==

library(ggplot2)

mat - matrix(sample(1:1000,180),12,15)
rownames(mat) - letters[1:12]
colnames(mat) - paste('c',1:15,sep='')

dates - sample(1:3,12,replace=T)

hc - hclust(dist(mat))
order - hc$order
batch - as.factor(as.numeric(dates[order]))  ## batchorder
roworder - rownames(mat)[order]

dd.row - as.dendrogram(hc)
ddata_x - dendro_data(dd.row)
labs - label(ddata_x)
labs2 - cbind(labs,batch,roworder)

p2 - ggplot(segment(ddata_x)) +
geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + coord_flip() +
scale_y_reverse(expand=c(0.2, 0)) +
theme_dendro()

p2 + geom_text(data=labs2,
aes(label=roworder, x=x, y=0, colour=batch),size=4)



[[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] Modifying R package code

2012-05-10 Thread Brian Smith
Hi,

I was trying to change some code in an existing package. I downloaded the
source package (say 'package_xx') from CRAN, and changed the R code
provided in the /package_xx/R/xx.R. I then saved the changes and did the R
CMD INSTALL -l /path to modified package/.

Do I need to do something else before the changes will be effective?

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] ggplot2: scale_shape_manual

2012-04-19 Thread Brian Smith
Thanks Brian. That worked. I also wanted to increase the size of the
'points' on the graph. Is there any way I can get rid of the 'legend' (in
this case '3') appearing on the plot?

=== code 
library(ggplot2)

leaves - letters[1:8]
mat - matrix(sample(1:1000,32),nrow=16,ncol=2)
colnames(mat) - paste('t',1:2,sep='')
df - as.data.frame(cbind(mat,leaves))

vals - 1:length(leaves)
names(vals) - leaves

p - ggplot(df,aes(t1,t2))
p + aes(shape = factor(leaves)) + geom_point(aes(colour =
factor(leaves),size=3)) + scale_shape_manual(values=vals)


=

thanks!


On Mon, Apr 16, 2012 at 3:09 PM, Brian Diggs dig...@ohsu.edu wrote:

 On 4/16/2012 7:31 AM, Brian Smith wrote:

 Hi,

 I was trying to replicate one of the graphs given on the ggplot2 website.
 I
 have given a sample code below. I would like to combine the legends, since
 each color is uniquely mapped to a shape.

 ###
 library(ggplot2)

 leaves- letters[1:8]
 mat- matrix(sample(1:1000,32),nrow=**16,ncol=2)
 colnames(mat)- paste('t',1:2,sep='')
 df- as.data.frame(cbind(mat,**leaves))

 vals- 1:length(leaves)
 names(vals)- leaves

 p- ggplot(df,aes(t1,t2))
 p + aes(shape = factor(leaves)) + geom_point(aes(colour =
 factor(leaves))) + scale_shape_manual(,values=**vals)

 

 Which parameter do I need to change?


 add scale_colour_discrete() to your call. In order for scales to be
 combined, the breaks, labels, and title must all be the same. You had
 breaks and labels the same, but not the title.  Alternatively, change the
 scale_shape_manual call to scale_shape_manual(values=**vals).


  thanks!



 --
 Brian S. Diggs, PhD
 Senior Research Associate, Department of Surgery
 Oregon Health  Science University

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] ggplot2: scale_shape_manual

2012-04-16 Thread Brian Smith
Hi,

I was trying to replicate one of the graphs given on the ggplot2 website. I
have given a sample code below. I would like to combine the legends, since
each color is uniquely mapped to a shape.

###
library(ggplot2)

leaves - letters[1:8]
mat - matrix(sample(1:1000,32),nrow=16,ncol=2)
colnames(mat) - paste('t',1:2,sep='')
df - as.data.frame(cbind(mat,leaves))

vals - 1:length(leaves)
names(vals) - leaves

p - ggplot(df,aes(t1,t2))
p + aes(shape = factor(leaves)) + geom_point(aes(colour =
factor(leaves))) + scale_shape_manual(,values=vals)



Which parameter do I need to change?

thanks!

[[alternative HTML version deleted]]

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


[R] Simple color strip

2011-10-19 Thread Brian Smith
Hi,

I was trying to get an image/pdf of a sequence of colors in the order given.
For example:

myCols - c('#BF','#BF','#FF','#FF','#BF','#FF')


I'd like to make a strip of colors as they appear in the order above and
save it as a pdf file. Is there a function in the base package (or some
other package) to do this?

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] Simple color strip

2011-10-19 Thread Brian Smith
Hi Duncan,

Yes, I'd like it without any gaps. There are likely to be at least a hundred
colors, so something that is not as 'tall' (ideally an inch?) and that would
be a mm or two for each color.

thanks!


On Wed, Oct 19, 2011 at 10:49 AM, Duncan Murdoch
murdoch.dun...@gmail.comwrote:

 On 19/10/2011 10:32 AM, Brian Smith wrote:

 Hi,

 I was trying to get an image/pdf of a sequence of colors in the order
 given.
 For example:

 myCols- c('#BF','#BF','#**FF','#FF','#BF','#**
 FF')


 I'd like to make a strip of colors as they appear in the order above and
 save it as a pdf file. Is there a function in the base package (or some
 other package) to do this?


 On 19/10/2011 10:32 AM, Brian Smith wrote:

 Hi,

 I was trying to get an image/pdf of a sequence of colors in the order
 given.
 For example:

 myCols- c('#BF','#BF','#**FF','#FF','#BF','#**
 FF')


 I'd like to make a strip of colors as they appear in the order above and
 save it as a pdf file. Is there a function in the base package (or some
 other package) to do this?



 barplot(rep(1, 6), col=myCols, axes=FALSE)

 There are other options to barplot if you want the bars horizontal, without
 spacing, etc.

 Putting it in a pdf is simple:  just open the pdf() device before you draw,
 and close it afterwards.

 Duncan Murdoch


[[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] Reading data with 'awk' - basics?

2011-10-17 Thread Brian Smith
Hi,

I had a large file for which I require a subset of rows. Instead of reading
it all into memory, I use the awk command to get the relevant rows. However,
I'm doing it pretty inefficiently as I write the subset to disk, before
reading it into R. Is there a way that I can read it into an R object
without writing to disk? For example, this is what I do currently:

## write test sample file
mat1 - matrix(sample(1:100,16),8,2)
fname1 - 'temp1.txt'
fname2 - 'temp2.txt'
write.table(mat1,fname1,sep='\t',row.names=F,col.names=F)

## Read a subset of rows, write to file, and read from file
system(paste(awk '(NR  1  NR  4) {print $0}' ,fname1, 
,fname2,sep=''))
mat2 - read.table(fname2,sep='\t')

print(mat2)
#

Is there a way that I can skip writing to disk?

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] Reading data with 'awk' - basics?

2011-10-17 Thread Brian Smith
Got it. Thanks!

On Mon, Oct 17, 2011 at 9:40 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote:

 On Mon, 17 Oct 2011, Brian Smith wrote:

  Hi,

 I had a large file for which I require a subset of rows. Instead of
 reading
 it all into memory, I use the awk command to get the relevant rows.
 However,
 I'm doing it pretty inefficiently as I write the subset to disk, before
 reading it into R. Is there a way that I can read it into an R object
 without writing to disk? For example, this is what I do currently:

 ## write test sample file
 mat1 - matrix(sample(1:100,16),8,2)
 fname1 - 'temp1.txt'
 fname2 - 'temp2.txt'
 write.table(mat1,fname1,sep='\**t',row.names=F,col.names=F)

 ## Read a subset of rows, write to file, and read from file
 system(paste(awk '(NR  1  NR  4) {print $0}' ,fname1, 
 ,fname2,sep=''))
 mat2 - read.table(fname2,sep='\t')

 print(mat2)
 #

 Is there a way that I can skip writing to disk?


 Use a pipe() connection.


 thanks!

[[alternative HTML version deleted]]

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


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


[[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] ggplot2: changing default colors of boxplot

2011-10-04 Thread Brian Smith
Hi,

I wanted to change the default colors appearing in boxplot. For example, the
following code (from the package/documentation):

===
library(ggplot2)

p - ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(aes(fill = factor(am)))

===

Gives the default colors. What do I need to do to modify this so that:

1. Change the colors from green and red to blue and black
2. Only have the outline of the boxplot colored (and not fill in the box)


thanks,

[[alternative HTML version deleted]]

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


[R] ggplot geom_freqpoly() layers ..?

2011-09-08 Thread Brian Smith
Hi,

I was trying to overlay/combine two freqpoly plots. The sample code below
illustrates the problem. Essentially, I want to do is:

1. Have the same colour for all the lines in 'Plot 1' (and 'Plot 2').
Currently, all the lines in Plot 1 have different colours and all the lines
in Plot 2 have different colors. I'd like for all lines in Plot 1 to be
'red' and all the lines in Plot 2 to be 'black'.
2. Combine both the plots ('Plot 1' and 'Plot 2' as one combined plot -
which I attempt to do in 'Combined Plot'). However, I'm doing something
wrong because with the code for 'Combined Plot' I just get two lines.

 sample code 
library(ggplot2)

## Plot 1 - normal distributions with mean = 0 ##
mat - matrix(rnorm(1,mean=0),1000,10)
colnames(mat) - paste('a',1:ncol(mat),sep='')
rownames(mat) - 1:nrow(mat)
mat2 - melt(mat)

ggplot(mat2) + geom_freqpoly(aes(x = value,
y = ..density.., colour = X2))

## Plot 2- normal distributions with mean = 1
tab - matrix(rnorm(1,mean=1),1000,10)
colnames(tab) - paste('b',1:ncol(tab),sep='')
rownames(tab) - 1:nrow(tab)
tab2 - melt(tab)

ggplot(tab2) + geom_freqpoly(aes(x = value,
y = ..density.., colour = X2))


## Combined plot
comb - cbind(mat,tab)
comb2 - melt(comb)
cols -
c(rep('red',ncol(mat)*nrow(mat)),rep('black',ncol(tab)*nrow(tab)))

ggplot(comb2) + geom_freqpoly(aes(x = value,
y = ..density.., colour = cols))


### End code ###

Any help would be 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] ggplot geom_freqpoly() layers ..?

2011-09-08 Thread Brian Smith
Hi,

Thanks for the reply. For the combined plot, if I use:

ggplot(comb2) + geom_freqpoly(aes(x = value,
y = ..density.., group = X2))


I get the same colour for both the sets of distributions. What I want is one
colour for the first set of distributions, and a different colour for the
second set of distributions. Does that make sense?

thanks!



On Thu, Sep 8, 2011 at 11:26 AM, Ista Zahn iz...@psych.rochester.eduwrote:

 Hi Brian

 On Thu, Sep 8, 2011 at 10:30 AM, Brian Smith bsmith030...@gmail.com
 wrote:
  Hi,
 
  I was trying to overlay/combine two freqpoly plots. The sample code below
  illustrates the problem. Essentially, I want to do is:
 
  1. Have the same colour for all the lines in 'Plot 1' (and 'Plot 2').

 Then don't map the colour to X2!

  Currently, all the lines in Plot 1 have different colours and all the
 lines
  in Plot 2 have different colors. I'd like for all lines in Plot 1 to be
  'red' and all the lines in Plot 2 to be 'black'.

 You will need a variable indicating which values come from mat and
 which come from tab. Then map color to that variable.

  2. Combine both the plots ('Plot 1' and 'Plot 2' as one combined plot -
  which I attempt to do in 'Combined Plot'). However, I'm doing something
  wrong because with the code for 'Combined Plot' I just get two lines.

 use aes(group = X2)

 Best,
 Ista

 
   sample code 
  library(ggplot2)
 
  ## Plot 1 - normal distributions with mean = 0 ##
 mat - matrix(rnorm(1,mean=0),1000,10)
 colnames(mat) - paste('a',1:ncol(mat),sep='')
 rownames(mat) - 1:nrow(mat)
 mat2 - melt(mat)
 
 ggplot(mat2) + geom_freqpoly(aes(x = value,
 y = ..density.., colour = X2))
 
  ## Plot 2- normal distributions with mean = 1
 tab - matrix(rnorm(1,mean=1),1000,10)
 colnames(tab) - paste('b',1:ncol(tab),sep='')
 rownames(tab) - 1:nrow(tab)
 tab2 - melt(tab)
 
 ggplot(tab2) + geom_freqpoly(aes(x = value,
 y = ..density.., colour = X2))
 
 
  ## Combined plot
 comb - cbind(mat,tab)
 comb2 - melt(comb)
 cols -
  c(rep('red',ncol(mat)*nrow(mat)),rep('black',ncol(tab)*nrow(tab)))
 
 ggplot(comb2) + geom_freqpoly(aes(x = value,
 y = ..density.., colour = cols))
 
 
  ### End code ###
 
  Any help would be 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.
 



 --
 Ista Zahn
 Graduate student
 University of Rochester
 Department of Clinical and Social Psychology
 http://yourpsyche.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.


[R] Installing Rmpi on hpc

2011-03-14 Thread Brian Smith
Hi,

I was trying to install the package Rmpi on a hpc cluster running SGE. The
command, and the sessionInfo() is as follows:

===
 install.packages(Rmpi,dependencies=TRUE)
also installing the dependency ‘rsprng’

trying URL '
http://www.ibiblio.org/pub/languages/R/CRAN/src/contrib/rsprng_1.0.tar.gz'
Content type 'application/x-gzip' length 35916 bytes (35 Kb)
opened URL
==
downloaded 35 Kb

trying URL '
http://www.ibiblio.org/pub/languages/R/CRAN/src/contrib/Rmpi_0.5-9.tar.gz'
Content type 'application/x-gzip' length 87953 bytes (85 Kb)
opened URL
==
downloaded 85 Kb

* installing *source* package ‘rsprng’ ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
Try to find sprng.h ...
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sprng.h usability... no
checking sprng.h presence... no
checking for sprng.h... no
Cannot find sprng 2.0 header file.
ERROR: configuration failed for package ‘rsprng’
* removing ‘/home/bs/R_home/R-2.11.1/library/rsprng’
* installing *source* package ‘Rmpi’ ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
I am here /usr/lib/lam and it is LAM
Trying to find mpi.h ...
Found in /usr/lib/lam/include
Trying to find libmpi.so or libmpich.a ...
Found libmpi in /usr/lib/lam/lib
Try to find liblam.so ...
Found liblam in /usr/lib/lam/lib
checking for openpty in -lutil... yes
checking for main in -lpthread... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/home/bs/R_home/R-2.11.1/include -DPACKAGE_NAME=\\
-DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\
-DPACKAGE_BUGREPORT=\\ -I/usr/lib/lam/include  -DMPI2 -DLAM
-I/usr/local/include-fpic  -g -O2 -c RegQuery.c -o RegQuery.o
gcc -std=gnu99 -I/home/bs/R_home/R-2.11.1/include -DPACKAGE_NAME=\\
-DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\
-DPACKAGE_BUGREPORT=\\ -I/usr/lib/lam/include  -DMPI2 -DLAM
-I/usr/local/include-fpic  -g -O2 -c Rmpi.c -o Rmpi.o
gcc -std=gnu99 -I/home/bs/R_home/R-2.11.1/include -DPACKAGE_NAME=\\
-DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\
-DPACKAGE_BUGREPORT=\\ -I/usr/lib/lam/include  -DMPI2 -DLAM
-I/usr/local/include-fpic  -g -O2 -c conversion.c -o conversion.o
gcc -std=gnu99 -I/home/bs/R_home/R-2.11.1/include -DPACKAGE_NAME=\\
-DPACKAGE_TARNAME=\\ -DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\
-DPACKAGE_BUGREPORT=\\ -I/usr/lib/lam/include  -DMPI2 -DLAM
-I/usr/local/include-fpic  -g -O2 -c internal.c -o internal.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so RegQuery.o Rmpi.o
conversion.o internal.o -L/usr/lib/lam/lib -lmpi -llam -lutil -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/lam/lib/libmpi.so when searching
for -lmpi
/usr/bin/ld: skipping incompatible /usr/lib/lam/lib/libmpi.a when searching
for -lmpi
/usr/bin/ld: cannot find -lmpi
collect2: ld returned 1 exit status
make: *** [Rmpi.so] Error 1
ERROR: compilation failed for package ‘Rmpi’
* removing ‘/home/bs/R_home/R-2.11.1/library/Rmpi’

The downloaded packages are in
‘/tmp/RtmpShmM5e/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages(Rmpi, dependencies = TRUE) :
  installation of package 'rsprng' had non-zero exit status
2: In install.packages(Rmpi, dependencies = TRUE) :
  installation of package 'Rmpi' had non-zero exit status





 sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-unknown-linux-gnu

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] stats graphics  grDevices utils  

[R] linear model - lm (Adjusted R-squared)?

2011-03-04 Thread Brian Smith
Hi,

Sorry for the naive question, but what exactly does the 'Adjusted R-squared'
coefficient in the summary of linear model adjust for?

Sample code:

 x - rnorm(15)
 y - rnorm(15)
 lmr - lm(y~x)
 summary(lmr)

Call:
lm(formula = y ~ x)

Residuals:
Min  1Q  Median  3Q Max
-1.7828 -0.7379 -0.4485  0.7563  2.1570

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) -0.130840.28845  -0.4540.658
x0.019230.25961   0.0740.942

Residual standard error: 1.106 on 13 degrees of freedom
Multiple R-squared: 0.0004217,Adjusted R-squared: -0.07647
F-statistic: 0.005485 on 1 and 13 DF,  p-value: 0.942

 cor(x,y)
[1] 0.02053617


- What factors are included in the adjustment?

many thanks!

[[alternative HTML version deleted]]

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


[R] linear model lme4

2011-02-25 Thread Brian Smith
Hi,


I wanted to check the difference in results (using lme4) , if I treated a
particular variable (beadchip) as a random effect vs if I treated it as a
fixed effect.


For the first case, my formula is:


lmer.result - lmer(expression ~ cancerClass + (1|beadchip))


For the second case, I want to do:


lmer.result2 - lmer(expression ~ cancerClass + beadchip)



However, I get an error in the second case:


 Error in lmerFactorList(formula, fr, 0L, 0L):

  No random effects terms specified in formula



Is there any way that I can get lmer() to accept a formula without a random
effect?


many thanks

[[alternative HTML version deleted]]

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