[R] lme predicted value confidence intervals

2008-02-06 Thread Colin
Dear R users,

Does anyone know of a way to obtain approximate 95% confidence intervals 
for predicted values for factor levels of fixed effects from lme?  Our 
goal is to use these intervals to interpret patterns across our 
predicted values for certain factor levels.

Our mixed model has the following form with 7 levels of mtDNA, 2 levels 
of autosome, 2 levels of brood and 2 levels of block,

 > lme(fitness ~ mtDNA*autosome + brood, random = ~1 | block)

We have used the predict.lme function to obtain predicted values, but 
are unsure how to obtain appropriate standard errors on these predicted 
values.

Using predict.lme to predict "fitness" across a subset of our factor 
levels (2 mtDNA, 2 autosome) generates the following output,

autosome   mtDNA brood block predict.fixed predict.block
1   ore ore A A 0.4977047 0.5016255
2   ore simw501 A A 0.4278287 0.4317495
3   ore ore B A 0.5042857 0.5082065
4   ore simw501 B A 0.4344098 0.4383306
5   ore ore A B 0.4977047 0.4937839
6   ore simw501 A B 0.4278287 0.4239079
7   ore ore B B 0.5042857 0.5003649
8   ore simw501 B B 0.4344098 0.4304890
9   aut ore A A 0.5321071 0.5360279
10  aut simw501 A A 0.4866497 0.4905705
11  aut ore B A 0.5386882 0.5426090
12  aut simw501 B A 0.4932308 0.4971516
13  aut ore A B 0.5321071 0.5281863
14  aut simw501 A B 0.4866497 0.4827289
15  aut ore B B 0.5386882 0.5347674
16  aut simw501 B B 0.4932308 0.4893099

We would like to calculate, for example, the appropriate 95% confidence 
intervals for the predicted values of autosome=ore + mtDNA=ore, 
autosome=ore + mtDNA=simw501, etc.

Sincerely,
Kristi Montooth and Colin Meiklejohn
Ecology and Evolutionary Biology
Brown University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] `head` doesn't show all columns for an empty data.frame

2016-09-22 Thread Colin Phillips
I'm sure I'm doing something wrong, but I'm seeing strange behaviour using the 
`head` and `tail` functions on an empty data.frame.

To reproduce:
# create an empty data frame.  I actually read an empty table from Excel using 
`readWorkbook` from package `openxlsx`
test <- structure(list(Code = NULL, Name = NULL, Address = NULL, Sun.Hrs = 
NULL, 
Mon.Hrs = NULL), .Names = c("Code", "Name", "Address", "Sun.Hrs", 
"Mon.Hrs"), class = "data.frame", row.names = integer(0))

# show the data frame
test

# output in console:
# [1] CodeNameAddress Sun.Hrs Mon.Hrs
# <0 rows> (or 0-length row.names)

# note that the data frame has 0 rows and 5 columns
# show the structure
str(test)

# output in console:
#'data.frame':  0 obs. of  5 variables:
# $ Code   : NULL
# $ Name   : NULL
# $ Address: NULL
# $ Sun.Hrs: NULL
# $ Mon.Hrs: NULL

#again, the structure shows 5 columns.  However...
head(test); tail(test)

# output in console:
#[1] NameSun.Hrs
#<0 rows> (or 0-length row.names)
#[1] NameSun.Hrs
#<0 rows> (or 0-length row.names)

# now we have only two columns
 
Weird, right?

So, here's my session info:
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

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

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

other attached packages:
 [1] tidyr_0.6.0   lpSolve_5.6.13flexclust_1.3-4   modeltools_0.2-21 
lattice_0.20-34   gtools_3.5.0  reshape2_1.4.1ash_1.0-15
RODBC_1.3-13 
[10] ggmap_2.6.1   ggplot2_2.1.0 dplyr_0.5.0   assertthat_0.1
openxlsx_3.0.0   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7   plyr_1.8.4tools_3.3.1   digest_0.6.10 
tibble_1.2gtable_0.2.0  png_0.1-7 DBI_0.5-1 
mapproj_1.2-4
[10] parallel_3.3.1proto_0.3-10  stringr_1.1.0 RgoogleMaps_1.4.1 
maps_3.1.1R6_2.1.3  jpeg_0.1-8sp_1.2-3  
magrittr_1.5 
[19] scales_0.4.0  geosphere_1.5-5   colorspace_1.2-6  labeling_0.3  
stringi_1.1.1 lazyeval_0.2.0munsell_0.4.3 rjson_0.2.15 

This is not an urgent issue, I just think it's curious, so it would be nice to 
understand why it happens.

Thanks,

Colin

__
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] Select top three values from data frame

2009-08-26 Thread Colin Millar
Or perhaps use a temporary vector might be neater?

tmp <- with(df.mydata, B[A=="X" & C < 2])
df.mydata[order(tmp) %in% 1:3,] # gives df with highest three values of B

or

head(df.mydata[order(tmp),],3) # gives first 3 rows of df sorted by B


Colin.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mohamed Lajnef
Sent: 26 August 2009 11:25
To: Noah Silverman
Cc: r help
Subject: Re: [R] Select top three values from data frame

Noah Silverman a écrit :
> I only have a few values in my example, but the real data set might have 
> 20-100 rows with A="X".  So how do I pick just the three highest ones?
>
> -N
>
>   
Hi,

and now?

df.mydata$B[order(df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, 
]$B)][length(df.mydata$B)-3:length(df.mydata$B)]


cheers,
ML





> On 8/26/09 2:46 AM, Ottorino-Luca Pantani wrote:
>   
>> df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, ]
>> will do the job ?
>>
>> 8rino
>>
>> Noah Silverman ha scritto:
>> 
>>> Hi,
>>>
>>> I'm trying to find an easy way to do this.
>>>
>>> I want to select the top three values of a specific column in a 
>>> subset of rows in a data.frame.  I'll demonstrate.
>>>
>>> ABC
>>> x21
>>> x41
>>> x32
>>> y15
>>> y26
>>> y38
>>>
>>>
>>> I want the top 3 values of B from the data.frame where A=X and C <2
>>>
>>> I could extract all the rows where C<2, then sort by B, then take the 
>>> first 3.  But that seems like the wrong way around, and it also will 
>>> get messy with real data of over 100 columns.
>>>
>>> Any suggestions?
>>>
>>>   
>
>   [[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.
>
>   


-- 
Mohamed Lajnef
INSERM Unité 955. 
40 rue de Mesly. 94000 Créteil.
Courriel : mohamed.laj...@inserm.fr 
tel. : 01 49 81 31 31 (poste 18470)
Sec : 01 49 81 32 90
fax : 01 49 81 30 99 

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Select top three values from data frame

2009-08-26 Thread Colin Millar

Hi,

This should work - head is quite a usefull summary function

head(df.mydata[df.mydata$A=="X" & df.mydata$C < 2, ],3)


Colin.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Noah Silverman
Sent: 26 August 2009 10:54
To: ottorino-luca.pant...@unifi.it
Cc: r help
Subject: Re: [R] Select top three values from data frame


I only have a few values in my example, but the real data set might have

20-100 rows with A="X".  So how do I pick just the three highest ones?

-N


On 8/26/09 2:46 AM, Ottorino-Luca Pantani wrote:
> df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, ]
> will do the job ?
>
> 8rino
>
> Noah Silverman ha scritto:
>> Hi,
>>
>> I'm trying to find an easy way to do this.
>>
>> I want to select the top three values of a specific column in a 
>> subset of rows in a data.frame.  I'll demonstrate.
>>
>> ABC
>> x21
>> x41
>> x32
>> y15
>> y26
>> y38
>>
>>
>> I want the top 3 values of B from the data.frame where A=X and C <2
>>
>> I could extract all the rows where C<2, then sort by B, then take the

>> first 3.  But that seems like the wrong way around, and it also will 
>> get messy with real data of over 100 columns.
>>
>> Any suggestions?
>>

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Presumably simple question about sorting/ordering

2009-07-03 Thread Colin Beale
Hi, 

I'm stuck with a fairly basic re-ordering problem. I want to extract part of a 
matrix as a vector, and reorder it to match with an erratic sequence of x,y 
coordinates. Here's an example that shows what I want and how close I've got 
(but for some reason my mind just can't get the final step at the moment!):

#Define a grid:
xy100 <- expand.grid(1:10, 1:10)
# Define a matrix ofvalues
mat <- matrix(log(xy100[,1]) * log(xy100[,2])+1, ncol = 10)/2

#Plot some the matrix with image and the same data as xy plot:
par(mfrow = c(2,2))
image(mat)
plot(xy100, cex = c(mat), pch = 20)

#define the subset of coordinates I'm interested in:
shortXY <- expand.grid(1:5, 1:5)
#and shuffle these into an erratic sequence:
rand.seq <- sample(1:25)
shortXY <- shortXY[rand.seq,]

#Identify which coordinates in the full dataset are needed (not doubt better 
ways exist!):
needed <- which(paste(xy100[,1],xy100[,2], sep = " ") %in% paste(shortXY[,1], 
shortXY[,2], sep = " "))
#Sort these into a sensible order:
sorted <- needed[order(xy100[needed,1], xy100[needed,2])]

# plot showing that when the short-coordinates are ordered (removing the 
erratic sequence)
# the sorted subset of the matrix is correctly subsetted:
plot(shortXY[order(shortXY[,1], shortXY[,2]),], cex = c(mat)[sorted], pch = 20)

#but what further ordering do I apply to the
# sorted and subsetted matrix, to mean that I don't have to alter the 
# sequence of the shortXY coordinate list? In this example it is obviously the 
value of rand.seq:
plot(shortXY, cex = c(mat)[sorted][rand.seq], pch = 20)
# but what is the general value of this: how can I recover rand.seq when it 
isn't known?

Obviously I could do some of this (much more elegantly) with merge, but for 
various reasons I don't want to (I need to run the process many, many times on 
very large datasets). Thanks for any pointers - I'm being very slow today...

Colin

