Re: [R] read.table question
Thanks All! On Thu, Dec 8, 2011 at 7:41 PM, Robert Baer rb...@atsu.edu wrote: Hello All, This works, results - read.table(plink.txt,T) while this doesn't. results - read.table(plink.txt) The T is the value for the second parameter which you show from the help file printout you looked at to be header. Thus, you are writing in short cut: results - read.table(plink.txt, header=T)# parameters are assigned by position when names are not explicit. Further, you should know that T is a variable with the value TRUE (boolean). Most people recommend you write it out to avoid unexpected reassignments of the variable T to something other than TRUE. Thus, you should write: results - read.table(plink.txt, header=TRUE) # this is explicit of what works for plink.txt Finally, by header = TRUE, you are saying that the first row of your file contains the column headings for your data which apparently it does if it it works. Hopes this helps you understand the help file which at least you took the time to read. Good on you! HTH, Rob Make sure your data frame contains columns CHR, BP, and P What does adding the T in read.table do? Which argument does this correspond to? I tried searching for it but didn't find the answer in: read.table(file, header = FALSE, sep = , quote = \', dec = ., row.names, col.names, as.is = !stringsAsFactors, na.strings = NA, colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = #, allowEscapes = FALSE, flush = FALSE, stringsAsFactors = default.stringsAsFactors(), fileEncoding = , encoding = unknown) Could someone please explain? Thanks P [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://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. --** Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A. T. Still University of Health Sciences 800 W. Jefferson St. Kirksville, MO 63501 660-626-2322 FAX 660-626-2965 [[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] Find x value of density plots
Vielen Dank! On Tue, Dec 6, 2011 at 1:48 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 06/12/2011 1:42 PM, Pavan G wrote: Hello All, How do I find the x value at max density for say, this plot plot(density(rnorm(1000))) d - density(rnorm(1000)) plot(d) abline(v=d$x[which.max(d$y)]) Duncan Murdoch [[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] read.table question
Hello All, This works, results - read.table(plink.txt,T) while this doesn't. results - read.table(plink.txt) Make sure your data frame contains columns CHR, BP, and P What does adding the T in read.table do? Which argument does this correspond to? I tried searching for it but didn't find the answer in: read.table(file, header = FALSE, sep = , quote = \', dec = ., row.names, col.names, as.is = !stringsAsFactors, na.strings = NA, colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = #, allowEscapes = FALSE, flush = FALSE, stringsAsFactors = default.stringsAsFactors(), fileEncoding = , encoding = unknown) Could someone please explain? Thanks P [[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] Find x value of density plots
Hello All, How do I find the x value at max density for say, this plot plot(density(rnorm(1000))) Thank you, P [[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] Create subsets of data
Thanks David and Steve. This is exactly what I was looking for. tapply seems to be one robust command. (Humor of any potency is always a welcome thing in academia :) WSS [[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] Create subsets of data
Hello All, Let's say I have points on a x-y plane. x ranges from 0-2 and y from 0-2. There are points in quadrants x[0:1]---y[0:1] and in x[1:2]y[1:2]. I would like to get the mean and std of the points in the x[0:1]y[0:1] quadrant alone. Is there a straight forward way to do it? I asked a similar question a few days ago regarding plotting a subset of data using conditions. The solution was: http://r.789695.n4.nabble.com/Conditional-plot-length-in-R-td3503855.html Thank you, Why-so-serious. [[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] Conditional plot length in R
Hello All, Let's say I have data spanning all quadrants of x-y plane. If I plot data with a certain x and y range using xlim and ylim or by using plot.formula as described in this link: http://www.mathkb.com/Uwe/Forum.aspx/statistics/5684/plotting-in-R *DF - data.frame(x = rnorm(1000), y = rnorm(1000)) * * str(DF)* *'data.frame': 1000 obs. of 2 variables: $ x: num -0.0265 0.1554 -0.1050 -0.9697 -0.3430 ... $ y: num 1.386 -1.356 -1.170 0.426 0.204 ... Now, let's plot the data meeting the criteria you indicated above: plot(y ~ x, data = DF, subset = (x 0) (y 0))* How then can I get the length of that data? If have 1000 data points and 200 lie in x,y0, how do I find that the length is 200? Thanks! Why-so-serious [[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] Conditional coloring
Mighty thanks Peter. This does precisely what I wanted. Thanks again. On Mon, Mar 14, 2011 at 4:52 PM, Peter Langfelder peter.langfel...@gmail.com wrote: On Mon, Mar 14, 2011 at 1:06 PM, Pavan G pavan.n...@gmail.com wrote: Hello All, I have a histogram with values above and below 0. I would like to color the +ve bars green and -ve bars red. I am plotting data using: hist(a[,2],breaks=100,main=W3,xlab=Movement towards site (A)) Can someone please comment on how it can be done? Thanks! See help(hist). The argument border lets you color the outline of the bars. You can use, for example, this code: h = hist(a[,2],breaks=100) bor = ifelse(h$mids 0, red, green); plot(h, border = bor, main=W3,xlab=Movement towards site (A)) Example with random data: h = hist(rnorm(1000),breaks=100) bor = ifelse(h$mids 0, red, green); plot(h, border = bor, main=W3,xlab=Movement towards site (A)) HTH, Peter [[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] Conditional coloring
Hello All, I have a histogram with values above and below 0. I would like to color the +ve bars green and -ve bars red. I am plotting data using: hist(a[,2],breaks=100,main=W3,xlab=Movement towards site (A)) Can someone please comment on how it can be done? Thanks! [[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.