Re: [R] Reformatting text inside a data frame

2015-09-07 Thread Jon BR
Hi John, Thanks for the reply; I'm pasting here the output from dput, with a 'df <-' added in front: df <- structure(list(rowNum = c(1, 2, 3), first = structure(c(NA, 1L, 2L), .Label = c("AD=2;BA=8", "AD=9;BA=1"), class = "factor"), second = structure(c(2L, 1L, NA), .Label = c("AD=1;BA=2"

[R] Reformatting text inside a data frame

2015-09-07 Thread Jon BR
Hi all, I've read in a large data frame that has formatting similar to the one in the small example below: df <- data.frame(c(1,2,3),c(NA,"AD=2;BA=8","AD=9;BA=1"),c("AD=13;BA=49","AD=1;BA=2",NA)); names(df) <- c("rowNum","first","second") > df rowNum first second 1 1 AD=

[R] data frame formatting

2015-08-18 Thread Jon BR
Hello all, I would like to take a data frame such as the following one: > df <- data.frame(id=c("A","A","B","B"),first=c("BX",NA,NA,"LF"),second=c(NA,"TD","BZ",NA),third=c(NA,NA,"RB","BT"),fourth=c("LG","QR",NA,NA)) > df id first second third fourth 1 ABX LG 2 A TD

Re: [R] dplyr help

2015-07-29 Thread Jon BR
David, I do appreciate your help, if not the dose of contempt. I hope you feel OK. Thanks for the tips, -Jonathan On Wed, Jul 29, 2015 at 11:14 PM, David Winsemius wrote: > > On Jul 29, 2015, at 7:37 PM, Jon BR wrote: > > > Hello, > >I've recently discovered

Re: [R] dplyr help

2015-07-29 Thread Jon BR
gt; select(name, drink, cost, sex) > > The last select statement puts the output in the column order you wanted > in your result. > > I hope this helps. > > Brian > > > > On Wed, Jul 29, 2015 at 9:37 PM, Jon BR wrote: > >> Hello, >> I've r

[R] dplyr help

2015-07-29 Thread Jon BR
Hello, I've recently discovered the helpful dplyr package. I'm using the 'aggregate' function as such: bevs <- data.frame(cbind(name = c("Bill", "Mary"), drink = c("coffee", "tea", "cocoa", "water"), cost = seq(1:8), sex = c("male","female"))); bevs$cost <- seq(1:8) > bevs name drink cos

Re: [R] reshape a data frame

2015-06-03 Thread Jon BR
304.02 7 A_1 A bc2 319.79 8 A_2 A bc2 186.84 9 A_3 A bc2 125.80 10 A_4 A bc294.87 11 B_1 B bc2 1008.19 12 B_2 B bc2 314.02 Thanks. On Wed, Jun 3, 2015 at 5:44 PM, Jon BR wrote: > Hello, > > I would like to ask for so

[R] reshape a data frame

2015-06-03 Thread Jon BR
Hello, I would like to ask for some advice in reformatting a data frame such as the following one: gIN <- c("A_1","A_2","A_3","A_4","B_1","B_2") bc1 <- c(1219.79, 1486.84, 1255.80, 941.87, 588.19, 304.02) bc2 <- c(319.79, 186.84, 125.80, 94.87, 1008.19, 314.02) group <- c("A","A","A","A","B","B"

[R] Basic data frame manipulation

2015-02-23 Thread Jon BR
Hi R-help, Although I know that variations of this question are frequently asked, I searched and haven't found an answer for this specific variant, and wonder if any of you know this off the top of your head: df1 <- data.frame(a = 1:5, row.names = letters[1:5]) # letters a to

[R] ggplot2 beginner question

2013-11-06 Thread Jon BR
Hello, I'm having fun exploring the pretty graphing options in R, although I'm struggling to figure out how to do some simple things; would be thankful if someone could point me toward relevant sections of the manual or provide some starter code to get me going. I'd like to extend what is offer

Re: [R] data frame pointers?

2013-10-24 Thread Jon BR
ot;) #should work > > But, if you wanted to use ?write.table() and also to substitute zeros, > perhaps: > > > res[,2:4] <- lapply(res[,2:4],function(x) {x1 > <-unlist(lapply(x,paste,collapse=","));x1[x1==""] <- 0; x1}) > > > str(res) > #&#x

Re: [R] data frame pointers?

2013-10-23 Thread Jon BR
actors=FALSE) > res <- dcast(df,gene~case,value.var="issue",list) > res > # genecase_1 case_2 case_3 > #1 gene1 nsyn, ampdel > #2 gene2 UTR > > > A.K. > > > On Wednesday, October 23, 2013 7:38 PM, Jon BR > wrote: > H

[R] data frame pointers?

2013-10-23 Thread Jon BR
Hello, I've been running several programs in the unix shell, and it's time to combine results from several different pipelines. I've been writing shell scripts with heavy use of awk and grep to make big text files, but I'm thinking it would be better to have all my data in one big structure in

[R] using "sample()" for a vector of length 1

2010-07-22 Thread Jon BR
Hi All, I'm trying to use the "sample" function within a loop where the vector being sampled from (the first argument in the function) will vary in length and composition. When the vector is down in size to containing only one element, I run into the "undesired behaviour" acknowledged in the ?