PS sessionInfo()
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=English_United 
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] debug_1.1.0mvbutils_1.1.1 svSocket_0.9-5 svIO_0.9-5 R2HTML_1.58
svMisc_0.9-5   svIDE_0.9-5   

loaded via a namespace (and not attached):
[1] tools_2.8.1



-- 
Please note that the views expressed in this e-mail are those of the
sender and do not necessarily represent the views of the Macaulay
Institute. This email and any attachments are confidential and are
intended solely for the use of the recipient(s) to whom they are
addressed. If you are not the intended recipient, you should not read,
copy, disclose or rely on any information contained in this e-mail, and
we would ask you to contact the sender immediately and delete the email
from your system. Thank you.
Macaulay Institute and Associated Companies, Macaulay Drive,
Craigiebuckler, Aberdeen, AB15 8QH.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Normal distribution

2009-10-02 Thread Colin Millar
A quick google on 'normality test' (no quotes) gives 
http://en.wikipedia.org/wiki/Normality_test. This gives you a few more tests 
than the KS test.

Cheers,
Colin.


Steve Lianoglou wrote:
> Hi,
> 
> I think you can also use a qq-plot to do the same, no? You won't get a
> statistic score + p.value, but perhaps you're more of a visual person?
> :-)
> 
> -steve
> 
> On Thu, Oct 1, 2009 at 12:56 PM, Richardson, Patrick
>  wrote:
>> ?shapiro.test
>>
>>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
>> Behalf Of Noela Sánchez
>> Sent: Thursday, October 01, 2009 12:47 PM
>> To: r-help@r-project.org
>> Subject: [R] Normal distribution
>>
>> Hi,
>>
>> I am dealing with how to check in R if some data that I have belongs to a 
>> normal distribution or not. I am not interested in obtaining the 
>> theoreticall frequencies. I am only interested in determing if (by means of 
>> a test as Kolmogorov, or whatever), if my data are normal or not.
>>
>> But I have tried with ks.test() and I have not got it.
>>
>>
>> --
>> Noela
>> Grupo de Recursos Marinos y Pesquerías
>> Universidad de A Coruña
>>
>>[[alternative HTML version deleted]]
>>
>> This email message, including any attachments, is for th...{{dropped:6}}
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
>

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] odfweave table styles

2009-11-03 Thread Colin Robertson
Hello List,

Does anyone have examples of custom formatting of tables in odfweave? I know
there is an example of this in the formatting.odt file that comes with the
package, but running that through odfweave gives the following error:

Error:  chunk 13 (label=showTableStyles)
Error in names(x) <- value :
  'names' attribute [1] must be the same length as the vector [0]

What I am really trying to do is replicate this part which highlights one
row

<>=
bigState <- which.max(tableData[, "Area"])
tableStyles$text[bigState,] <- "ArialHighlight"
tableStyles$cell[bigState,] <- "highlight"
tableStyles$text
@

In my code I do:

<>=
  bluesYes <- which(outTable[,2] >= 3 & outTable[,2] < 4)
  namel <- colnames(outTable)
  tstyles <- tableStyles(outTable, useRowNames = F, header = namel)
  tstyles$cell[bluesYes,2] <- "highlight"
@
<>=
  odfTable(outTable, styles = tstyles, useRowNames = F, colnames = namel)
@

My code runs and does not throw an error, but the resulting table does not
have the rows I asked for highlighted. If I check the tableStyles object the
values of $cell are properly set as I want. What are valid values that
tableStyles$cell can be set to? Does this have to be a custom style defined
in the ODT file beforehand?

Thanks in advance,


Colin Robertson

PhD Candidate
Dept of Geography
University of Victoria

