[R] Combining multiple probability weights for the sample() function.

2015-06-02 Thread Benjamin Ward (ENV)
Dear R-List, I have a set of possibilities I want to sample from: bases <- list(c('A', 'C'), c('A', 'G'), c('C', 'T')) possibilities <- as.matrix(expand.grid(bases)) >possibilities Var1 Var2 Var3 [1,] "A" "A" "C" [2,] "C" "A" "C" [3,] "A" "G" "C" [4,] "C" "G" "C" [5,] "A" "A" "T" [6,]

[R] Two x axes - top and bottom

2014-02-08 Thread Benjamin Ward (ENV)
Hi, fellow R users, I've been asked to make a plot with two datasets each with a different x axis, and it's been suggested one be at the top and the other at the bottom of the graph. I normally use ggplot2, and I know how to plot multiple datasets by simply + a new geom with a different data op

[R] Change points in R

2014-01-30 Thread Benjamin Ward (ENV)
Hi R helpers, I have a set of data best shown in this below graph. Each coloured line represents a statistic calculated across pairs of DNA sequences. And for each coloured line, I would like to identify breakpoints - so identify the chunks where the values are high, for example, in the light

Re: [R] Small p from binomial probability function.

2013-10-16 Thread Benjamin Ward (ENV)
in so 0.05, 0.50 and 0.95, or even just 0.05 and 0.95? Then uniroot finds the root of this function and doing so find me the small p I need? Best, Ben. From: Rolf Turner [rolf.tur...@vodafone.co.nz] Sent: 11 October 2013 02:11 To: Benjamin Ward (EN

Re: [R] Small p from binomial probability function.

2013-10-10 Thread Benjamin Ward (ENV)
than uniroot? Best, Ben. From: Stefan Evert [stefa...@collocations.de] Sent: 10 October 2013 09:37 To: R-help Mailing List Cc: Benjamin Ward (ENV) Subject: Re: [R] Small p from binomial probability function. Sounds like you want a 95% binomial confidence interval:

[R] Small p from binomial probability function.

2013-10-09 Thread Benjamin Ward (ENV)
Hi, I got given some code that uses the R function pbionom: p <- mut * t sumprobs <- pbinom( N, B, p ) * 1000 Which gives the output of a probability as a percentage like 5, 50, 95. What the code currently does is find me the values of t I need, by using the above two code lines in a loop, eac

[R] Building a Package & using gWidgets

2013-02-14 Thread Benjamin Ward (ENV)
Hi, For the past few months I've been building a simulation in R I hope to package. It consists of two usable functions, and many internal ones which one of the two usable functions call while looping, to perform the stages of simulation. A simple conceptual example is: # Abstract representati

[R] Remove and add to many matrices in list.

2013-02-05 Thread Benjamin Ward (ENV)
Hi all, I realised that my last email question and code was probably going to be a bit of an eyesore for some people and that perhaps the best thing for me to do is to pose the question of what it is I want to achieve, rather than what I've written, if it helps people: I'm writing a simulation

[R] Subscript out of Bounds Lapply

2013-02-05 Thread Benjamin Ward (ENV)
Hi all, I've written a function for a simulation which will - in general operation without being specific to the simulation scenario, duplicate or delete columns from a matrix based on two values which determine how many as a proportion of the matrix: the two values are always between 0.01 and

[R] NA and Character(0) in List Element

2013-01-28 Thread Benjamin Ward (ENV)
Hi, This is probably a small query but one I'm struggling with: I have a list in which I had elements which were NA, I removed them, by doing: list2 <- lapply(list, na.omit), However this leaves the element there with 'character(0)' in place as well as attributes: e.g. [[978]] character(0) at

Re: [R] Removal of columns from matrix where all values of the column are identical.

2013-01-26 Thread Benjamin Ward (ENV)
m: arun [smartpink...@yahoo.com] Sent: 26 January 2013 02:34 To: Benjamin Ward (ENV) Cc: R help Subject: Re: [R] Removal of columns from matrix where all values of the column are identical. Hi, I guess this should also work: Matrix[,apply(Matrix,2,function(x) all(c(TRUE,x[-length(x)]!=x[-1])))]

[R] Removal of columns from matrix where all values of the column are identical.

2013-01-25 Thread Benjamin Ward (ENV)
Hi all, I'd like to write a piece of code which will remove columns from a matrix, if the column contains only one value, say every value in the column is a "3": Matrix <- matrix(NA, nrow=5, ncol=4) Matrix[,1] <- c(1,2,3,4,5) Matrix[,2] <- c(3,3,3,3,3) Matrix[,3] <- c(5,4,3,2,1) Matrix[,4] <- c(

[R] Pairwise Comparrisons

2013-01-24 Thread Benjamin Ward (ENV)
Dear all, I'm trying to write a function, that will take as an argument, some aligned genome sequences, and using a sliding window, do pairwise comparisons of sequence similarity. Coding the sliding window I think I can manage but what I'm trying to get to grips with is getting it so as every p

Re: [R] Stuck trying to modify a function

2012-11-28 Thread Benjamin Ward (ENV)
ker. Best Wishes, Ben W. UEA (ENV) and The Sainsbury Laboratory. From: Jean V Adams [jvad...@usgs.gov] Sent: 27 November 2012 22:01 To: Benjamin Ward (ENV) Cc: r-help@r-project.org Subject: Re: [R] Stuck trying to modify a function Ben, You can use the

[R] Stuck trying to modify a function

2012-11-27 Thread Benjamin Ward (ENV)
Hi, I have the following data: Path_Number <- 5 ID.Path <- c(1:Path_Number) # Make vector of ID's. No_of_X <- sample(50:550, length(ID.Path), replace=TRUE) # X <- split(sample(1:1, sum(No_of_X), replace=TRUE), rep(ID.Path, No_of_X)) Y <- lapply(X,function(x) sample(x, round(runif(1, min=10, m

[R] Code works, but not as function.

2012-11-15 Thread Benjamin Ward (ENV)
Hi, I have some values in a list format generated by the following: Path_Number <- 0010 ID.Path <- formatC(0001:Path_Number, width=4, flag=0) # Make vector of ID's. No_of_Effectors <- sample(1:550, length(ID.Path), replace=TRUE) # Define Number of Effectors each individual gets. Effectors <- spli

Re: [R] Extract cell of many values from dataframe cells and sample from them.

2012-11-11 Thread Benjamin Ward (ENV)
.gov] Sent: 08 November 2012 19:59 To: r-help@r-project.org Cc: Benjamin Ward (ENV) Subject: Re: [R] Extract cell of many values from dataframe cells and sample from them. Ben, I think you would find lists a helpful way to arrange your data. They do not require equal lengths of data in each ele

