Re: [R] sorting matrix by sets rows

2016-02-06 Thread Bert Gunter
?order is what I think you want. There is a slight wrinkle here, however. You want to sort Cluster in *increasing* order and Byers_EMT in *decreasing*, as I understand. order() will do both increasing, or both decreasing, but not differently. So a simple but inefficient way around this is to first

Re: [R] reading in multiple data sets in 2 loops

2016-02-06 Thread Boris Steipe
Computing filenames is a dangerous, backwards approach. If you already _have_ files, it's wrong to create filenames from assumptions. Rather you need to capture the existing filenames with an appropriate use of list.files(), and then process that vector. Computing filenames only has a place when

[R] sorting matrix by sets rows

2016-02-06 Thread Adrian Johnson
Hello: sorry I've been trying to sort a matrix to make waterfall plot using barplot function. I have have 30x5 matrix.Rows are samples and columns are results for a test as numeric vector. I want sort matrix by column. For example, first I want to sort column 1, in decreasing values where col

Re: [R] reading in multiple data sets in 2 loops

2016-02-06 Thread William Dunlap via R-help
I tried the following but it does not work: data <- lapply( paste(("C:/Research3/simulation1/second_gen/pheno_ 1000ind_4000m_add_h70_prog_",[1:2],"_",[2:3],".csv",sep=''), read.csv, header=TRUE, sep=',' ) names(data) <- paste("d", LETTERS[1:3], sep='') I tried that and R comp

Re: [R] [FORGED] Plot step function

2016-02-06 Thread jupiter
Thank you for the all response, how can the point y (0.0) on the same x axis, and X increases 1 between [-4, 4]? On Sun, Feb 7, 2016 at 5:29 AM, Rolf Turner wrote: > On 07/02/16 01:11, jupiter wrote: > >> Hi, >> >> I am just starting to learn R, sorry for asking a simple question. How can >> plo

Re: [R] Plot step function

2016-02-06 Thread Göran Broström
On 2016-02-06 19:23, David Winsemius wrote: On Feb 6, 2016, at 4:11 AM, jupiter wrote: Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? There is a stepfun function and an associated plotting method: y0 <- c(rep(0,3),re

Re: [R] reading in multiple data sets in 2 loops

2016-02-06 Thread Jeff Newmiller
Normally one wants not only to read the data, but to save it in an object as well. Here are some modifications toward achieving that (untested): header<-"C:/Research3/simulation1/second_gen/pheno_1000ind_4000m_add_h70_prog" fnums <- expand.grid( a = 1:2, b = 2:3 ) result <- vector( "list", nrow(

Re: [R] [FORGED] Plot step function

2016-02-06 Thread Bert Gunter
All of which should suggest: 1. Before posting further, spend some time with an R tutorial or two. "An Intro to R" ships with R; and links to some of the many excellent web resources can be found here: https://www.rstudio.com/resources/training/online-learning/#R 2. Search! A web search of "pl

Re: [R] [FORGED] Plot step function

2016-02-06 Thread Rolf Turner
On 07/02/16 01:11, jupiter wrote: Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? One way: plot(c(-1,0,1),c(0,1,1),type="s",xlab="x",ylab="y") cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics Un

Re: [R] Plot step function

2016-02-06 Thread David Winsemius
> On Feb 6, 2016, at 4:11 AM, jupiter wrote: > > Hi, > > I am just starting to learn R, sorry for asking a simple question. How can > plot a line x <= 0 y = 0, x > 0 y = 1? There is a stepfun function and an associated plotting method: y0 <- c(rep(0,3),rep(1,3)) sfun0 <- stepfun(-2:2, y0,

Re: [R] Plot step function

2016-02-06 Thread Duncan Murdoch
On 06/02/2016 7:11 AM, jupiter wrote: Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? There are lots of ways. One is curve(ifelse(x < 0, 0, 1), from=-2, to=2) This isn't perfectly vertical at x=0; a more accurate approac

[R] Plot step function

2016-02-06 Thread jupiter
Hi, I am just starting to learn R, sorry for asking a simple question. How can plot a line x <= 0 y = 0, x > 0 y = 1? Thank you. - j [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see htt

Re: [R] reading in multiple data sets in 2 loops

2016-02-06 Thread Jim Lemon
Hi Reka, Try this: header<-"C:/Research3/simulation1/second_gen/pheno_ 1000ind_4000m_add_h70_prog" for(index1 in 1:2) { for(index2 in 2:3) read.csv(paste(paste(header,index1,index2,sep="_"),".csv",sep="")) } Jim On Sat, Feb 6, 2016 at 4:53 PM, Reka Howard wrote: > Hello, > I have over 1000