[[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] odfweave table styles

2009-11-04 Thread Colin Robertson
Thanks! The formattingOut.odt document had exactly what I needed. The style
"highlight" wasnt defined in my environment.

Cheers,

Colin


On Wed, Nov 4, 2009 at 4:59 AM, Max Kuhn  wrote:

> It's hard to say without a reproducible example or the output form
> sessionInfo().
>
> Before doing that though, did you read the 31 page document
> "formattingOut.odt" (or the corresponding pre-odfWeave document) in
> the examples folder of the package?
>
> Max
>
> On Tue, Nov 3, 2009 at 8:14 PM, Colin Robertson 
> wrote:
> > Hello List,
> >
> > Does anyone have examples of custom formatting of tables in odfweave? I
> know
> > there is an example of this in the formatting.odt file that comes with
> the
> > package, but running that through odfweave gives the following error:
> >
> > Error:  chunk 13 (label=showTableStyles)
> > Error in names(x) <- value :
> >  'names' attribute [1] must be the same length as the vector [0]
> >
> > What I am really trying to do is replicate this part which highlights one
> > row
> >
> > <>=
> > bigState <- which.max(tableData[, "Area"])
> > tableStyles$text[bigState,] <- "ArialHighlight"
> > tableStyles$cell[bigState,] <- "highlight"
> > tableStyles$text
> > @
> >
> > In my code I do:
> >
> > <>=
> >  bluesYes <- which(outTable[,2] >= 3 & outTable[,2] < 4)
> >  namel <- colnames(outTable)
> >  tstyles <- tableStyles(outTable, useRowNames = F, header = namel)
> >  tstyles$cell[bluesYes,2] <- "highlight"
> > @
> > <>=
> >  odfTable(outTable, styles = tstyles, useRowNames = F, colnames = namel)
> > @
> >
> > My code runs and does not throw an error, but the resulting table does
> not
> > have the rows I asked for highlighted. If I check the tableStyles object
> the
> > values of $cell are properly set as I want. What are valid values that
> > tableStyles$cell can be set to? Does this have to be a custom style
> defined
> > in the ODT file beforehand?
> >
>

[[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] negative log likelihood

2009-11-09 Thread Colin Millar
Sounds like a homework question ...
 
if y = a + bx + e,  where e ~ N(0, sigma^2)
 
the log likelihood of the slope parameter and intercept parameters, a and b, 
and variance sigma^2 given n data points y and covariates x is
 
f(a,b, sigma; y, x) = -0.5*n*log(2 * pi) - n*log(sigma) - 0.5 / sigma^2 * sum_i 
[ (y_i - (a + b*x_i))^2 ]
 
You can simplyfiy this function if you condition on the variance and intercept. 
 
You are then left with a simple function coresponding to the log-likelihood 
curve.
This function is trivial to minimise.
 
Hope this helps.
Colin.
 



From: r-help-boun...@r-project.org on behalf of mat7770
Sent: Sun 08/11/2009 19:12
To: r-help@r-project.org
Subject: [R] negative log likelihood




I have two related variables, each with 16 points (x and Y). I am given
variance and the y-intercept. I know how to create a regression line and
find the residuals, but here is my problem. I have to make a loop that uses
the seq() function, so that it changes the slope value of the y=mx + B
equation ranging from 0-5 in increments of 0.01. The loop also needs to
calculate the negative log likelihood at each slope value and determine the
lowest one. I know that R can compute the best regression line by using
lm(y~x), but I need to see if that value matches the loop functions.
--
View this message in context: 
http://old.nabble.com/negative-log-likelihood-tp26256881p26256881.html
Sent from the R help mailing list archive at Nabble.com.

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__



[[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] Plotting Histogram using histogram() and for loop and Iwant to save the histogram individually ... HELP

2009-11-17 Thread Colin Millar
Or alternatively store as a list and export later if you want

... after some tidying ...


library(lattice)

columns <- 8:153
plots <- vector("list", length(columns)) 
j <- 0
for (i in columns)
{  
  plots[[ j <- j+1 ]] <- 
histogram( ~ data[,i] | data[,2], 
  ylab = "Frequency", xlab = "Score", 
  xlim = c(1,5), ylim = c(0,100),
  main = colnames(data)[i]
)
}

print(plots[[1]]) 

# or export

for (i in seq_along(plots))
{
  png(paste("hist", i, ".png", sep = ""))
  print(plots[[i]])
  dev.off()
}

HTH
Colin.

Incidentally, 

You put what you want to export between png(..) and dev.off()

If you supply the data explicitly it doesn't make any sense to pass the
data through the data argument.

No need for paste(x) if is x is already a character vector.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Tal Galili
Sent: 17 November 2009 12:15
To: ychu066
Cc: r-help@r-project.org
Subject: Re: [R] Plotting Histogram using histogram() and for loop and
Iwant to save the histogram individually ... HELP

I know how you feel,
I came a cross the same problem once, which took sometime to find a
solution
for.

What you need to do is put the hist into a variable and then plot it,
for
example:



library(lattice)
for(i in 8:153){

hist.to.plot <- histogram(~ data[,i] | data[,2],
data=data,,ylab="Frequency",xlim=c(1,5),xlab="Score",ylim=c(0,100)),main
=paste(colnames(data)[i],sep="")
plot(hist.to.plot)
}


Cheers,
Tal


--


My contact information:
Tal Galili
E-mail: tal.gal...@gmail.com
Phone number: 972-52-7275845
FaceBook: Tal Galili
My Blogs:
http://www.talgalili.com (Web and general, Hebrew)
http://www.biostatistics.co.il (Statistics, Hebrew)
http://www.r-statistics.com/ (Statistics,R, English)




On Tue, Nov 17, 2009 at 7:09 AM, ychu066 
wrote:

>
> tried but still doesnt work ...
>
> very weird ...
>
> ychu066 wrote:
> >
> > here is the codes that i tried.
> >
> >> png(paste("hist",i,".png",sep="")
> > + library(lattice)
> > Error: unexpected symbol in:
> > "png(paste("hist",i,".png",sep="")
> > library"
> >> for(i in 8:153){
> > + histogram(~ data[,i] | data[,2],
> > data=data,ylab="Frequency",xlim=c(1,5),xlab="Score",ylim=c(0,100)))
> > Error: unexpected ')' in:
> > "for(i in 8:153){
> > histogram(~ data[,i] | data[,2],
> > data=data,ylab="Frequency",xlim=c(1,5),xlab="Score",ylim=c(0,100)))"
> >> }
> > Error: unexpected '}' in "}"
> >> dev.off()
> > Error in dev.off() : cannot shut down device 1 (the null device)
> >
> >
> > ychu066 wrote:
> >>
> >> still doesnt work ...
> >>
> >>
> >> Karl Ove Hufthammer wrote:
> >>>
> >>> On Thu, 12 Nov 2009 19:10:52 -0800 (PST) ychu066  >>> @aucklanduni.ac.nz> wrote:
> >>>> And I also want to save each histogram in each separate pdf file
using
> >>>> the
> >>>> following codes ?.
> >>>> png("hist.png[i]")
> >>>> dev.off()
> >>>
> >>> Try png(paste("hist",i,".png",sep="") instead.
> >>>
> >>> --
> >>> Karl Ove Hufthammer
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
>
http://old.nabble.com/Plotting-Histogram-using-histogram%28%29-and-for-l
oop-and-I-want-to-save-the-histogram-individually-...-HELP-tp26328734p26
384489.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Calculating the power of a negative number

2009-11-17 Thread Colin Millar
Hi,

Look at 

?NumericConstants


At the bottom of the details section you will find:

"Note that a leading plus or minus is not regarded by the parser as part
of a numeric constant but as a unary operator applied to the constant."


See 

?Syntax 

for precedence information.

Hope this helps,
Colin.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Zhiyuan Jason ZHENG
Sent: 17 November 2009 14:00
To: r-h...@stat.math.ethz.ch
Subject: [R] Calculating the power of a negative number

Hello,

 

I use R a lot, one thing bugs me is that when I try the following 

> x<- -8

> x^(1/3)

[1] NaN

 

However, it is fine with -8^(1/3). Priority goes to the power. Can you
help
me out for this? Thanks.

 

Best,

 

Zhiyuan J. ZHENG

Ph.D. Candidate

Economic  Department

Virginia Polytechnic Institute and State University

Phone: 540-231-5120 , Blacksburg, VA, 24060

 


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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Calculating the power of a negative number

2009-11-17 Thread Colin Millar


If you are trying to solve

x^3 + 2 = 0


I think R will always give the positive root if available

ie

(-8 + 0i) ^ (1/3)
#[1] 1+1.732051i

So if you wanted all roots you would have to code it yourself... not
sure though


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Colin Millar
Sent: 17 November 2009 16:10
To: Zhiyuan Jason ZHENG; r-h...@stat.math.ethz.ch
Subject: Re: [R] Calculating the power of a negative number

Hi,

Look at 

?NumericConstants


At the bottom of the details section you will find:

"Note that a leading plus or minus is not regarded by the parser as part
of a numeric constant but as a unary operator applied to the constant."


See 

?Syntax 

for precedence information.

Hope this helps,
Colin.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Zhiyuan Jason ZHENG
Sent: 17 November 2009 14:00
To: r-h...@stat.math.ethz.ch
Subject: [R] Calculating the power of a negative number

Hello,

 

I use R a lot, one thing bugs me is that when I try the following 

> x<- -8

> x^(1/3)

[1] NaN

 

However, it is fine with -8^(1/3). Priority goes to the power. Can you
help
me out for this? Thanks.

 

Best,

 

Zhiyuan J. ZHENG

Ph.D. Candidate

Economic  Department

Virginia Polytechnic Institute and State University

Phone: 540-231-5120 , Blacksburg, VA, 24060

 


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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 question on nominal data

2009-11-17 Thread Colin Millar
Hi,
 
try ?table
 
# for example
 
(s3 <- table(s))
 
# and if you want a single value
 
s3["a"]
# or
s3[1]
 
HTH,
Colin.
 
 



From: r-help-boun...@r-project.org on behalf of Marc Giombetti
Sent: Tue 17/11/2009 22:55
To: r-help@r-project.org
Subject: [R] Basic question on nominal data



Hello everybody,

I am new to R and I have a very basic question, but I couldn't get
this to work.
Let's say I have a vector

s = c("a","a","a","b","b","c","c","c","c")
s1 <- factor(s)

s2 <- summary(s1) leads to the following
a b c
3 2 4


How can I access the different aggregated values for a b and c? I am
not quite sure if the factor method is the right approach.
I tried to use s2$a but it didn't work.

Any suggestions?

Thanks a lot for your help

Marc

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__



[[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] Switch Help

2009-11-18 Thread Colin Millar
I think you just missed some commas out...  

aar <-
function(command = c("scrn", "dx", "df"))
{
  command <- match.arg(command)
  switch(command,
scrn = cat("scrn  :Screening","\n"),
dx   = cat("dx:Diagnosis","\n"),
df   = cat("df:Don't Forget","\n")
  )
}

Colin.


Ps you don't need the curly brackets here if theres only one expresion,
and sometimes its good to restrict the inputs to only those you want
So that

aar("something wrong")

# Error in match.arg(command) : 'arg' should be one of "scrn", "dx",
"df"


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of oscar linares
Sent: 18 November 2009 10:40
To: r-help@r-project.org
Subject: [R] Switch Help

Dear Rexperts,

Given,

aar <-function(command) {

switch(command,
  {scrn = cat("scrn  :Screening","\n")}
  {dx   = cat("dx:Diagnosis","\n")}
  {df   = cat("df:Don't Forget","\n")}
)
}

I want to be able to do:

aar("dx") # function does cat("dx:Diagnosis","\n")

aar(c("dx","df"))  # function does cat("dx:Diagnosis","\n")
# function does df   = cat("df:Don't
Forget","\n")

BUT IT IS NOT WORKING FOR ME.

Please help:-)

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Switch Help

2009-11-18 Thread Colin Millar
And if you want to do both do

invisible( lapply(c("scrn","dx"), aar) )

but I think you will have to use multiple ifs rather than switch if you
intend to add more functionality...


.
.
.

I think you just missed some commas out...  

aar <-
function(command = c("scrn", "dx", "df")) {
  command <- match.arg(command)
  switch(command,
scrn = cat("scrn  :Screening","\n"),
dx   = cat("dx:Diagnosis","\n"),
df   = cat("df:Don't Forget","\n")
  )
}

Colin.


Ps you don't need the curly brackets here if theres only one expresion,
and sometimes its good to restrict the inputs to only those you want So
that

aar("something wrong")

# Error in match.arg(command) : 'arg' should be one of "scrn", "dx",
"df"


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of oscar linares
Sent: 18 November 2009 10:40
To: r-help@r-project.org
Subject: [R] Switch Help

Dear Rexperts,

Given,

aar <-function(command) {

switch(command,
  {scrn = cat("scrn  :Screening","\n")}
  {dx   = cat("dx:Diagnosis","\n")}
  {df   = cat("df:Don't Forget","\n")}
)
}

I want to be able to do:

aar("dx") # function does cat("dx:Diagnosis","\n")

aar(c("dx","df"))  # function does cat("dx:Diagnosis","\n")
# function does df   = cat("df:Don't
Forget","\n")

BUT IT IS NOT WORKING FOR ME.

Please help:-)

-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Function doesn't work?

2009-11-27 Thread Colin Millar
Hi,

You would also make your code more efficient and possible more readable
by doing

ReturnsGrid <- 
function(x, y, m)
{
  x + (seq.int(m) - 1) * (y - x) / m
}

(xx <- ReturnsGrid(0, 9, 3))
#[1] 0 3 6

And if you want to supply vector x and y you could do something like
(there are probably better ways..)

ReturnsGrid <- 
function(x, y, m)
{
  if (length(x) != length(y) & (length(x)==1 | length(y) == 1)) stop
("inputs not compatible") # or something
  n <- max(length(x), length(y))
  out <- sapply(seq.int(n), function(i) x[i] + (1:m - 1) * (y[i] - x[i])
/ m)
  
  drop(out)
}

(xx  <- ReturnsGrid(0, 9, 3))
#[1] 0 3 6

(xx  <- ReturnsGrid(0:2, 9:11, 3))
#[1,]012
#[2,]345
#[3,]678


But it seems like you could also do it using sequence ...

seq(x, y-1, by = m)

HTH,
Colin 



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Anastasia
Sent: 27 November 2009 16:01
To: r-help@r-project.org
Subject: [R] Simple Function doesn't work?

Hello,

I am new to R program, therefore, I am sorry if this is a really stupid
question.
I wrote a simple function and for some reason it doesn't work

ReturnsGrid = function(x,y,m){
for (i in 1:m){
   grid[i] <- x + (i-1)*(y-x)/m
}
grid
}

xx=ReturnsGrid(0,9,3)

Thanks a lot!

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Function doesn't work?

2009-11-27 Thread Colin Millar

Erm... Maybe the sequence bit wont work ... A bit hasty there

And also the length check should be

if (length(x) != length(y) & !(length(x) == 1 | length(y) == 1)) stop
("inputs not compatible") # or something
 
I missed out the not!

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Colin Millar
Sent: 27 November 2009 16:41
To: Anastasia; r-help@r-project.org
Subject: Re: [R] Simple Function doesn't work?

Hi,

You would also make your code more efficient and possible more readable
by doing

ReturnsGrid <-
function(x, y, m)
{
  x + (seq.int(m) - 1) * (y - x) / m
}

(xx <- ReturnsGrid(0, 9, 3))
#[1] 0 3 6

And if you want to supply vector x and y you could do something like
(there are probably better ways..)

ReturnsGrid <-
function(x, y, m)
{
  if (length(x) != length(y) & (length(x)==1 | length(y) == 1)) stop
("inputs not compatible") # or something
  n <- max(length(x), length(y))
  out <- sapply(seq.int(n), function(i) x[i] + (1:m - 1) * (y[i] - x[i])
/ m)
  
  drop(out)
}

(xx  <- ReturnsGrid(0, 9, 3))
#[1] 0 3 6

(xx  <- ReturnsGrid(0:2, 9:11, 3))
#[1,]012
#[2,]345
#[3,]678


But it seems like you could also do it using sequence ...

seq(x, y-1, by = m)

HTH,
Colin 



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Anastasia
Sent: 27 November 2009 16:01
To: r-help@r-project.org
Subject: [R] Simple Function doesn't work?

Hello,

I am new to R program, therefore, I am sorry if this is a really stupid
question.
I wrote a simple function and for some reason it doesn't work

ReturnsGrid = function(x,y,m){
for (i in 1:m){
   grid[i] <- x + (i-1)*(y-x)/m
}
grid
}

xx=ReturnsGrid(0,9,3)

Thanks a lot!

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 rgl to put a graphic beneath a plot

2009-12-05 Thread Colin Wyers

I've written a very simple bit of code to plot a trajectory using rgl:

 

x <- 
(c(0,-5.947,-11.496,-16.665,-21.474,-25.947,-30.116,-34.017,-37.684,-41.148,-44.435,-47.568,-50.567,-53.448,-56.223,-58.906))
y <- 
(c(0,33.729,65.198,94.514,121.784,147.151,170.797,192.920,213.717,233.360,252.003,269.774,286.781,303.117,318.858,334.071))
z <- 
(c(3,11.914,19.629,26.066,31.167,34.902,37.262,38.257,37.903,36.221,33.233,28.964,23.442,16.696,8.761,-0.325))
plot3d(x,y,z, type='l',axes=FALSE, box=FALSE)

 

I have a PNG file that I want to place the plot on top of. I've arranged the 
image so that the point at x=282 px and y=52 px should correspond with the 
origin of the graph.

 

Thanks in advance for your help,

--CW
  
_


id=1&media=aero-shake-7second&listid=1&stop=1&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_7secdemo:122009
[[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] General help for a function I'm attempting to write

2009-03-27 Thread Colin Garroway
Hello,

I have written a small function ('JostD' based upon a recent molecular
ecology paper) to calculate genetic distance between populations (columns in
my data set).  As I have it now I have to tell it which 2 columns to use (X,
Y).  I would like it to automatically calculate 'JostD' for all combinations
of columns, perhaps returning a matrix of distances.  Thanks for any help or
suggestions.
Cheers
Colin



Function:

JostD <- function(DF, X, Y) {

Ni1 <- DF[,X]
Ni2 <- DF[,Y]

N1 <- sum(Ni1)
N2 <- sum(Ni2)

pi1 <-Ni1/N1
pi2 <-Ni2/N2
pisqr <- ((pi1+pi2)/2)^2

H1 <- 1 - sum(pi1^2)
H2 <- 1 - sum(pi2^2)
Ha <- 0.5*(H1+H2)

Da <- 1/(1-Ha)
Dg <- 1/sum(pisqr)
Db <- Dg/Da
D <- -2*((1/Db) - 1)
D
}

Sample data:

e<-c(0,0,0,4,27)
r<-c(0,1,0,7,16)
t<-c(1,0,0,16,44)
y<-c(0,0,0,2,39)
df<-cbind(e,r,t,y)
rownames(df)<-q
colnames(df)<-w

> df
  P01 P02 P03 P04
L01.1   0   0   1   0
L01.2   0   1   0   0
L01.3   0   0   0   0
L01.4   4   7  16   2
L01.5  27  16  44  39

> JostD(df, 1, 2)
[1] 0.0535215

> JostD(df, 1, 3)
[1] 0.02962404
>





-- 
Colin Garroway (PhD candidate)
Wildlife Research and Development Section
Ontario Ministry of Natural Resources
Trent University, DNA Building
2140 East Bank Drive
Peterborough, ON, K9J 7B8
Canada

[[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] image3d in misc3d

2009-04-28 Thread Colin Beale
Hi,

I'm trying to make sense of the image3d plots in misc3d. Unfortunately I can't 
find any authors on the help pages of the function to e-mail directly. In the 
following toy example, I'm puzzled as to why (1) the positions of the image 
plot on the axes include negative values when I think I've specified all to be 
1:3 and (2) the logic that needs to be adhered to in order to reliably match up 
the sphere plot with the image plot. 

library(misc3d)
##Set up array:
arr <- array(1:27, dim = rep(3,3))
## Plot image, with x, y, z positions all  set (I thought) to 1:3
image3d(arr, x = 1:3, y = 1:3, z = 1:3, vlim = quantile(arr, c(0.01, 0.99)))
## Add spheres of the same data at the same positions
spheres3d(x=expand.grid(x = 1:3, y = 1:3, z = 1:3), radius = 0.1 *sqrt(arr))

## Ooops! So why don't they match up? Add axes:

axes3d()
## For some reason the image3d is generating negative values of z...

spheres3d(x=expand.grid(x = 1:3, y = 1:3, z = -(1:3)), radius = 0.1 * arr^(1/3))
## But is this reliable? I've tried with a variety of plots and sometimes it 
seems as though another axis is the negative one...

I'm using:
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
Kingdom.1252;LC_MONETARY=English_United 
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] rgl_0.83-3 misc3d_0.6-1   debug_1.1.0mvbutils_1.1.1 svSocket_0.9-5 
svIO_0.9-5 R2HTML_1.58svMisc_0.9-5   svIDE_0.9-5   

loaded via a namespace (and not attached):
[1] tools_2.8.1


Thanks!

Colin


-- 
Please note that the views expressed in this e-mail are those of the
sender and do not necessarily represent the views of the Macaulay
Institute. This email and any attachments are confidential and are
intended solely for the use of the recipient(s) to whom they are
addressed. If you are not the intended recipient, you should not read,
copy, disclose or rely on any information contained in this e-mail, and
we would ask you to contact the sender immediately and delete the email
from your system. Thank you.
Macaulay Institute and Associated Companies, Macaulay Drive,
Craigiebuckler, Aberdeen, AB15 8QH.

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


[R] R package dependencies

2010-01-13 Thread Colin Millar
Hi there,
 
My question relates to getting information about R packages.  In particular i 
would like to be able to find from within R:
  what are a packages dependencies
  what are a packages reverse dependencies
  does a package contain a dll
 
The reason i ask is:
 
The organisation that i work for is introducing a secure intranet operating on 
windows PCs and laptops, and this requires that all software / executables / 
dlls are validated before they are combined to produce a generic PC build.
 
I would like to maximise the packages available to our staff and so for the 
packages that we have listed as buisness needs, i would like to include all 
reverse dependencies of this collection that do not have dlls.
 
I hope this makes sense (the question not the reason).
 
Kind regards,
Colin.

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

2010-01-14 Thread Colin Millar
Thanks Gabor,
 
Are you or anyone aware if there is a text list of of package contents?  The 
only way i have managed to get information like the number of dlls per package 
is by downloading the zip file to a tempporary file and listing its contents 
via unzip(..., list  = TRUE).  However, downloading every package on CRAN is a 
time consuming so if there was a more efficient way of finding the contents of 
each it would be useful to know.
 
The code i am using on R2.10.1 on windows 7
 
contriburl <- "http://cran.uk.r-project.org/bin/windows/contrib/2.10 
<http://cran.uk.r-project.org/bin/windows/contrib/2.10> "
destdir <- "C:/colin/SCOTS-user-group/pkgs"
lab.pkgs <- 
c("gamair","mgcv","survival","lme4","nlme","lattice","MASS","nnet","splines","stats4",
 "stats", "methods")
 
available <- available.packages(contriburl = contriburl)
fnames <- paste(available[,"Repository"], available[,"File"], sep = "/")
tmpf <- paste(tempfile(), ".zip", sep = "")
 
pkg.contents <- lapply(fnames, function(x) {download.file(x, tmpf); unzip(tmpf, 
list = TRUE)})
ndlls <- sapply(pkg.contents, function(x) sum( grepl( ".dll", x $ Name )))
pkg.summ <- data.frame(pkg = rownames(available), dll = ndlls)

 
Thanks again,
Colin.



From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
Sent: Wed 13/01/2010 22:09
To: Colin Millar
Cc: r-help@r-project.org
Subject: Re: [R] R package dependencies



See the dep function defined here:
http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7159.html

On Wed, Jan 13, 2010 at 11:39 AM, Colin Millar  wrote:
> Hi there,
>
> My question relates to getting information about R packages.  In particular i 
> would like to be able to find from within R:
>  what are a packages dependencies
>  what are a packages reverse dependencies
>  does a package contain a dll
>
> The reason i ask is:
>
> The organisation that i work for is introducing a secure intranet operating 
> on windows PCs and laptops, and this requires that all software / executables 
> / dlls are validated before they are combined to produce a generic PC build.
>
> I would like to maximise the packages available to our staff and so for the 
> packages that we have listed as buisness needs, i would like to include all 
> reverse dependencies of this collection that do not have dlls.
>
> I hope this makes sense (the question not the reason).
>
> Kind regards,
> Colin.
>
>[[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.
>

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__



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

2010-01-14 Thread Colin Millar
Thanks guys!

The tools functions are very useful, and also the the
utils:::.clean_up_dependencies hiding in there, which I had a managed to
do myself but in far more lines!

I think I am going to download each zip file one by one to find if there
are dlls - which sounds like an overnight job to me.

Many thanks again,
Colin.

-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: 14 January 2010 14:06
To: Colin Millar
Cc: Gabor Grothendieck; r-help@r-project.org
Subject: Re: [R] R package dependencies

For the original question:

 >   what are a packages dependencies

tools:::package.dependencies(available.packages())


 >   what are a packages reverse dependencies

tools:::dependsOnPkgs(available.packages()[,1])


 >   does a package contain a dll

If the package has been installed already and you want to get the number

of dlls in libs:

   length(grep("\\.dll$", dir(system.file(package="foo", "libs"

or if not installed, you can get an idea by looking at the check logs on

CRAN. If they contain a line
  * checking line endings in C/C++/Fortran sources/headers ... OK
they also contain compiled code. This is not a save test, though.

Uwe Ligges







On 14.01.2010 12:27, Colin Millar wrote:
> Thanks Gabor,
>
> Are you or anyone aware if there is a text list of of package
contents?  The only way i have managed to get information like the
number of dlls per package is by downloading the zip file to a
tempporary file and listing its contents via unzip(..., list  = TRUE).
However, downloading every package on CRAN is a time consuming so if
there was a more efficient way of finding the contents of each it would
be useful to know.
>
> The code i am using on R2.10.1 on windows 7
>
> contriburl<-
"http://cran.uk.r-project.org/bin/windows/contrib/2.10<http://cran.uk.r-
project.org/bin/windows/contrib/2.10>  "
> destdir<- "C:/colin/SCOTS-user-group/pkgs"
> lab.pkgs<-
c("gamair","mgcv","survival","lme4","nlme","lattice","MASS","nnet","spli
nes","stats4", "stats", "methods")
>
> available<- available.packages(contriburl = contriburl)
> fnames<- paste(available[,"Repository"], available[,"File"], sep =
"/")
> tmpf<- paste(tempfile(), ".zip", sep = "")
>
> pkg.contents<- lapply(fnames, function(x) {download.file(x, tmpf);
unzip(tmpf, list = TRUE)})
> ndlls<- sapply(pkg.contents, function(x) sum( grepl( ".dll", x $ Name
)))
> pkg.summ<- data.frame(pkg = rownames(available), dll = ndlls)
>
>
> Thanks again,
> Colin.
>
> ____
>
> From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
> Sent: Wed 13/01/2010 22:09
> To: Colin Millar
> Cc: r-help@r-project.org
> Subject: Re: [R] R package dependencies
>
>
>
> See the dep function defined here:
> http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7159.html
>
> On Wed, Jan 13, 2010 at 11:39 AM, Colin Millar
wrote:
>> Hi there,
>>
>> My question relates to getting information about R packages.  In
particular i would like to be able to find from within R:
>>   what are a packages dependencies
>>   what are a packages reverse dependencies
>>   does a package contain a dll
>>
>> The reason i ask is:
>>
>> The organisation that i work for is introducing a secure intranet
operating on windows PCs and laptops, and this requires that all
software / executables / dlls are validated before they are combined to
produce a generic PC build.
>>
>> I would like to maximise the packages available to our staff and so
for the packages that we have listed as buisness needs, i would like to
include all reverse dependencies of this collection that do not have
dlls.
>>
>> I hope this makes sense (the question not the reason).
>>
>> Kind regards,
>> Colin.
>>
>> [[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.
>>
>
> __
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> __
>
>
>
>   [[alternative HTML version deleted]]
>
> 

[R] ordisymbol - changing symbols used in plotting factor levels

2010-01-26 Thread Colin Curry
Hello,

I'm trying plot points in an NMDS according to a factor with two levels:

fig<-ordiplot(canod.sol,  
type="none",cex.axis=0.9,cex.lab=0.1,pty="m",tck=-0.01)
ordisymbol(fig, y = hab, factor = "habitat", rainbow = T,col = env,  
legend = F)

This gets me part of the way - It produces a plot with blue triangles  
for the first factor level and red circles for the second level. What  
I want to do is change the symbols so they all plot as circles, then  
change the colours used to plot each factor level (e.g. I want blue  
circles and red circles). Any advice on how to do this?

Thanks,
Colin Curry
--
Colin Curry
Ph.D. Candidate
Canadian Rivers Institute
Department of Biology
University of New Brunswick, Fredericton


[[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] Conjoint Analysis in R??

2012-11-28 Thread Colin Birth
Hi all,

are there any packages to perform a market simulation with the conjoint
analysis' results?

Thanks,

Colin



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

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


[R] plotting a marginal distribution on the plane behind a persp() plot

2013-10-15 Thread Colin Rowat
R'istas:

I am trying to plot a marginal distribution on the plane behind a persp() plot. 
 My existing code is:

library(MASS)

X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2))

X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n

persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res

Any suggestions are very appreciated.

Thank you,

Colin


[[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] plotting a marginal distribution on the plane behind a persp() plot

2013-10-18 Thread Colin Rowat
Dear Duncan,

Thank you for your quick reply.   I've got the basic version of what I'm 
looking for now (see below).  My next step will be your rgl::persp3d suggestion 
for the hidden lines control.

Best,

Colin 

library(MASS)

X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2))

X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z n*n

persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res

c<-17
lines(trans3d(rep(X.kde$x[c],25), X.kde$y, 
X.kde$z[c,],pmat=res),col="red",lwd=2)

marg <- rowSums(X.kde$z)
mass <- sum(marg)
lines(trans3d(x=X.kde$x, y=rep(X.kde$y[25],25), z=marg/mass, 
pmat=res),col="green",lwd=2)

detach(package:MASS)

> -Original Message-
> From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
> Sent: 15 October 2013 18:00
> To: Colin Rowat
> Cc: r-help@R-project.org
> Subject: Re: [R] plotting a marginal distribution on the plane behind a 
> persp()
> plot
> 
> On 15/10/2013 11:38 AM, Colin Rowat wrote:
> > R'istas:
> >
> > I am trying to plot a marginal distribution on the plane behind a persp()
> plot.  My existing code is:
> >
> > library(MASS)
> >
> > X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2))
> >
> > X.kde <- kde2d(X[,1],X[,2],n=25) # X.kde is list: $x 1*n, $y 1*n, $z
> > n*n
> >
> > persp(X.kde,phi=30,theta=60,xlab="x_b",ylab="x_a",zlab="f") ->res
> >
> > Any suggestions are very appreciated.
> 
> I would suggest not using persp() (use rgl::persp3d instead), but you can do 
> it
> in persp using the same technique as in the 2nd example in the
> ?persp help page.   The difficulty with doing this is that persp() uses
> the painter's algorithm for hiding things, so if you want something hidden,
> you need to draw it first.  That's not always easy
> 
> rgl::persp3d maintains a depth buffer so the order in which you draw things
> usually doesn't matter.  (The exception is with semi-transparent
> objects.)
> 
> Duncan Murdoch
> 

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


[R] Cleveland dot plots

2011-06-07 Thread Colin Wahl
I would rather use cleveland dot plots than bar charts to display my study
results. I have not been able to find (or figure out) an R package that is
capable of producing the publication quality dot charts Im looking for. I
have either not been able to get error bars (lattice), cannot order the data
display properly (latticeExtra), or cannot make adjustments to axes. Does
anyone have a quick suggestion for a package that can handle cleveland dot
plots well? 

--
View this message in context: 
http://r.789695.n4.nabble.com/Cleveland-dot-plots-tp3581122p3581122.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] heatmap is producing unwanted horizontal and vertical lines?

2011-08-08 Thread Colin Ford
Hello,

I must start by saying that I am an R novice and am sorry if this is a 
no-brainer...

I have an csv file that contains a grid of 300x300 data points. Each point 
represents
a 1Km square on a map. Each point is either a floating point number or NA. I 
load the
data in with:

  data <- read.csv("matrix.csv", sep=',')

Convert the data to a matrix with:

  data_matrix <- data.matrix(data) 

and then produce the heatmap with:

  data_heatmap <- heatmap(data_matrix,Rowv=NA,Colv='Rowv',margin=c(0,0))

The heatmap is displayed in a separate window as expected and looks correct 
apart 
from fine white banding lines spaced out evenly over the image running 
horizontally 
across the image?

At first I thought it was my data but I checked that and its not. If I resize 
the
image I then see white vertical lines and different horizontal lines appear?

I've tried a number of different settings but can't seem to get rid of these 
lines.
If I can get rid of them the image will be ideal and just what I want. Does 
anyone
have any idea of what I'm doing wrong?

Best regards,
Col.
[[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] heatmap is producing unwanted horizontal and vertical lines?

2011-08-08 Thread Colin Ford
Hi Pete,

I thought it might be something to do with NA's when I first started but its 
not. I've attached both the image output and the data. Its almost as if the 
blocks in the heatmap are not quite meshing together? I've tried heatmap.2 as 
well and that gave the same result. I also just tried the image command and 
that was giving the same result as well. 

What I'm wanting are blocks together without the white lines going through but 
just cant seem to find a way to do that?

Best regards,
Col.



From: Peter Morgan 
To: Colin Ford 
Sent: Monday, 8 August 2011, 14:37
Subject: Re: [R] heatmap is producing unwanted horizontal and vertical lines?


Hi Col, 

Without seeing your data and the heatmap
you are plotting it is hard to tell what is going on. Are the NAs in any
pattern?  NAs appear in heatmap as the background colour which is
white by default since they are plotted transparently (see the image( )
command for details). If this is the case, you could be seeing the pattern
of NAs plotted in white.   

Also, have you tried the the heatmap.2(
) option in gplots? 

Regards, 

Pete 





From:      
 Colin Ford  
To:      
 "r-help@r-project.org"
 
Date:      
 08/08/2011 13:05 
Subject:    
   [R] heatmap
is producing unwanted horizontal and vertical lines? 
Sent by:    
   r-help-boun...@r-project.org 

 


Hello,

I must start by saying that I am an R novice and am sorry if this is a
no-brainer...

I have an csv file that contains a grid of 300x300 data points. Each point
represents
a 1Km square on a map. Each point is either a floating point number or
NA. I load the
data in with:

  data <- read.csv("matrix.csv", sep=',')

Convert the data to a matrix with:

  data_matrix <- data.matrix(data) 

and then produce the heatmap with:

  data_heatmap <- heatmap(data_matrix,Rowv=NA,Colv='Rowv',margin=c(0,0))

The heatmap is displayed in a separate window as expected and
looks correct apart 
from fine white banding lines spaced out evenly over the image running
horizontally 
across the image?

At first I thought it was my data but I checked that and its not. If I
resize the
image I then see white vertical lines and different horizontal
lines appear?

I've tried a number of different settings but can't seem to get
rid of these lines.
If I can get rid of them the image will be ideal and just what I want.
Does anyone
have any idea of what I'm doing wrong?

Best regards,
Col.
               
[[alternative HTML version deleted]]

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


Re: [R] heatmap is producing unwanted horizontal and vertical lines?

2011-08-09 Thread Colin Ford
Yes that sounds very much like it. I'm using R 13.1 on Windows 7 32 bit. I did 
do a search but didn't find anything - probably not using the correct search 
terms. Glad its not just me. 

Thank you,
Col.



From: Michael Sumner 

Cc: Peter Morgan ; "r-help@r-project.org" 

Sent: Tuesday, 9 August 2011, 1:32
Subject: Re: [R] heatmap is producing unwanted horizontal and vertical lines?

Is it this?

https://stat.ethz.ch/pipermail/r-devel/2011-July/061540.html

Try a recent version of R 2.13.1 patched


> Hi Pete,
>
> I thought it might be something to do with NA's when I first started but its 
> not. I've attached both the image output and the data. Its almost as if the 
> blocks in the heatmap are not quite meshing together? I've tried heatmap.2 as 
> well and that gave the same result. I also just tried the image command and 
> that was giving the same result as well.
>
> What I'm wanting are blocks together without the white lines going through 
> but just cant seem to find a way to do that?
>
> Best regards,
> Col.
>
>
> 
> From: Peter Morgan 

> Sent: Monday, 8 August 2011, 14:37
> Subject: Re: [R] heatmap is producing unwanted horizontal and vertical lines?
>
>
> Hi Col,
>
> Without seeing your data and the heatmap
> you are plotting it is hard to tell what is going on. Are the NAs in any
> pattern?  NAs appear in heatmap as the background colour which is
> white by default since they are plotted transparently (see the image( )
> command for details). If this is the case, you could be seeing the pattern
> of NAs plotted in white.
>
> Also, have you tried the the heatmap.2(
> ) option in gplots?
>
> Regards,
>
> Pete
>
>
>
>
>
> From:

> To:
>  "r-help@r-project.org"
> 
> Date:
>  08/08/2011 13:05
> Subject:
>    [R] heatmap
> is producing unwanted horizontal and vertical lines?
> Sent by:
>    r-help-boun...@r-project.org
> 
>
>
>
> Hello,
>
> I must start by saying that I am an R novice and am sorry if this is a
> no-brainer...
>
> I have an csv file that contains a grid of 300x300 data points. Each point
> represents
> a 1Km square on a map. Each point is either a floating point number or
> NA. I load the
> data in with:
>
>   data <- read.csv("matrix.csv", sep=',')
>
> Convert the data to a matrix with:
>
>   data_matrix <- data.matrix(data)
>
> and then produce the heatmap with:
>
>   data_heatmap <- heatmap(data_matrix,Rowv=NA,Colv='Rowv',margin=c(0,0))
>
> The heatmap is displayed in a separate window as expected and
> looks correct apart
> from fine white banding lines spaced out evenly over the image running
> horizontally
> across the image?
>
> At first I thought it was my data but I checked that and its not. If I
> resize the
> image I then see white vertical lines and different horizontal
> lines appear?
>
> I've tried a number of different settings but can't seem to get
> rid of these lines.
> If I can get rid of them the image will be ideal and just what I want.
> Does anyone
> have any idea of what I'm doing wrong?
>
> Best regards,
> Col.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@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] Cleveland Dot plots: tick labels and error bars

2011-07-20 Thread Colin Wahl
Dear list,
I've been learning how to make a 2x2 paneled dotplot in lattice without any
previous experience using lattice.
my code thusfar is:

   nut<-read.table("/Users/colinwahl/Desktop/nutsimp_noerror.csv", T, sep=
",")

attach(nut)

nut1<-data.frame(Nitrate, Total_Nitrogen, Phosphate, Total_Phosphorus)

nut1<-as.matrix(nut1)

rownames(nut1)<-group

ylimlist=list(c(0,10), c(0,10), c(0,0.25), c(0,0.25))

dotplot(nut1, groups=FALSE, horizontal=FALSE, scales = list(relation='free'
), ylim=ylimlist, ylab="Nutrient Concentration (mg/L)")

I have two issues currently: eliminating y and x tick labels between panels,
and creating error bars.

1st issue:
Figure 4.1 in Deepayan Sarkar's book creates a simple 2x2 dotplot that only
has x and y axis tick labels on the bottom and left margins of the whole
figure:
dotplot(VADeaths, groups = FALSE)


When I add scales = list(relation='free') to customize y ranges with
ylim=ylimlist, each panel has its own y and x axis tick labels. I would like
the figure panels to fit to gether like this simple figure.

2nd issue:
I'd like to create standard error bars for each point. The most direct
option I've observed is from:
http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign2.htm

It seems to use the following panel function to create 95% conf. intervals:

   panel=function(x,y) {

panel.grid(v=0, h=-6, lty=3)

panel.segments(new.data$lower95, as.numeric(y), new.data$upper95,
as.numeric(y), lty=1, col=1)

panel.segments(new.data$lower50, as.numeric(y), new.data$upper50,
as.numeric(y), lty=1, lwd=4, col='grey60')

panel.xyplot(x, y, pch=16, cex=1.2, col='white')

panel.xyplot(x, y, pch=1, cex=1.1, col='black')

panel.abline(v=0, col=2, lty=2)

}

I tried to adapt this to my data resulting in the following code:

dotplot(nut1, groups=FALSE, horizontal=FALSE, scales = list(relation='free'
), ylim=ylimlist, ylab="Nutrient Concentration (mg/L)",

   panel=function(x,y) {

panel.segments(nut$N.upper, as.numeric(y), nut$N.lower, as.numeric(y), lty=1
, col=1)

})


I have no experience with panel functions and would very much appreciate
advice.

Thank you,

Colin Wahl
Graduate Student
Dept. of Biology
Western Washington University

[[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] "inside" argument in barplot

2011-07-29 Thread Colin Bergeron
Dear list,

I want to plot a sample depth curve over a barplot. It would be perfect if
the argument "inside" in the barplot function would be functional, cause I
could just add this curve to the actual barplot, but it seems like it is not
(not yet implemented). Argument "inside" would allow not to plot the line
dividing two bars and using a null color within these bars would allow
superposition with the actual bar plot and indicate the sample depth.

Do you have any suggestions or experience to share?

Colin

[[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] "inside" argument in barplot

2011-07-29 Thread Colin Bergeron
Thanks Jannis,

I am including an example code of what I am trying to do:

par(mar=c(4,5,3,1))
barplot(Value[,1],space=0, col="grey30",axis.lty=2)
barplot(sampledepth[,1]/2, space=0, col="grey30", inside=FALSE,
add=TRUE)

sampledepth is divided by two to have the same axis scale as Value and I can
put another axis on the right of the plot no problem. I just want the
inside=FALSE so I still can see the top of the bars of the barplot but not
the inside. That way I still can see the other barplot which represent the
value. The problem is that inside=FALSE is not yet implemented.

Colin


On Fri, Jul 29, 2011 at 9:02 AM, Jannis  wrote:

> Dear Collin,
>
>
> as always, a reproducible example code would help us to understand what you
> want to do. This way I can only guess
>
> And my guess would be that it is much easier to use:
>
> par(new=TRUE)
>
> and to superimpose the barplot with whatever curve you want to include. You
> may need to set the x/y limits of the two plots to be identical.
>
>
> HTH
> Jannis
>
>
>
> On 07/29/2011 04:29 PM, Colin Bergeron wrote:
>
>> Dear list,
>>
>> I want to plot a sample depth curve over a barplot. It would be perfect if
>> the argument "inside" in the barplot function would be functional, cause I
>> could just add this curve to the actual barplot, but it seems like it is
>> not
>> (not yet implemented). Argument "inside" would allow not to plot the line
>> dividing two bars and using a null color within these bars would allow
>> superposition with the actual bar plot and indicate the sample depth.
>>
>> Do you have any suggestions or experience to share?
>>
>> Colin
>>
>>[[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://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.
>>
>>
>


-- 

Colin Bergeron
PhD. Candidate
Boreal Forest Ecology, Biodiversity
814 General Services Building
University of Alberta
Edmonton, Alberta
T6G 2E3
http://www.ales.ualberta.ca/rr/GraduateProgram/GraduateStudents/ColinBergeron.aspx

[[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] "inside" argument in barplot

2011-07-29 Thread Colin Bergeron
Thanks again,

I like the idea of adding transparency. I will try it. For now, I resigned
myself to add points to the original barplot using points as such:

plotV<-barplot(Value[,1],space=0)
dev.off()

par(mar=c(4,5,3,1))
barplot(Value[,1],space=0, col="grey30",axis.lty=2)
points(plotV, sampledepth[,1]/(max(sampledepth[,1])/max(Value[,i])), pch=19,
col="black", xpd=TRUE)

#sampledepth[,1]/(max(sampledepth[,1])/max(Value[,i] is just to relativize
the values of sampledepth to fit the axis of the plot

Not exactly what I want but close to it. A continuous curve that represents
the "top" of the barplot would be ideal to represent sample depth (n) of
each class of Value. Stacking barplot will not provide what I am looking
for.

Thanks much for your suggestions, I will post an update if I find a way to
do exactly what I want. Still, implementing the argument "inside" in the
barplot function would be the way to go but I am lacking some time to
acquire the skills required to implement it.

Colin

On Fri, Jul 29, 2011 at 11:05 AM, Jannis  wrote:

> Why dont you plot a stacked barplot with the two values for each depth (or
> whatever is on the x axis) besides each other? Another option would be to
> add transparency to the fill color of the plot (col=rgb(1,1,1,0.5)).
>
>
> On 07/29/2011 05:21 PM, Colin Bergeron wrote:
>
>> Thanks Jannis,
>>
>> I am including an example code of what I am trying to do:
>>
>> par(mar=c(4,5,3,1))
>> barplot(Value[,1],space=0, col="grey30",axis.lty=2)
>> barplot(sampledepth[,1]/2, space=0, col="grey30", inside=FALSE,
>> add=TRUE)
>>
>> sampledepth is divided by two to have the same axis scale as Value and I
>> can
>> put another axis on the right of the plot no problem. I just want the
>> inside=FALSE so I still can see the top of the bars of the barplot but not
>> the inside. That way I still can see the other barplot which represent the
>> value. The problem is that inside=FALSE is not yet implemented.
>>
>> Colin
>>
>>
>> On Fri, Jul 29, 2011 at 9:02 AM, Jannis  wrote:
>>
>>  Dear Collin,
>>>
>>>
>>> as always, a reproducible example code would help us to understand what
>>> you
>>> want to do. This way I can only guess
>>>
>>> And my guess would be that it is much easier to use:
>>>
>>> par(new=TRUE)
>>>
>>> and to superimpose the barplot with whatever curve you want to include.
>>> You
>>> may need to set the x/y limits of the two plots to be identical.
>>>
>>>
>>> HTH
>>> Jannis
>>>
>>>
>>>
>>> On 07/29/2011 04:29 PM, Colin Bergeron wrote:
>>>
>>>  Dear list,
>>>>
>>>> I want to plot a sample depth curve over a barplot. It would be perfect
>>>> if
>>>> the argument "inside" in the barplot function would be functional, cause
>>>> I
>>>> could just add this curve to the actual barplot, but it seems like it is
>>>> not
>>>> (not yet implemented). Argument "inside" would allow not to plot the
>>>> line
>>>> dividing two bars and using a null color within these bars would allow
>>>> superposition with the actual bar plot and indicate the sample depth.
>>>>
>>>> Do you have any suggestions or experience to share?
>>>>
>>>> Colin
>>>>
>>>>[[alternative HTML version deleted]]
>>>>
>>>> __
>>>> R-help@r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/**listinfo/r-help>
>>>> <https://stat.**ethz.ch/mailman/listinfo/r-**help<https://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<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] Wrong values when projecting LatLong in UTM

2011-08-02 Thread Colin Bergeron
Hi R helpers,

I tried to convert a list of LatLong coordinates (in DD format) into UTM
zone 11 NAD 27. I first tried this from PBSmapping:

library(PBSmapping)
LatLong<-cbind(c(56.85359, 56.85478),c(-118.4109, -118.4035))
colnames(LatLong)<-c("X","Y")

attr(LatLong, "projection") <- "UTM"
attr(LatLong, "zone") <- 11
UTM<-convUL(LatLong)


#and that's what I get
> UTM
  X Y
1 -120.9799 -1.068699
2 -120.9799 -1.068632

Now, the UTM values are supposed to be around:
X   Y
1 414040   6301764.2
2 414493   6301888.39

#  I don't know what is wrong, So, I then tried with rgdal


library(rgdal)

UTM<-project(LatLong, "+proj=utm +zone=11+ellps=NAD27")

# and that's what i get:

projected point not finite
projected point not finite

# Errors might come from the fact that I do have DD format in the LatLong
file. Maybe I should be able to specify that it is zone 11 north. What do
you think?


Colin

[[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] PCA: prcomp rotations

2011-09-28 Thread Colin Wahl
Hi all,
I think I may be confused by different people/programs using the word
rotation differently.

Does prcomp not perform rotations by default?
If I understand it correctly retx=TRUE returns ordinated data, that I can
plot for individual samples (prcomp()$x: which is the scaled and centered
(rotated?) data multiplied by loadings).

What does it mean that the data is rotated from the "?prcomp" description?
Is this referring to the data matrix orientation (i.e. looking at
differences among samples (columns) based on variables (rows) vs.
differences among variables (columns) based on samples(rows))?

Thank you,
Colin Wahl
Graduate student,
Western Washington University


code & background:
I am looking at the ordination of abiotic stream variables between different
sampling locations.

   abiot.pca=prcomp(all24[, c(10, 13:18)], retx=TRUE, center=TRUE, scale=
TRUE)


   summary(abiot.pca)

Importance of components:

  PC1PC2PC3PC4 PC5 PC6 PC7

Standard deviation 1.5925 1.0814 1.0697 0.9536 0.76624 0.68444 0.43037

Proportion of Variance 0.3623 0.1671 0.1635 0.1299 0.08387 0.06692 0.02646

Cumulative Proportion  0.3623 0.5294 0.6928 0.8227 0.90662 0.97354 1.0


loadings[,1:3]

 PC1 PC2 PC3

avg.dmax  -0.1879223  0.55792480 -0.04962935

scond.med -0.4327223  0.04779998 -0.43369560

docon.med  0.1976094 -0.30384127  0.67222550

cb.per 0.4134302 -0.17550281 -0.40171318

gc.per 0.4136933 -0.26997129 -0.39960398

gf.per 0.3419349  0.63917223  0.16174661

fine.per  -0.5285840 -0.28616200  0.10168155

[[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] Estimate of intercept in loglinear model

2011-11-07 Thread Colin Aitken

How does R estimate the intercept term \alpha in a loglinear
 model with Poisson model and log link for a contingency table of counts?

(E.g., for a 2-by-2 table {n_{ij}) with \log(\mu) = \alpha + \beta_{i} + 
\gamma_{j})


I fitted such a model and checked the calculations by hand. I  agreed 
with the main effect terms but not the intercept. Interestingly,  I 
agreed with the fitted value provided by R for the first cell {11} in 
the table.


If my estimate of intercept = \hat{\alpha}, my estimate of the fitted 
value for the first cell = exp(\hat{\alpha}) but R seems to be doing 
something else for the estimate of the intercept.


However if I check the  R $fitted_value for n_{11} it agrees with my 
exp(\hat{\alpha}).


	I would expect that with the corner-point parametrization, the 
estimates for a 2 x 2 table would correspond to expected frequencies 
exp(\alpha), exp(\alpha + \beta), exp(\alpha + \gamma), exp(\alpha + 
\beta + \gamma). The MLE of \alpha appears to be log(n_{.1} * 
n_{1.}/n_{..}), but this is not equal to the intercept given by R in the 
example I tried.


With thanks in anticipation,

Colin Aitken


--
Professor Colin Aitken,
Professor of Forensic Statistics,
School of Mathematics, King’s Buildings, University of Edinburgh,
Mayfield Road, Edinburgh, EH9 3JZ.

Tel:0131 650 4877
E-mail:  c.g.g.ait...@ed.ac.uk
Fax :  0131 650 6553
http://www.maths.ed.ac.uk/~cgga


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Estimate of intercept in loglinear model

2011-11-08 Thread Colin Aitken
Sorry about that.  However I have solved the problem by declaring the 
explanatory variables as factors.


An unresolved problem is:  what does R do when the explanatory factors 
are not defined as factors when it obtains a different value for the 
intercept but the correct value for the fitted value?


A description of the data and the R code and output is attached for 
anyone interested.


Best wishes,

Colin Aitken

---

David Winsemius wrote:


On Nov 7, 2011, at 12:59 PM, Colin Aitken wrote:


How does R estimate the intercept term \alpha in a loglinear
model with Poisson model and log link for a contingency table of counts?

(E.g., for a 2-by-2 table {n_{ij}) with \log(\mu) = \alpha + \beta_{i} 
+ \gamma_{j})


I fitted such a model and checked the calculations by hand. I  agreed 
with the main effect terms but not the intercept. Interestingly,  I 
agreed with the fitted value provided by R for the first cell {11} in 
the table.


If my estimate of intercept = \hat{\alpha}, my estimate of the fitted 
value for the first cell = exp(\hat{\alpha}) but R seems to be doing 
something else for the estimate of the intercept.


However if I check the  R $fitted_value for n_{11} it agrees with my 
exp(\hat{\alpha}).


I would expect that with the corner-point parametrization, the 
estimates for a 2 x 2 table would correspond to expected frequencies 
exp(\alpha), exp(\alpha + \beta), exp(\alpha + \gamma), exp(\alpha + 
\beta + \gamma). The MLE of \alpha appears to be log(n_{.1} * 
n_{1.}/n_{..}), but this is not equal to the intercept given by R in 
the example I tried.


With thanks in anticipation,

Colin Aitken


--
Professor Colin Aitken,
Professor of Forensic Statistics,


Do you suppose you could provide a data-corpse for us to dissect?

Noting the tag line for every posting 

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




--
Professor Colin Aitken,
Professor of Forensic Statistics,
School of Mathematics, King’s Buildings, University of Edinburgh,
Mayfield Road, Edinburgh, EH9 3JZ.

Tel:0131 650 4877
E-mail:  c.g.g.ait...@ed.ac.uk
Fax :  0131 650 6553
http://www.maths.ed.ac.uk/~cgga


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[R] Error in file(fname, "r") : invalid 'description' argument when running maptools' readAsciiGrid on a dataframe

2012-03-05 Thread Colin Wren
Hi,
I'm trying to calculate a sum of differences between two ascii grids.
I have the file names of the two grid files in a data.frame along with
other data. I'm then trying to add a new column to the data.frame with
the result of that calculation.

eg.

library(maptools)
difcount <- function(surfA, surfB) {
  A <- readAsciiGrid(surfA, colname="a")
  B <- readAsciiGrid(surfB, colname="b")
  sum(A$a - B$b)
}
attach(mydataframe)
difcount(surfA[1],surfB[1]) #this test part works fine and gives me
the correct result

#But when I try to do a batch job by running the function against each
row of the table it fails
mydataframe["TotalDif"] <- difcount(surfA,surfB)

Error in file(fname, "r") : invalid 'description' argument

This error seems to be coming from the readAsciiGrid function, but its
being given the same entry so I don't understand why it fails. Any
ideas?

Thanks,
Colin

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


[R] Problem with range()

2012-02-01 Thread Colin Wahl
Hello,
I'm using range do define boundaries for a linear model, so the line I
graph is only graphed for the range of data. There are NAs in the
data, but I dont remember this being a problem before. I typed
na.action=na.omit anyway, which has usually solved any NA issues in
the past. Any idea why R cant do vector functions for these data?
Solution?

Thanks,
Colin Wahl
M.S. Biology candidate
Western Washington University

fit<-lm(sandcomb ~ CCEC25)
z<-predict(fit, data.frame(CCEC25=range(CCEC25)))
lines(range(CCEC25), z, lty=2, lwd=0.75, col="grey51")


> is.vector(CCEC25)
[1] TRUE

> is.numeric(CCEC25)
[1] TRUE

> range(CCEC25)
[1] NA NA

> CCEC25
 [1]   375.8  8769.0  NA  4197.0  NA 36880.0  4167.0 13100.0  3694.0
[10] 51420.0 30660.0 30850.0  4076.0  NA 59450.0 16050.0  NA 65480.0
[19]  2101.0 16390.0  5968.0 11330.0  9112.0  8326.0

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-apple-darwin9.8.0/i386 (32-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] grid_2.14.1  lattice_0.20-0   lme4_0.999375-42 Matrix_1.0-2
[5] nlme_3.1-102 stats4_2.14.1tools_2.14.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] dotplots with error bars

2012-02-12 Thread Colin Wahl
Does anyone have any recommendations for producing dotplots with error
bars? Are there packages available for this? I searched far and wide
and cannot find a suitable option.

I am trying to produce publication-quality figures for my thesis
results. Dotplots (Cleveland dotplots) are a much better form of
summarizing barchart-type data. It does not appear that any of the
main plotting packages in r support dotplots with error bars.
Considering the benefit of these plots, I find it difficult to believe
that they have not been fully integrated into R.

I did find a function "dotplots.errors" available here:
http://agrobiol.sggw.waw.pl/~cbcs/articles/CBCS_5_2_2.pdf.

However, I have found this function absurdly difficult to use when
customizing figures (ordering displays properly, or just simple
getting the function to work.)

I've been struggling for the last few hours to figure out the error:
"error using packet 1 sum not meaningful for factors." Unlike other
packages, this function doesnt have a ?dotplots.errors to help guide
troubleshooting. I presume this is a technicality due to the a numeric
variable being identified as a factor. However, I've double checked
that all the numeric columns in the data frame are not factors, and
the error persists.

I'd really prefer not just calling it quits and resorting to
old-school sloppy bar charts, but if thats what I need to do to finish
this in a timely manner, then so be it.

Thank you,
Colin
M.S. candidate
WWU, Biology dept.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] dotplots with error bars

2012-02-15 Thread Colin Wahl
Thank you,
Its looking like your package will work for me. I have two questions.

First, how do I rotate the plot 90 degrees so the group labels are on
the x axis and the response value on the y axis?

Second, I'm having trouble with the group labels. I need to order my
groups into meaningful groups to properly display my data. I used the
sort.segs=FALSE argument expecting it to plot the values in the order
of data in the plant_height matrix.

centipede.plot(t(plant_height[,c(3,2,4)]),
panel.first=c(abline(h=1: 13 , col="lightgray", lty=2),
abline(v=mean(plant_height$est), col="lightgray")),
sort.segs=FALSE,
left.labels=plant_height$group, bg="green",
right.labels=rep("", 13), xlab="Mean plant height (cm) +- SE")

Not only are the groups not plotted in the order as they appear in the
matrix, but the labels are incorrect. The labels cycle through CA-I,
CAIII, CA-II, in that order.

The plot file is attached.

Colin

On Mon, Feb 13, 2012 at 1:31 AM, Jim Lemon  wrote:
> On 02/13/2012 09:51 AM, Colin Wahl wrote:
>>
>> Does anyone have any recommendations for producing dotplots with error
>> bars? Are there packages available for this? I searched far and wide
>> and cannot find a suitable option.
>>
>> I am trying to produce publication-quality figures for my thesis
>> results. Dotplots (Cleveland dotplots) are a much better form of
>> summarizing barchart-type data. It does not appear that any of the
>> main plotting packages in r support dotplots with error bars.
>> Considering the benefit of these plots, I find it difficult to believe
>> that they have not been fully integrated into R.
>>
>> I did find a function "dotplots.errors" available here:
>> http://agrobiol.sggw.waw.pl/~cbcs/articles/CBCS_5_2_2.pdf.
>>
>> However, I have found this function absurdly difficult to use when
>> customizing figures (ordering displays properly, or just simple
>> getting the function to work.)
>>
>> I've been struggling for the last few hours to figure out the error:
>> "error using packet 1 sum not meaningful for factors." Unlike other
>> packages, this function doesnt have a ?dotplots.errors to help guide
>> troubleshooting. I presume this is a technicality due to the a numeric
>> variable being identified as a factor. However, I've double checked
>> that all the numeric columns in the data frame are not factors, and
>> the error persists.
>>
>> I'd really prefer not just calling it quits and resorting to
>> old-school sloppy bar charts, but if thats what I need to do to finish
>> this in a timely manner, then so be it.
>>
> Hi Colin,
> I am grateful that Marcin Kozak gave plotrix a plug in the paper, and to
> show my gratitude, I'll explain how to use centipede.plot to get the
> illustration in the paper. Assume that you have the data frame shown on p70
> of the paper:
>
> plant_height<-read.csv("plant_height.csv")
>
> Now, to echo Marcin, let us produce the plot:
>
> library(plotrix)
> centipede.plot(t(plant_height[,c(3,2,4)]),
>  left.labels=plant_height$group,bg="black",
>  right.labels=rep("",13),xlab="Mean plant height (cm) +- SE")
>
> If you want the mean value line:
>
> abline(v=mean(plant_height$est),col="lightgray")
>
> The grid lines are a bit more difficult. You could insert a line into the
> function just after the call to box() to draw grid lines under each dot:
>
> abline(h=1:dim(x)[2],col="lightgray",lty=2)
>
> However, this looks like such a good idea that I will add two arguments to
> the function to do the vertical line(s) and horizontal grid automatically,
> and this option will appear in the next version of plotrix.
>
> Jim
<>__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Behaviour of interactions in glm

2008-03-25 Thread Colin Towers
Dear All,

I'm struggling a little with the behaviour of R with GLM interactions. In 
particular, I have a dataset with two factors - call them factor A and 
factor B, where I would like to fit a GLM that is factor A + (grouped 
factor A):factor B.

To try to isolate this, I've ignored the original "factor A" part, as that 
I have this as a separate column in my data. So, it looks like I have 
factor A + factor B + factor C:factor B, but I don't want terms for the 
base level of factor B for that factor C:factor B interaction.

An example of the data I'm trying to fit a model to could be as follows:

Record   FactorA   FactorB  Weight  Response
1 111   0.73
2 120.5 0
3 131   1.00
4 210.332.77
5 220.4 0
6 235   0

(I've given a sample here, as my data has around 10,000 records and about 
30 columns).

So, I've prepared my data using something similar to:

glmdata <- read.table("C:\\MyData.csv", sep=",", header=TRUE)

glmdata$FactorA <- C(factor(glmdata$FactorA),base=1)
glmdata$FactorB <- C(factor(glmdata$FactorB),base=2)

glmfit <- glm(Response ~ 1 + FactorA:FactorB, family=(Gamma( 
link="log")), weights = Weight, data=glmdata)

After some playing around, I've found I get slightly different results 
with FactorA*FactorB, FactorA+FactorB+FactorA:FactorB, FactorA:FactorB - 
but whatever I do I always get 6 coefficients.

Really what I would like to do is to ask for FactorA*FactorB less the 
entries in the design matrix that I get from FactorA and FactorB. This 
would leave me with the design matrix being:

Record Mean  FactorA2:FactorB1  FactorA2:FactorB3
1  1 0  0
2  1 0  0
3  1 0  0
4  1 1  0
5  1 0  0
6  1 0  1

If anyone has any advice on how I could make this happen, I'd be very 
grateful!

Thanks in advance,
Colin Towers.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 rcorr.cens for Goodman Kruskal gamma

2007-12-19 Thread Colin Robertson
Dear List,

 

I would like to calculate the Goodman-Kruskal gamma for the predicted
classes obtained from an ordinal regression model using lrm in the Design
package. I couldn't find a way to get gamma for predicted values in Design
so have found previous positings suggesting to use :

 

Rcorr.cens(x, S outx = TRUE)  in the Hmisc package

 

My question is, will this work for predicted vs observed factors?  I.e. x =
predicted class and S = observed class? Or is there a better way to obtain
this? I used the maximum individual probability for each observation to
determine the predicted class. 

 

Any help appreciated, 

 

Thanks

 

Colin

 

 

 

Colin Robertson

Dept of Geography

University of Victoria

 

 


[[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] AUC values from LRM and ROCR

2008-01-04 Thread Colin Robertson
Dear List,

 

I am trying to assess the prediction accuracy of an ordinal model fit with
LRM in the Design package. I used predict.lrm to predict on an independent
dataset and am now attempting to assess the accuracy of these predictions.
>From what I have read, the AUC is good for this because it is threshold
independent. I obtained the AUC for the fit model output from the c score (c
= 0.78). For the predicted values and independent data, for each level of
the response I used the ROCR functions to get the AUC (i.e., probability y
>= class1, y >= class2, y >= class3 etc) and plotted the ROC curves for
each. The AUC values are all higher (AUC = 0.80 - 0.93) for the predicted
values than what I got from the fit model in lrm. 

 

I am not sure whether I have misinterpreted the use of the AUC for ordinal
models or whether the prediction results are actually better than the model
results.

 

Any help / clarification appreciated,

 

Colin

 

Colin Robertson

University of Victoria

 


[[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] Details regarding the nnet package

2008-04-25 Thread Colin Blake Rickert
Hello,

I've recently been using the nnet package to do some basic forecast  
predictions. I've found the package to be quite useful and I am  
getting some good results. However, I am in the midst of writing a  
small paper on the results I am getting and wish to clarify some  
things about the nnet package that are not made clear in the  
documentation. In particular I would like to know the following:

1) Is it a standard feed forward network trained using gradient  
descent (I am assuming this is the case, seems like a no brainer but  
just to be sure)?

2) What is the sigmoidal function used for the activation/firing of a  
node in the network?

3) What exactly does the output "value" consist of at each iteration?  
Is this the value of the Least Mean Square function of the difference  
between the output layer and the target values or is it something else?

4) Will this package ever be updated to allow for multiple layers  
instead of just one? (just out of curiousity)


I have to present this paper on Friday May 2nd so I would greatly  
appreciate a timely response.

Thanks,

-Colin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Another Question Regarding the nnet package

2008-04-26 Thread Colin Blake Rickert
I have one other question regarding the nnet package in R:

What is the value of the step size (often referred to as "eta") for  
the gradient descent function?

I dont see anywhere in the API where this value can be modified.

Thanks,

-Colin

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