Re: [R] Help with a function [along columns]

2014-10-14 Thread Jim Lemon
On Mon, 13 Oct 2014 08:54:51 PM Kate Ignatius wrote: > Just an update to this: > > gtal <- function(d) { > alleles <- sapply(d, function(.) strsplit(as.character(.), "/")) > gt <- unlist(lapply(alleles, function(x) >ifelse(identical(x[[1]], vcf[,3]) & identical(x[[2]], vcf[,3])

Re: [R] Help with a function [along columns]

2014-10-13 Thread Kate Ignatius
Just an update to this: gtal <- function(d) { alleles <- sapply(d, function(.) strsplit(as.character(.), "/")) gt <- unlist(lapply(alleles, function(x) ifelse(identical(x[[1]], vcf[,3]) & identical(x[[2]], vcf[,3]), 'RR', ifelse(identical(x[[1]], vcf[,4]) & identical(

[R] Help with a function [along columns]

2014-10-13 Thread Kate Ignatius
Hi all, I need help with a function. I'm trying to write a function to apply to varying number of columns in a lot of files - hence the function... but I'm getting stuck. Here it is: gt<- function(x) { alleles <- sapply(x, function(.) strsplit(as.character(.), "/")) gt <- apply(x, funct