[R] Extract cell of many values from dataframe cells and sample from them.

2012-11-08 Thread Benjamin Ward (ENV)
ividual, each slice through the array in the z direction, would have different numbers of rows - different numbers of effectors. This may be easier to work on, but I've not worked with multidimensional arrays, I'm used to data in dataframes (usually from spreadsheets from experim

Re: [R] sample from list

2012-11-08 Thread Benjamin Ward (ENV)
indexing or some such thing I can write functions to do the interactions and immunology and such. Best, Ben W. UEA (ENV) & The Sainsbury Laboratory. From: Jean V Adams [jvad...@usgs.gov] Sent: 07 November 2012 21:12 To: Benjamin Ward (ENV) Cc: r-help@r-projec

[R] sample from list

2012-11-06 Thread Benjamin Ward (ENV)
Hi all, I have a list of genes present in 500 individuals, the individuals are the elements: Genes <- lapply(1:nrow(inds),function(x) sample(1:1,inds$No_of_Genes,replace=TRUE)) (This was later written to a dataframe as well as kept as the list object: inds2 <- data.frame(inds,Genes=I(Genes

[R] FW: Having some Trouble Data Structures

2012-11-05 Thread Benjamin Ward (ENV)
From: Benjamin Ward (ENV) Sent: 03 November 2012 13:29 To: Jeff Newmiller; r-help@r-project.org Subject: RE: [R] Having some Trouble Data Structures Hi, Thank you very much for your reply - how you prefer, is how my supervisor implemented the layout in Minitab, however I was unsure of how to get

[R] Having some Trouble Data Structures

2012-10-28 Thread Benjamin Ward (ENV)
Hi All, I'm trying to run a simulation of host-pathogen evolution based around individuals. What I need to have is a dataframe or table of some description - describing all the individuals of a pathogen population (so far I've implemented this as a matrix): ID No_of_Effectors

[R] RExcel

2009-10-06 Thread Benjamin Ward
Hello- I am a Graduate Assistant for an instructor who has written programs for statistics calculations such as binomial distributions and regressions. The programs had worked with no problem in Excel 2003. Now we are trying to use it with Excel 2007, and we are having some trouble. I have downl