Re: [R] help to sum up data frame
With your data set as the data.frame xx library(reshape2) xx - melt(xx) dcast(xx, name ~ variable, sum) --- On Sun, 11/7/10, Mohan L l.mohanphys...@gmail.com wrote: From: Mohan L l.mohanphys...@gmail.com Subject: [R] help to sum up data frame To: r-help@r-project.org Received: Sunday, November 7, 2010, 8:59 AM Dear All, I have a data frame like this: name ip Bsent Breceived a 1 0.00 0.00 a 2 1.43 19.83 a 1 0.00 0.00 a 2 1.00 1.00 b 1 0.00 2.00 b 3 0.00 2.00 b 2 2.00 0.00 b 2 2.00 0.00 b 1 24.40 22.72 c 1 1.00 1.00 c 1 2.00 1.00 c 1 2.00 1.00 c 1 90.97 15.70 d 0 0.00 0.00 d 1 30.00 17.14 I want to sum up the similar name into one row, like : name ip Bsent Breceived a 6 2.43 20.83 b 9 28.40 26.72 c d I need help to sum up. Thanks for your time. Thanks Rg Mohan L __ 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-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] Populating then sorting a matrix and/or data.frame
--- On Thu, 11/11/10, William Dunlap wdun...@tibco.com wrote: From: William Dunlap wdun...@tibco.com Subject: Re: [R] Populating then sorting a matrix and/or data.frame To: Peter Langfelder peter.langfel...@gmail.com, r-help@r-project.org Received: Thursday, November 11, 2010, 4:19 PM Peter, Your example doesn't work for me unless I set options(stringsAsFactors=TRUE) first. Don't you mean stringsAsFactors=FALSE here? At least I get the same results you do but with stringsAsFactors=FALSE The TRUE condition is giving multiple NAs and error messages (If I do set that, then all columns of 'results' have class character, which I doubt the user wants.) results - data.frame() n = 10 for(i in 1:n){ + a = LETTERS[i]; + b = i; + c = 3*i + 2 + d = rnorm(1); + results - rbind(results, c(a,b,c,d)) + } There were 36 warnings (use warnings() to see them) warnings()[1:5] $`invalid factor level, NAs generated` `[-.factor`(`*tmp*`, ri, value = B) $`invalid factor level, NAs generated` `[-.factor`(`*tmp*`, ri, value = 2) $`invalid factor level, NAs generated` `[-.factor`(`*tmp*`, ri, value = 8) $`invalid factor level, NAs generated` `[-.factor`(`*tmp*`, ri, value = -0.305558353507095) $`invalid factor level, NAs generated` `[-.factor`(`*tmp*`, ri, value = C) results X.A. X.1. X.5. X.1.43055780028799. 1 A 1 5 1.43055780028799 2 NA NA NA NA 3 NA NA NA NA 4 NA NA NA NA 5 NA NA NA NA 6 NA NA NA NA 7 NA NA NA NA 8 NA NA NA NA 9 NA NA NA NA 10 NA NA NA NA Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Langfelder Sent: Thursday, November 11, 2010 12:25 PM To: Noah Silverman Cc: r-help@r-project.org Subject: Re: [R] Populating then sorting a matrix and/or data.frame On Thu, Nov 11, 2010 at 11:33 AM, Noah Silverman n...@smartmediacorp.com wrote: Still doesn't work. When using rbind to build the data.frame, it get a structure mostly full of NA. The data is correct, so something about pushing into the data.frame is breaking. Example code: results - data.frame() for(i in 1:n){ #do all the work #a is a test label. b,c,d are numeric. results - rbind(results, c(a,b,c,d)) } Works for me: results - data.frame() n = 10 for(i in 1:n){ a = LETTERS[i]; b = i; c = 3*i + 2 d = rnorm(1); results - rbind(results, c(a,b,c,d)) } results X.A. X.1. X.5. X.0.142223304589023. 1 A 1 5 0.142223304589023 2 B 2 8 0.243612305595176 3 C 3 11 0.476795513990516 4 D 4 14 1.0278220664213 5 E 5 17 0.916608672305205 6 F 6 20 1.61075985995586 7 G 7 23 0.370423691258896 8 H 8 26 -0.0528603547004191 9 I 9 29 -2.07888666920403 10 J 10 32 -1.87980721733655 Maybe there's something wrong with the calculation you do? Peter __ 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-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-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] sum in vector
Have a look at the reshape2 package. http://had.co.nz/reshape/ reshape2 is, to the user a slight modification of rehape but the author says it is much faster. The code below seems to do what you want. - xx - data.frame(market, price) library(reshape2) yy - melt(xx, id=1) dcast(yy, market ~ variable, sum) - --- On Sun, 11/14/10, lgpeco pavic.o...@gmail.com wrote: From: lgpeco pavic.o...@gmail.com Subject: [R] sum in vector To: r-help@r-project.org Received: Sunday, November 14, 2010, 7:02 AM hy guys i have one question :) i have two vectors markets and price market - c(1, 5, 7, 9, 9, 6, 5, 4, 4, 3, 1, 2, 1) price - c(100, 20, 30, 10, 50, 23, 23, 33, 96, 6, 4, 38, 96) i would like sum prices: market 1: (100+4+96), market 2: (38),..., market 9: (10+50) ao i would like get this result: (200, 38, ..., 60) and i don't wanna use while, for loops... is there any other function to sum these :) tnx for helping ;) -- View this message in context: http://r.789695.n4.nabble.com/sum-in-vector-tp3041661p3041661.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] replace a row in a matrix
Indexing (xx - matrix(1:4, nrow=2)) vec - 5:6 xx[2,] - vec xx --- On Sun, 11/14/10, cassie jones cassiejone...@gmail.com wrote: From: cassie jones cassiejone...@gmail.com Subject: [R] replace a row in a matrix To: r-help@r-project.org Received: Sunday, November 14, 2010, 10:59 AM Dear all, I created a n*2 matrix and I want to replace the ith row with a vector. Can anyone suggest me what is the simple way to do it? Sorry for bothering you with such simple question. I appreciate any hints or advice. Thanks in advance. Cassie [[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-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] how to get rid of unused space on all 4 borders in plot() render
Alternatively give ggplot2 package a try: x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) xx - data.frame(x,y) library(ggplot2) qplot(x,y, data=xx) --- On Sun, 11/21/10, madr madra...@interia.pl wrote: From: madr madra...@interia.pl Subject: [R] how to get rid of unused space on all 4 borders in plot() render To: r-help@r-project.org Received: Sunday, November 21, 2010, 11:49 AM x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5),yaxt=n, ann=FALSE) and this code produces: http://i53.tinypic.com/ffd7d3.png Where I marked in red areas that I want to get rid of and use as much real screen estate as I can. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052527.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] specifying colours in a ggplot2 piechart
Someone was asking how to do a 16 category piechart in OpenOffice Calc and it appears that it can not be done (which we, probably, should be happy about) but I thought that I'd try it in ggplot2. It works but I then thought I'd like to make the colours more distinctive but fro some reason I don't seem to be able to use manually assigned colours. Can anyone suggest where I'm going wrong? Thanks === library(ggplot2) mypie - data.frame(xx = c(12,13,6,7,9,10,4, 3, 8, 6, 8, 4, 6,5,2,3), zz = letters[1:16]) mycolours - c(a = red, b = blue, c = green, d = orange, e = red, f = blue, g = geen, h = orange, i = red, j = blue, k = green, l = orange, m = red, n = blue, o = green, p = orange ) pie1 - ggplot(mypie, aes(x = factor(zz), fill = factor(zz))) + geom_bar(width = 1) pie2 - pie + coord_polar(theta = x) + scale_colour_brewer(Pastel1) pie2 # try to get even nastier piechart with ugly colours to provide rast. pie3 - pie2 + scale_colour_manual(value=mycolours) pie __ 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] specifying colours in a ggplot2 piechart
Obviously I cannot type or spell. Your solution was great but do you have any idea why scale_colour_manual(value=mycolours) does not work. More typos on my part or am I misunderstanding what scale_colour_manual(value=mycolours) is supposed to do? Thanks --- On Tue, 11/23/10, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] specifying colours in a ggplot2 piechart To: John Kane jrkrid...@yahoo.ca Cc: r-h...@stat.math.ethz.ch Received: Tuesday, November 23, 2010, 2:02 PM fixing the various typos in your code, this works, lat_plot() + scale_fill_manual(value=mycolours) HTH, baptiste On 23 November 2010 19:47, John Kane jrkrid...@yahoo.ca wrote: Someone was asking how to do a 16 category piechart in OpenOffice Calc and it appears that it can not be done (which we, probably, should be happy about) but I thought that I'd try it in ggplot2. It works but I then thought I'd like to make the colours more distinctive but fro some reason I don't seem to be able to use manually assigned colours. Can anyone suggest where I'm going wrong? Thanks === library(ggplot2) mypie - data.frame(xx = c(12,13,6,7,9,10,4, 3, 8, 6, 8, 4, 6,5,2,3), zz = letters[1:16]) mycolours - c(a = red, b = blue, c = green, d = orange, e = red, f = blue, g = geen, h = orange, i = red, j = blue, k = green, l = orange, m = red, n = blue, o = green, p = orange ) pie1 - ggplot(mypie, aes(x = factor(zz), fill = factor(zz))) + geom_bar(width = 1) pie2 - pie + coord_polar(theta = x) + scale_colour_brewer(Pastel1) pie2 # try to get even nastier piechart with ugly colours to provide rast. pie3 - pie2 + scale_colour_manual(value=mycolours) pie __ 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-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] Creating Enumerated Variables
I think this is simpler but still not all that clean. === xx - structure(list(ID = 1:9, Age = c(10L, 10L, 10L, 11L, 11L, 11L, 10L, 10L, 11L), School = c(1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L ), Grade = c(98L, 97L, 92L, 90L, 80L, 70L, 80L, 79L, 70L)), .Names = c(ID, Age, School, Grade), class = data.frame, row.names = c(NA, -9L)) library(reshape) (rr - cast(xx, Age + School ~ ., length)) mylist - NULL for(i in 1:length(rr[,3])) { mylist[[i]] - seq(rr[i,3]) } ecount - unlist(mylist) cbind(xx[order(xx[,3]),], ecount) --- On Thu, 7/15/10, Dennis Murphy djmu...@gmail.com wrote: From: Dennis Murphy djmu...@gmail.com Subject: Re: [R] Creating Enumerated Variables To: jdellava jdell...@vcuhi.edu Cc: r-help@r-project.org Received: Thursday, July 15, 2010, 5:08 PM Hi: I sincerely hope there's an easier way, but one method to get this is as follows, with d as the data frame name of your test data: d - d[order(with(d, Age, School, rev(Grade))), ] d$Count - do.call(c, mapply(seq, 1, as.vector(t(with(d, table(Age, School)) d d ID Age School Grade Count 1 1 10 1 98 1 3 3 10 1 92 2 7 7 10 1 80 3 8 8 10 1 79 4 2 2 10 2 97 1 4 4 11 1 90 1 5 5 11 1 80 2 6 6 11 2 70 1 9 9 11 2 70 2 The code to get the count is a little convoluted: - first, find the frequency table of Age and School, transpose it and then unlist into a vector - use mapply to generate a sequence for each group from 1 up to its group count; mapply() is necessary to use the counts as a vector argument. This returns a list of sequences. - do.call() applies a function (here, c) to an input list, yielding the vector of groupwise indices we wanted. Basically, it flattens the list. This is what we assign to d$Count. Side note: I didn't get the correct ordering the first time, but I did the second time (2.11.1 64bit, Windows 7). HTH, Dennis On Thu, Jul 15, 2010 at 7:45 AM, jdellava jdell...@vcu.edu wrote: Hi, I am trying to create a variable counting the number of individuals based on two variables. I am able to do it or one variable, but not two. In SAS I was able to sort by two variables and use a first. statement to create the counts based on both. Here is an example: What I have ID Age School Grade 1 10 1 98 2 10 2 97 3 10 1 92 4 11 1 90 5 11 1 80 6 11 2 70 7 10 1 80 8 10 1 79 9 11 2 70 What I need ID Age School Grade School Count 1 10 1 98 1 3 10 1 92 2 7 10 1 80 3 8 10 1 79 4 2 10 2 97 1 4 11 1 90 1 5 11 1 80 2 6 11 2 70 1 9 11 2 70 2 I want to create counts of individuals age 10 in school 1 then age 10 in school two (the what I need set) Anyway to do this? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Creating-Enumerated-Variables-tp2290262p2290262.html Sent from the R help mailing list archive at Nabble.com. __ 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. [[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-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,
Re: [R] sort file names in numerical order
library(gtools) ?mixedorder --- On Sat, 7/17/10, Sebastian Gibb li...@sebastiangibb.de wrote: From: Sebastian Gibb li...@sebastiangibb.de Subject: [R] sort file names in numerical order To: r-help@r-project.org Received: Saturday, July 17, 2010, 4:31 AM Hello, I get some file names by list.files(). These names are in alphabetical order. I want to change it to logical numeric order. Example: fileNames - c(A10, A1, A2, B1, B2, B10) sort(fileNames) [1] A1 A10 A2 B1 B10 B2 I want to have: A1 A2 A10 B1 B2 B10 Is this possible? Kind regards, Sebastian __ 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-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] Reshaping data
Assuming your data is in data.frame xx library(reshape) mm1 - melt(xx, id=c(ID)) cast(mm1, ID ~ variable ) = --- On Mon, 7/19/10, Thomas Jensen thomas.jen...@eup.gess.ethz.ch wrote: From: Thomas Jensen thomas.jen...@eup.gess.ethz.ch Subject: [R] Reshaping data To: R-help@r-project.org Received: Monday, July 19, 2010, 6:48 PM Dear All, I have some data in the following shape: ID begin_t1 end_t1 begin_t2 end_t2 Thomas 11/03/04 13/05/06 04/02/07 16/05/08 ... ... ... ... ... Jens 24/01/02 23/05/03 07/06/03 14/11/05 I would like to reshape this data to have the following form: ID Begin_Time End_Time Thomas 11/03/04 13/05/06 Thomas 04/02/07 16/05/08 ... ... ... Jens 24/01/02 23/05/03 Jens 07/06/03 14/11/05 I have been doing some google searches and looked at the reshape library, but so far I have not been able to shape the data like I want. If you guys could help, I would greatly appreciate it! Best, Thomas __ 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-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] Sequence from 2 Vectors
enum.list - function(x,y) { mylist - NULL for(i in 1:length(x)) { mylist[[i]] - x[i]:y[i] } xx - unlist(mylist) } a - c(1,2,3) b - a+2 (harry - enum.list(a,b) ) --- On Mon, 7/19/10, Suphajak Ngamlak supha...@phatrasecurities.com wrote: From: Suphajak Ngamlak supha...@phatrasecurities.com Subject: [R] Sequence from 2 Vectors To: r-help@r-project.org Received: Monday, July 19, 2010, 11:25 PM I would like to create a vector that is a sequence from 2 vectors. Could anyone provide suggestion on this? For example a-c(1,2,3) b-a+2 b [1] 3 4 5 I would like to have a vector that is a sequence which starting from a and ending at b c = c(1:3,2:4,3:5) c = c(1,2,3,2,3,4,3,4,5) Thank you Best Regards, Suphajak Ngamlak Equity and Derivatives Trading Phatra Securities Public Company Limited Tel: +662-305-9179 Email: supha...@phatrasecurities.com [[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-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] simplify if statement in R ?
Will something like the %in% statements below help? x1 - 1 x2 - 5 y1 - c(2,3) y2 - c(4,5) y3 - c(7,8) x1 %in% y1 ||x2 %in% y2 x1 %in% y1 ||x2 %in% y3 --- On Tue, 7/20/10, Jim Maas jimmaa...@gmail.com wrote: From: Jim Maas jimmaa...@gmail.com Subject: [R] simplify if statement in R ? To: r-help@r-project.org Received: Tuesday, July 20, 2010, 2:11 PM I found a form of the if statement that works but it is very long. I'm attempting to check the value of of two different variables to see if they evaluate to either of two different values, which will result in a division by 0 in the final equation. This first if statement works for me ___ if ((x0.trial01 == 0.0)||(x0.trial01 == npt01)||(x1.trial01 == 0.0)||(x1.trial01 == npt01)) { x0.trial01.in - x0.trial01 + 0.5 x1.trial01.in - x1.trial01 + 0.5 npt01.in - npt01 + 1.0 } else { x0.trial01.in - x0.trial01 x1.trial01.in - x1.trial01 npt01.in - npt01 } __ I've tried if ( ( x0.trial01 || x1.trial01) == ( 0.0 || npt01) ) .. but it doesn't seem to work correctly. Is there a simpler way to check two variables for two different valuables? Thanks J Jim Maas __ 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-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] Issues reshaping data
A small useable data set would help immensely. Have a look at ?dput as a way to supply one. --- On Wed, 7/21/10, JGull8502 jason.gulli...@gmail.com wrote: From: JGull8502 jason.gulli...@gmail.com Subject: [R] Issues reshaping data To: r-help@r-project.org Received: Wednesday, July 21, 2010, 6:05 PM Hello All, I'm having some trouble reshaping my data from wide to long format. I have tried using both the reshape function and package. Although I haven't worked much with the reshape function, I have found the reshape package useful and intuitive for reshaping data from long to wide format. However, going the other way has me stumped with this type of data. My data is set up, roughly, as follows: SUBJECT TRIAL WORD1 WORD1.RT WORD2 WORD2.RT ... WORD25.RT 1 1 My 100 friend 200 ... ... 1 2 John's 250 dog 320 ... ... 1 3 His 120 waiter 400 ... ... 2 1 My 100 friend 200 ... ... 2 2 John's 250 dog 320 ... ... 2 3 His 120 waiter 400 ... ... What I would like to do is transform it roughly to: Subject TRIAL WORD RT 1 1 My 100 1 1 friend 200 . 2 3 His 120 2 3 Waiter 400 The furthest I've gotten with the package is melting the data such that RT is in its own column by using each WORD#.RT as a measure.var. However, I can't get the words to go with them (either in the melted frame or trying to cast the melted data). I tried the reshape function as well, but kept getting an error about duplicate row names. I lost the exact code I was using after closing R, but roughly, I would use Subject as an ID variable, varying = list(wordRTs,words) [where wordRTs are the set of WORD#.RT and words are the set of WORD# columns] , v.names=c(RT,WORD). If anyone has any help, it would be much appreciated! Thanks, Jason -- View this message in context: http://r.789695.n4.nabble.com/Issues-reshaping-data-tp2297853p2297853.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] xtable
Try str(influencia) I don't think xtable is intended to print lists. --- On Wed, 7/21/10, Silvano silv...@uel.br wrote: From: Silvano silv...@uel.br Subject: [R] xtable To: r-help@r-project.org Received: Wednesday, July 21, 2010, 4:15 PM Hi, How do I build a table from a regression model adjusted using xtable? Commands are: modelo1 = lm(Y~X1 + X2) influencia = influence.measures(modelo1) require(xtable) xtable(influencia) but it isn't work. Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ 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] how to write legend of a plot
There is no simpler way. It's not automatic but it is fairly simple at the most basic. It can get a bit complicated later. ltxt - c(cat,dog) x - 1:5 y - 1:5 plot (x,y, type='n', ann=FALSE) lines(x,y,col=1,lty=solid) points(x,y,pch=16) legend(1,4,ltxt, pch=16) --- On Thu, 7/22/10, Yogesh Tiwari yogesh@googlemail.com wrote: From: Yogesh Tiwari yogesh@googlemail.com Subject: [R] how to write legend of a plot To: r-help r-h...@stat.math.ethz.ch Received: Thursday, July 22, 2010, 6:17 AM Dear R Users, If we issue simple plot command in R we don't get legend of the plot automatically. For example, following lines plots two curves, but to write a legend of these two curves there is no simple command. I checked with ?legend but it seems bit complicated for me. Does anyone know how to get a legend in a simple way for following R plot. Thanks, Yogesh plot (x,y, type='n', ann=FALSE) lines(x,y,col=1,lty=solid) points(x,y,pch=16) points (x,y1, type='n', ann=FALSE) lines(x,y1,col=1,lty=solid) points(x,y1,pch=21) - [[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-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] Help with scatterplots in R
I think that we need an example of what you are doing before anyone can really answer that question. At the moment we don't even know how you are plotting the scatterplot. --- On Wed, 7/28/10, Sarah Chisholm sarah.chisholm...@ucl.ac.uk wrote: From: Sarah Chisholm sarah.chisholm...@ucl.ac.uk Subject: [R] Help with scatterplots in R To: r-help@r-project.org r-help@r-project.org Received: Wednesday, July 28, 2010, 6:57 AM Hi, When I plot a scatter plot, R automatically only gives the years on the x-axis. How can I make R also show the months on the x-axis? Thank you very much! [[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-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] save plot
Yes, ?jpeg --- On Tue, 8/3/10, linda.s samrobertsm...@gmail.com wrote: From: linda.s samrobertsm...@gmail.com Subject: Re: [R] save plot To: gavin.simp...@ucl.ac.uk Cc: r-help@r-project.org Received: Tuesday, August 3, 2010, 5:36 PM [I presume you addressed this to Duncan Murdoch for a good reason???] Open a new device before plotting, do your plotting, close the device. For example, using a PDF device via pdf(): pdf(my_plots.pdf, height = 8, width = 8, pointsize = 10, version = 1.4, onefile = TRUE) for(i in 1:10) { y - rnorm(100) x - rnorm(100) plot(y ~ x) } dev.off() Can I make a group of jpg instead of pdfs? Thanks. Linda __ 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-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] colour of label points on a boxplot
It would really help if you could reduce the information below to a small reproducible example, that is, some small bit of code that a reader can paste into R and poke around at. For sending a small sample dataset have a look at ?dput I believe that this problem has been discussed on the R-help list before and you might find something about it with a search (RSiteSearch()) or using Google but it is hard to tell without an example. --- On Thu, 8/5/10, alison waller alison.wal...@embl.de wrote: From: alison waller alison.wal...@embl.de Subject: [R] colour of label points on a boxplot To: r-help@r-project.org Received: Thursday, August 5, 2010, 7:36 AM Hi all, I have 6 datasets(dataframes Assem_ContigsLen7 through all_ContigsLen12) containing 3 columns (contig_id, contig_length, read_count). Each dataset is composed of 3 types of contigs (assemblies of genomic fragments), 1- all Bacterial fragments, 2 - all Viral fragments, 3 - mixed fragments. I identified the type of contig through a merge with another table with just contig_id and contig_type as below: AssemViral_ContigsLen-merge(Assem_ContigsLen,allViral_contigs,by.x=contig_id,by.y=X.Contid.ID,all.x=FALSE) Below is a boxplot for boxplot(Assem_ContigsLen7$length,Assem_ContigsLen8$length,Assem_ContigsLen9$length,Assem_ContigsLen10$length,Assem_ContigsLen11$length,Assem_ContigsLen12$length,main=100species_rep2,ylab=Contig_length) All of the longer contigs in the sixth data set are allViral. How can I colour or label these? I tried overlaying 2 boxplots of different colours (using add=TRUE), but the individual points of the whiskers aren't coloured (and I can't figure out how to do so) I experimented with using points, but there isn't a general function that I can apply to all 6 datasets to identify the allViral contigs. specific questions; 1 -how can I color the data points that represent the whiskers in a boxplot? 2 - Can I identify and colour subsets of datapoints within a boxplot? 3- any other suggestions? Thank you, Alison __ 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-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] a question about 'read.table' with or without 'read.table'.(urgent)
I believe Wu Gong has given you a solution. As a note you were probably reading in the first two columns as either factors or characters and the last one as numeric. You might want to try it again and then do a str() on the resulting data.frame to see what was happening. It can be confusing to discover that you have factor rather than character data in the data.frame. :) --- On Thu, 8/5/10, karena dr.jz...@gmail.com wrote: From: karena dr.jz...@gmail.com Subject: [R] a question about 'read.table' with or without 'read.table'.(urgent) To: r-help@r-project.org Received: Thursday, August 5, 2010, 12:32 AM Hi, I've got a quite tricky question. I have a txt file, named 'temp.txt', as the following: snp1 snp2 snp3 AA 00 00 GG GG 00 00 AA 00 I want to read the file into R. 1) when I use 'read.table' without 'header=T' option, temp - read.table('temp.txt') # I got temp V1 V2 V3 1 snp1 snp2 snp3 2 AA 00 00 3 GG GG 00 4 00 AA 00 2) If I include the 'header=T' option, temp - read.table('temp.txt', header=T, as.is=T) # I got temp snp1 snp2 snp3 1 AA 00 0 2 GG GG 0 3 00 AA 0 The difference is for 'snp3', we can see, in 1) the values for snp3 are all '00', while in 2) the values are all '0'. How can I keep the original values for snp3 as '00', meanwhile get the 'headers' or say the colnames as 'snp1 snp2 snp3'? thank you very much, karena -- View this message in context: http://r.789695.n4.nabble.com/a-question-about-read-table-with-or-without-read-table-urgent-tp2314423p2314423.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] odfWeave
It looks like a path problem. I have not figured out how to handle it in Win 7 (new system last week) but have a look at http://r.789695.n4.nabble.com/odfWeave-Error-td1595848.html#a1595848 which I think addresses the problem. --- On Tue, 8/31/10, Michael Kubovy kub...@virginia.edu wrote: From: Michael Kubovy kub...@virginia.edu Subject: [R] odfWeave To: r-help@r-project.org Received: Tuesday, August 31, 2010, 1:24 PM Dear -r-helpers, I'm trying to get my students to use odfWeave. Windows users are having trouble. I would appreciate advice. Comment 1: Hello I have spent a while today trying to get odfWeave to be successful I installed the unzip and zip program but it has not changed the error message.I have copied the error message below but I am sure it is the one others have experienced. odfWeave('test.odt','testOut.odt') Copying test.odt Setting wd to C:\Users\Mark\AppData\Local\Temp\RtmpHPp0yb/odfWeave30211245749 Unzipping ODF file using unzip -o test.odt Error in odfWeave(test.odt, testOut.odt) : Error unzipping file In addition: Warning message: In system(zipCmd[2], invisible = TRUE) : unzip not found Please advise on any way to get around this issue. I am running Windows 7. Comment 2: I have been having the same problem as Mark for a few days now. After inputting the odfWeave command, the output looks normal up to this line: Unzipping ODF file using unzip -o test.odt but the next few lines show an error message. It seems to be a problem with the unzipping process, but installing the Zip and Unzip programs do not remedy the problem. I am also running Windows 7. Michael _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 __ 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-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] odfWeave
Replying to my own post, it is a path problem. I downloaded the UnZip and Zip binaries, the 5.51-1 UnZip and the most recent Zip and then added a path to the UnZip directory, and odfWeave seems to be working. --- On Te, 8/31/10, John Kane jrkrid...@yahoo.ca wrote: From: John Kane jrkrid...@yahoo.ca Subject: Re: [R] odfWeave To: r-help@r-project.org, Michael Kubovy kub...@virginia.edu Received: Tuesday, August 31, 2010, 2:12 PM It looks like a path problem. I have not figured out how to handle it in Win 7 (new system last week) but have a look at http://r.789695.n4.nabble.com/odfWeave-Error-td1595848.html#a1595848 which I think addresses the problem. --- On Tue, 8/31/10, Michael Kubovy kub...@virginia.edu wrote: From: Michael Kubovy kub...@virginia.edu Subject: [R] odfWeave To: r-help@r-project.org Received: Tuesday, August 31, 2010, 1:24 PM Dear -r-helpers, I'm trying to get my students to use odfWeave. Windows users are having trouble. I would appreciate advice. Comment 1: Hello I have spent a while today trying to get odfWeave to be successful I installed the unzip and zip program but it has not changed the error message.I have copied the error message below but I am sure it is the one others have experienced. odfWeave('test.odt','testOut.odt') Copying test.odt Setting wd to C:\Users\Mark\AppData\Local\Temp\RtmpHPp0yb/odfWeave30211245749 Unzipping ODF file using unzip -o test.odt Error in odfWeave(test.odt, testOut.odt) : Error unzipping file In addition: Warning message: In system(zipCmd[2], invisible = TRUE) : unzip not found Please advise on any way to get around this issue. I am running Windows 7. Comment 2: I have been having the same problem as Mark for a few days now. After inputting the odfWeave command, the output looks normal up to this line: Unzipping ODF file using unzip -o test.odt but the next few lines show an error message. It seems to be a problem with the unzipping process, but installing the Zip and Unzip programs do not remedy the problem. I am also running Windows 7. Michael _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400 Charlottesville, VA 22904-4400 Parcels: Room 102 Gilmer Hall McCormick Road Charlottesville, VA 22903 Office: B011 +1-434-982-4729 Lab: B019 +1-434-982-4751 Fax: +1-434-982-4766 __ 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-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-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] how to represent error bar in a plot legend?
Can you give us a working example of what you are doing? I don't understand why you would need a pch symbol for an error bar. Perhaps if you are using an unboxed legend you could just use arrow() and text() to add the error bar to the legend? --- On Wed, 9/1/10, josef.kar...@phila.gov josef.kar...@phila.gov wrote: From: josef.kar...@phila.gov josef.kar...@phila.gov Subject: [R] how to represent error bar in a plot legend? To: r-help@r-project.org Received: Wednesday, September 1, 2010, 2:56 PM I have a simple barplot of 4 mean values, each mean value has an associated 95% confidence interval drawn on the plot as an error bar. I want to make a legend on the plot that uses the error bar symbol, and explains 95% C.I. How do I show the error bar symbol in the legend? I could not find any pch values that are appropriate 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. __ 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] Function Gini or Ineq
You installed the package but probably forgot to load the library. This works fine for me. = library(reldist) x-c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G-gini(x) --- On Fri, 9/3/10, Mestat mes...@pop.com.br wrote: From: Mestat mes...@pop.com.br Subject: Re: [R] Function Gini or Ineq To: r-help@r-project.org Received: Friday, September 3, 2010, 1:07 PM Hi Peng, I did that i installed the package RELDIST, but nothing happened. R does not recognize this function. Still looking for the solution. Thanks, Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525981.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] how can I plot bar plots with all the bars (negative and positive) in the same direction????
I believe that you will have to draw them in ggplot2 as someone mentioned or in base graphics. Here is a rough first attempt that may give you some ideas. xx - -3:4 yy - rep(-3,length(xx)) plot(xx,xx, type=n, xlim=c(-4, 5)) rect(xx, yy, xx+.5, xx ) --- On Fri, 9/3/10, Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov wrote: From: Zoppoli, Gabriele (NIH/NCI) [G] zoppo...@mail.nih.gov Subject: [R] how can I plot bar plots with all the bars (negative and positive) in the same direction To: r-help@r-project.org r-help@r-project.org Received: Friday, September 3, 2010, 1:12 PM Dear r-help mailing list, this seems stupid, but I actually don't find the solution: if I have a vector of numbers x of length n, ranging, say, from -3 to 4, if I do barplot (x) all the values below 0 go downwards, and all the positive values go upward. How can I make them all begin from the minimum pointing upwards? Thanks! Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest Researcher, LMP, NCI, NIH, Bethesda MD Work: 301-451-8575 Mobile: 301-204-5642 Email: zoppo...@mail.nih.gov __ 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-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] Newbie cross tabulation issue
It would help if you included a bit of sample data. See ?dput as a way of doing this. Also a good place to start is by looking at the package reshape. Have a look at http://had.co.nz/reshape/ for some information on the package. --- On Wed, 9/8/10, Jonathan Finlay jmfinl...@gmail.com wrote: From: Jonathan Finlay jmfinl...@gmail.com Subject: [R] Newbie cross tabulation issue To: r-help@r-project.org Received: Wednesday, September 8, 2010, 6:40 PM hi, i'm new in R and i need some help. Please, ¿do you know a function how can process cross tables for many variables and show the result in one table who look like this?: ++ |-- | X variable | |- | Xop1 | Xop2 | Xop3|.| ++ |Yvar1 | Total | %row..| | | Op1 | %row..| | | Op2 | %row..| |+---+ |Yvar2 | Op1 | %row..| | | Op2 | %row...| ++ |Yvar3 | Op1 | %row..| | | Op2 | %row...| | | Op3 | %row...| |+---+ Like a pivot table! thanks a lot. -- Jonathan. [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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-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] Alignment of lines within barplot bars
Like this? x - 4:7 barplot(x, density=10, angle=180) --- On Thu, 9/9/10, Steve Murray smurray...@hotmail.com wrote: From: Steve Murray smurray...@hotmail.com Subject: [R] Alignment of lines within barplot bars To: r-help@r-project.org Received: Thursday, September 9, 2010, 11:35 AM Dear all, I have a barplot upon which I hope to superimpose horizontal lines extending across the width of each bar. I am able to partly achieve this through the following set of commands: positions - barplot(bar_values, col=grey) par(new=TRUE) plot(positions, horiz_values, col=red, pch=_, ylim=c(min(bar_values), max(bar_values))) ...however this results in small, off-centred lines, which don't extend across the width of each bar. I've tried using 'cex' to increase the width, but of course this also increases the height of the line and results in it spanning a large range of y-axis values. I'm sure this shouldn't be too tricky to achieve, nor that uncommon a problem! It may be that I'm taking the wrong approach. Any help offered would be gratefully received. Many thanks, Steve __ 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-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] Alignment of lines within barplot bars
Okay, I misread what you wanted. Try this == x - 4:7 positions - barplot(x) mid - x/2 arrows(positions-.5,mid,positions+.5,mid,angle=0) == --- On Thu, 9/9/10, Steve Murray smurray...@hotmail.com wrote: From: Steve Murray smurray...@hotmail.com Subject: RE: [R] Alignment of lines within barplot bars To: jrkrid...@yahoo.ca, r-help@r-project.org Received: Thursday, September 9, 2010, 1:19 PM Thanks for the reply. However this isn't quite what I want. I'm looking to display a single horizontal line across each bar - the distance up the y-axis corresponding to the values of the object horiz_values. So unless there's a way of controlling where the argument 'density' plots a particular line, then I don't think this is what I'm looking for. Any other suggestions are very welcome. Thanks again, Steve Date: Thu, 9 Sep 2010 10:01:26 -0700 From: jrkrid...@yahoo.ca Subject: Re: [R] Alignment of lines within barplot bars To: r-help@r-project.org; smurray...@hotmail.com Like this? x - 4:7 barplot(x, density=10, angle=180) --- On Thu, 9/9/10, Steve Murray wrote: From: Steve Murray Subject: [R] Alignment of lines within barplot bars To: r-help@r-project.org Received: Thursday, September 9, 2010, 11:35 AM Dear all, I have a barplot upon which I hope to superimpose horizontal lines extending across the width of each bar. I am able to partly achieve this through the following set of commands: positions - barplot(bar_values, col=grey) par(new=TRUE) plot(positions, horiz_values, col=red, pch=_, ylim=c(min(bar_values), max(bar_values))) ...however this results in small, off-centred lines, which don't extend across the width of each bar. I've tried using 'cex' to increase the width, but of course this also increases the height of the line and results in it spanning a large range of y-axis values. I'm sure this shouldn't be too tricky to achieve, nor that uncommon a problem! It may be that I'm taking the wrong approach. Any help offered would be gratefully received. Many thanks, Steve __ 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-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] adding labels above bars in a barplot
Are you trying to say that you don't really like barplots? At least the OP did not ask for error bars as well. :) --- On Fri, 9/10/10, Dennis Murphy djmu...@gmail.com wrote: From: Dennis Murphy djmu...@gmail.com Subject: Re: [R] adding labels above bars in a barplot To: Antonio Olinto aolint...@bignet.com.br Cc: R-help r-h...@stat.math.ethz.ch Received: Friday, September 10, 2010, 2:31 PM Hi: To add to Greg's sound advice, if you want to put the numbers on top of the bars, why bother with the numerical scale? The entire point of a scale is to provide a reference for comparing different (sets of) values. \begin{rant} And when I see things like this: dat.bar VAR1 Category 01 17.5 Category 02 15.2 Category 03 10.3 Category 04 8.4 Category 05 20.3 I get doubly annoyed, because it is yet another attempt to use a bar chart to plot quantitative values by factor level. As I mentioned in a private response today, one of the problems with a bar chart is that it forces the numerical scale to have origin zero, and this is often neither necessary nor desirable. A simple line plot that connects the quantitative values between categories is sufficient, and takes *far* less ink to produce. The purpose of a statistical graphic is to convey information in a simple, clean, concise fashion - it is not meant to be a rococo art form. If you intend to write a function to automate a graphic, please think carefully about what is meant to be conveyed and the *visually* simplest means by which to convey it. \end{rant} The purpose of a bar chart is to visualize a (joint) discrete distribution. There are better ways to plot quantitative variables by group; in addition to the line plot mentioned above, the Cleveland dot chart can be very effective with many groups or multiple grouping factors. With two factors and a quantitative response, another option is the interaction plot. If this weren't the third such example/request I've seen today, I probably wouldn't be so apoplectic... Dennis On Fri, Sep 10, 2010 at 10:44 AM, Greg Snow greg.s...@imail.org wrote: See this message and the replies to it (and the replies to the replies, etc.): http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html In there is a discussion of why you don't really want to do that along with better alternatives and examples of the improved plots. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Antonio Olinto Sent: Friday, September 10, 2010 8:59 AM To: R-help Subject: [R] adding labels above bars in a barplot Hello, I want to make a general routine to draw barplots with numbers plotted above each bar. See the example below. I could not place the numbers on the middle of each bar because I could not calculate the right position of each x-axis tick. axTicks(1) indicated a unitary step, but it does not seem work. I appreciate any help or suggestions. Best regards, Antonio Olinto == CAT VAR1 VAR2 Category 01 17.5 9 Category 02 15.2 20 Category 03 10.3 500 Category 04 8.4 150 Category 05 20.3 5000 # Coping data from a spreadsheet dat.data - read.delim(clipboard,header=T) summary(dat.data) CAT VAR1 VAR2 Category 01:1 Min. : 8.40 Min. : 9 Category 02:1 1st Qu.:10.30 1st Qu.: 20 Category 03:1 Median :15.20 Median : 150 Category 04:1 Mean :14.34 Mean :1136 Category 05:1 3rd Qu.:17.50 3rd Qu.: 500 Max. :20.30 Max. :5000 dat.bar - data.frame(dat.data[,c(2)]) row.names(dat.bar)-dat.data[,1] names(dat.bar)-c(VAR1) dat.bar VAR1 Category 01 17.5 Category 02 15.2 Category 03 10.3 Category 04 8.4 Category 05 20.3 par(mar=c(12,6,3,2),cex.axis=1.2,cex.lab=1.4) barplot(t(as.matrix(dat.bar)),ylim=c(0,max(dat.data[,2]*1.1)),las=2,yla b=Y label text,col=orange) box() up - max(dat.data$VAR1)*0.1 for (i in c(0:nrow(dat.data))) { legend(0.25+i,dat.bar[1+i,1]+up,dat.data[i+1,3],col=blue,bty=n) } Webmail - iBCMG Internet http://www.ibcmg.com.br __ 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-help@r-project.org mailing list
Re: [R] Create Dot Chart
?dotchart perhaps. --- On Sun, 9/19/10, avsha38 avsha...@post.tau.ac.il wrote: From: avsha38 avsha...@post.tau.ac.il Subject: [R] Create Dot Chart To: r-help@r-project.org Received: Sunday, September 19, 2010, 10:46 AM Hello everyone... I would like to create a chart (see below), how can I do it with R? Any help, suggestion, samples... will be greatly appreciated. Thanks... Avi http://r.789695.n4.nabble.com/file/n2545921/DotChart.jpg -- View this message in context: http://r.789695.n4.nabble.com/Create-Dot-Chart-tp2545921p2545921.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] SAS user now converting to R - Help with Transpose
library(reshape) melt(dataset) # assuming dataset is a data.frame. --- On Mon, 9/28/09, baxterj j...@vt.edu wrote: From: baxterj j...@vt.edu Subject: [R] SAS user now converting to R - Help with Transpose To: r-help@r-project.org Received: Monday, September 28, 2009, 10:24 AM I am just starting to code in R and need some help as I am used to doing this in SAS. I have a dataset that looks like this: Chemical Well1 Well2 Well3 Well4 BOD 13.2 14.2 15.5 14.2 O2 7.8 2.6 3.5 2.4 TURB 10.2 14.6 18.5 17.3 and so on with more chemicals I would like to transpose my data so that it looks like this: Chemical WellID Value BOD Well1 13.2 BOD Well2 14.2 BOD Well3 15.5 BOD Well4 14.2 O2 Well1 7.8 O2 Well2 2.6 and so on In sas I would code it like this: proc sort data=ds1; by chemical; run; Proc Transpose data=ds1 out=ds2; by chemical; var Well1 Well2 Well3 Well4; run; data ds3; set ds2; rename _name_ = WellID; rename col1 = value; run; How can I do this in R?? Any help is much appreciated. Thanks! -- View this message in context: http://www.nabble.com/SAS-user-now-converting-to-R---Help-with-Transpose-tp25645393p25645393.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yaho __ 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] Urgently needed Exercise solutions related to Practical Data Analysis Using R Statisctial Software
Ah, but the offer of the permanent job with a foreign company is so enticing. BTW I think he says that he is a computer science student. I doubt business school students would be so cheap. --- On Sat, 10/3/09, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] Urgently needed Exercise solutions related to Practical Data Analysis Using R Statisctial Software To: Mahesh Krishnan bhangisoluti...@gmail.com Cc: r-help@r-project.org Received: Saturday, October 3, 2009, 9:47 PM On Oct 3, 2009, at 8:31 PM, Mahesh Krishnan wrote: Hello, Can anybody help me in solving these exercises on regular basis paid or unpaid basis. If he/she want to pay by PayPal then it should be noticed that mention at this email kindly your paypal email account where one can transfer money in all cases. But please respect the deadline in al cases.. *Dealine for this assignment is 07.10.09.* *If it is paid based then kindly let me know a decent price for this ..* Regard, Mahesh Mahesh has also posted this at: http://www.odesk.com/jobs/Practical-Data-Analysis-Statistical-software-data-analysis-needed_~~ee9e750d03fe4303?source=rss And is offering payment for a longer term for Solving Exercises for a student on regular basis! Estimated Workload:As needed - Less than 10 hrs/week Estimated Duration:3 to 6 months Last Buyer Activity:September 15, 2009 Who could resist with the average fee of $11.64? It's probably a life strategy. Pay your way through your business school homework exercises and then hire someone to do all your technical work once you get a management position. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo __ 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] Saving each output of a loop into something that can be graphed
Define a matrix to hold the data and insert it into the loop? Something like mymat - matrix(rep(NA, 20), nrow=10) for(i in 1:10){ a - i b - i+1 mymat[i,] - c(a,b) } matplot(mymat) --- On Mon, 10/5/09, RR99 redhwanza...@hotmail.com wrote: From: RR99 redhwanza...@hotmail.com Subject: [R] Saving each output of a loop into something that can be graphed To: r-help@r-project.org Received: Monday, October 5, 2009, 2:27 AM Hi, from the code below; whats happening is i want to plot how the [1,9] entry changes as the matrx changes, print[] gives the values one after the other, but only the last value is saved so my graph has only one point. does anyone know how i can merge all the outputs into one dataframe or something? Q-matrix(c(-0.59,5.44,0,0,0,0,0,0,0,0.59,-8.16,2.51,0,0,0,0,0,0,0,2.72,-5.64,9.45,0,0,0,0,0,0,0,3.13,-13.23,6.91,0,0,0,0,0,0,0,3.15,-14.88,10.22,0,0,0,0,0,0,0.63,7.97,-19.81,30.19,0,96.77,0,0,0,0,0,7.67,-98.12,0,19.35,0,0,0,0,0,0,37.74,-315.79,0,0,0,0,0,0,1.92,30.19,315.79,-116.12),nrow=9,ncol=9) T-Q*.01 for (i in (1:10)){ R-MatrixExp(i*T) S-print(R[1,9]) } any help would be greatly appreciated. -- View this message in context: http://www.nabble.com/Saving-each-output-of-a-loop-into-something-that-can-be-graphed-tp25745700p25745700.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ [[elided Yahoo spam]] __ 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] ggplot equivalent of par(xaxt)
I am playing around learning ggplot and cannot see how to suppress the x or y axis values ( equivalent of xaxt in basic graphics) It must be obvious but I'm not seeing it. Problem = timedata - structure(list(month = structure(c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c(Apr, Aug, Dec, Feb, Jan, Jul, Jun, Mar, May, Nov, Oct, Sep), class = factor), days = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L), temps = c(39.2896128958748, 24.0463892588954, 14.7144317681674, 26.4473300457299, 17.5444095397464, 17.0554503502032, 31.4467837626264, 26.8669765071813, 31.6581966018795, 33.6092903491756, 31.0445298273758, 40.3509587680154, 19.4642817074759, 25.4368212783209, 32.4769837888977, 20.0778425836075, 20.7275666901593, 7.67556461182032, 20.710769686952, 21.5516612954105, 26.7415743698656, 18.9571423249225, 29.4591207748791, 28.5211729296181, 17.4525627959805, 30.923234208759, 20.6069761349652, 32.5113389689697, 30.5485452291517, 36.108280749871, 33.1800210253601, 32.9708790994613, 36.6536488173013, 21.5872681514094, 17.3698466624875, 23.8735008677194, 21.7834805625618, 39.7441872059634, 19.2363318860703, 17.2332575158032, 16.5456489770264, 27.4925071988056, 15.416376720661, 47.0542371710754, 28.9163963545337, 16.5216554897757, 29.6730172832844, 24.2525944040588, 13.2414079242807, 15.9791856515821, 19.4387549406012, 33.9589173474519, 19.5190927150932, 26.3488819156667, 28.7998700507852, 23.9846608380048, 7.88582132117484, 18.6611269160678, 28.9459512288244, 29.7954832888135), duration = 1:60), .Names = c(month, days, temps, duration), row.names = c(NA, 60L), class = data.frame) p - ggplot(timedata, aes(duration, temps, colour=month)) + geom_line() + opts(legend.position = none, title=Yearly temperatures) How do I suppress the numbers on the x-axis? Thanks __ [[elided Yahoo spam]] __ 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] ggplot equivalent of par(xaxt)
Lovely. I knew it was not that difficult, I had even gotten as far as deciding it had to be an opts() command but I had no idea of what it was. Thanks very much. --- On Tue, 10/6/09, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] ggplot equivalent of par(xaxt) To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Tuesday, October 6, 2009, 2:57 PM Hi, 2009/10/6 John Kane jrkrid...@yahoo.ca: How do I suppress the numbers on the x-axis? Try this, p + opts(axis.text.x = theme_blank()) HTH, baptiste Thanks __ [[elided Yahoo spam]] __ 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. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] ggplot equivalent of par(xaxt)
Blindingly obvious!! Thanks for that. I can see it will help me find more than one option that I've been interested in. --- On Tue, 10/6/09, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] ggplot equivalent of par(xaxt) To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Tuesday, October 6, 2009, 3:07 PM body(theme_grey) could help you find the name of a particular option (that's what I did). baptiste 2009/10/6 John Kane jrkrid...@yahoo.ca: Lovely. I knew it was not that difficult, I had even gotten as far as deciding it had to be an opts() command but I had no idea of what it was. Thanks very much. --- On Tue, 10/6/09, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] ggplot equivalent of par(xaxt) To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Tuesday, October 6, 2009, 2:57 PM Hi, 2009/10/6 John Kane jrkrid...@yahoo.ca: How do I suppress the numbers on the x-axis? Try this, p + opts(axis.text.x = theme_blank()) HTH, baptiste Thanks __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Creating a Clustered-Stacked Column Chart
I don't think I've seen an R version, probably because the technique is not very good for displaying data. Have a look at http://chartsgraphs.wordpress.com/tag/r-and-excel/ for an alternative method of displaying the data using lattice. --- On Fri, 10/9/09, zhijie zhang rusers...@gmail.com wrote: From: zhijie zhang rusers...@gmail.com Subject: [R] Creating a Clustered-Stacked Column Chart To: r-h...@stat.math.ethz.ch Received: Friday, October 9, 2009, 5:31 AM Hi all, In R, is there some functions or ways to create a Clustered-Stacked Column Chart as the example in the following page http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.html? I have browsed the R Graph Gallery (http://addictedtor.free.fr/graphiques/) and searched the R site, and didnot find an appropriate method to do it. Anybody has met this problem before? Thanks a lot. [[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. __ Get the name you've always wanted @ymail.com or @rocketmail.com! Go to http://ca.promos.yahoo.com/jacko/ __ 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] Placing text in a ggplot
I am attempting to graph 12 months of temperatures, delineate the months with a vline and place the names of the months at the top of the graph. So far I have gotten everything to work except the names, despite getting a similar graph to work yesterday the day before yesterday with Baptise A's help. Can anyone suggest what I am doing wrong. Data set is below code. Thanks. Code = line.count - c(1,cumsum(as.vector((table(year$monthnum) namposts - line.count[1:12] temprange - range(year[,4], na.rm=TRUE) mlabs - month.name[1:12] p - ggplot(year, aes(duration, temps, colour=month)) + geom_line() + ylab(Temperature (C)) + xlab(Mean Daily Temperatures) + opts(legend.position = none, title=Ottawa, 2008, axis.text.x = theme_blank(), axis.ticks = theme_blank()) + geom_vline(xintercept= line.count) [[elided Yahoo spam]] p + geom_text(aes(x = namposts, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) == year - structure(list(monthnum = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L), days = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L), month = structure(c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
Re: [R] plot the same types of graphics on the same R graphic device
?lines ?points Something like : x - 1:10 y1 - rnorm(10, 4, 3) y2 - rnorm(5,5,2) ymax - max(c(y1,y2)) ymin - min(c(y1,y2)) plot(x, y1, col='red',ylim = c(ymin,ymax)) lines(y2, col='green') --- On Fri, 10/9/09, carol white wht_...@yahoo.com wrote: From: carol white wht_...@yahoo.com Subject: [R] plot the same types of graphics on the same R graphic device To: r-h...@stat.math.ethz.ch Received: Friday, October 9, 2009, 5:10 PM Hi, How to plot the same types of graphics on the same R graphic device? Suppose that we want to plot a vector y against x (using plot for instance). How is it possible to plot y against x for different values of these two vectors on the same device so that the plots could be compared? Cheers, Carol [[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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Adding additional X-axis data to charts, e.g. N values
?mtext should help. --- On Tue, 10/13/09, spidermonkeydp gbabo...@gmail.com wrote: From: spidermonkeydp gbabo...@gmail.com Subject: [R] Adding additional X-axis data to charts, e.g. N values To: r-help@r-project.org Received: Tuesday, October 13, 2009, 6:06 AM Hello All, Does anyone know if it is possible to add an additional X-axis data to a chart? For example, if I have plotted a bar chart of mean height on the Y-axis and have male and female on the X-axis. I want to add automatically the number of samples (N) for males and number of samples for females under their respective labels on the X-axis. I could do this manually using Power Point or equivalent software, but was wondering if there were any way of doing this automatically. I have tried in SPSS, Sigma-plot, Excel and cannot see a way of doing this. Can R provide me with this function? Thank you for any advice, even if you know of another package that may be capable of this. Best, D. -- View this message in context: http://www.nabble.com/Adding-additional-X-axis-data-to-charts%2C-e.g.-N-values-tp25870161p25870161.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ [[elided Yahoo spam]] __ 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] SPSS long variable names
library(Hmisc) spss.get may do it but it's been some time since I used it. --- On Sat, 10/10/09, Orvalho Augusto orvaq...@gmail.com wrote: From: Orvalho Augusto orvaq...@gmail.com Subject: [R] SPSS long variable names To: r-help@r-project.org Received: Saturday, October 10, 2009, 12:14 PM Hello guys I am new to this list and for R too. I am wondering if there is a patch for the SPSS reading code on the foreign package, in order to be able to read long variable names. Right now read.spss() just trunc the names to 8 characters. Or if someone could help me on other way: I have to process everyday a lot of SPSS Syntax Files and Dat files that come from one system that can only export data on through that way. I use PSPP to generate the spss data file (sav) that I read with R. From R I can export to MySQL, DBF and STATA to satisfy the needs of different guys here. The problem is the limit of 8 characters long on variable names. Can someone help on that? Caveman __ 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. __ The new Internet Explorer® 8 - Faster, safer, easier. Optimiz etexplorer/ __ 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] Division of data frame and deletion of values from column
?subset ?split --- On Fri, 10/16/09, Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com wrote: From: Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com Subject: [R] Division of data frame and deletion of values from column To: r-help@r-project.org Received: Friday, October 16, 2009, 12:16 PM Hi all, I guess this might be an easy question, but I've searched multiple help pages without finding any answear... so now I put my trust in you! I have a data frame (36 variables and 556 observations). One column contains three factors, and I would like to divide the data frame into three new ones, based on the value of the factors, thereby having only one value for all elements of the particular column in each of the data frames. The reason is that I later will create plots and do statistical analyzes on these data frames, and I don't want those factors affecting the result. ID Weight Age_days ... 1 18 76.1 106 2 19 77.0 175 3 20 78.1 121 4 21 78.2 121 5 22 78.8 106 6 23 76.3 106 . . . I also have another column containing several factors, of which I would like to exclude one (get NA instead). ID Weight Age_days Value_ID ... 1 18 76.1 106 high 2 19 77.0 175 low 3 20 78.1 121 middle 4 21 78.2 121 high 5 22 78.8 106 high 6 23 76.3 106 number -- exclude 7 24 76.9 175 low . . . I really hope someone could help me, though you might think it's too easy... Best regards, Joel _ Hitta kärleken nu i vår! http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952 [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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. __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share wha __ 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] negative length vectors are not allowed in wilcox.exact() and perm.test()
Number of politicians' promises kept? --- On Fri, 10/16/09, Patrick Burns pbu...@pburns.seanet.com wrote: From: Patrick Burns pbu...@pburns.seanet.com Subject: Re: [R] negative length vectors are not allowed in wilcox.exact() and perm.test() To: Ben Bolker bol...@ufl.edu Cc: r-help@r-project.org Received: Friday, October 16, 2009, 1:45 PM Ben Bolker wrote: David Croll wrote: I want to compare two datasets and I get the message Error in .Call(cpermdist2, ma = as.integer(m), mb = as.integer(col), : negative length vectors are not allowed after specifying the exact test. I'm using the exactRankTests package. Do you suggest me using the coin library, or is there anything wrong with my data? Hard to say. Reproducible example please ... ? Yes, can we get an example of a negative length vector, please. Pat __ 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. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Opt ernetexplorer/ __ 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] Different way of scaling data
library(reshape) ?rescaler I think something along the lines of rescaler(data.frame, type=range) should do what you want. --- On Fri, 10/16/09, Noah Silverman n...@smartmediacorp.com wrote: From: Noah Silverman n...@smartmediacorp.com Subject: [R] Different way of scaling data To: r help r-help@r-project.org Received: Friday, October 16, 2009, 1:41 PM Hi, I have a data.frame that I need to scale. I've been using the scale function and it works nicely. Some of the libraries I'm testing won't accept negative values for data, so I need to find a way to scale the data from 0 to 1 Any ideas? Thans! __ 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-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] How to right-align labels in dotchart
Oops replying to the wrong post but anyway does this do what you want? aa - c(3,6,3,5,8) lbs - c('cat','goat', 'elephant', 'horse', 'whale') dotchart(aa, pch=(16), col = 1:5, main=A Dotchart) axis(side = 2, seq_along(aa), lbs, las=1) --- On Thu, 10/15/09, Sean Carmody seancarm...@gmail.com wrote: From: Sean Carmody seancarm...@gmail.com Subject: [R] How to right-align labels in dotchart To: R Help Mailing List r-help@r-project.org Received: Thursday, October 15, 2009, 7:51 PM I have only just discovered the joys of the dotchart (since I am reading William Cleveland's -- Sean Carmody The Stubborn Mule http://www.stubbornmule.net http://twitter.com/seancarmody [[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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] doing a Tukey HSD post-hoc
?TukeyHSD --- On Fri, 10/16/09, Leslie J Seltzer lselt...@wisc.edu wrote: From: Leslie J Seltzer lselt...@wisc.edu Subject: [R] doing a Tukey HSD post-hoc To: r-help@r-project.org Received: Friday, October 16, 2009, 5:38 PM Hi all I have a large spreadsheet (Excel) file with many rows and columns in it. I have four treatment groups and using the lm function shows that there is a significant omnibus R with respect to several of the variables. I want to do a Tukey HSD in R. How can I do this? Leslie J. Seltzer, Ph.D. Postdoctoral Fellow, CERL Department of Psychology and Waisman Center 385 Waisman (Assay Lab) University of Wisconsin-Madison 1500 Highland Ave Madison, WI 53705 WORK: (608) 890-2525 CELL: (608) 886-6067 __ 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. __ [[elided Yahoo spam]] __ 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] Putting names on a ggplot
Putting names on a ggplot Can anyone suggest what I am doing wrong here. I am plotting daily temperatures at Ottawa Ontario for 2008 broken down by months, I seperate them by lines and want to put the names of the months at the top of the chart ( with in the graphing area) Everything is working as I want until I try to add the names of the months. I did something similar a few days ago and I cannot see were I am doing anything very different. Also I tried to use year$month -- an interger variable -- to get the colour breakdown with no success and finally added the months variable ( character) to get it. Is this normal for ggplot? Thanks. CODE-- Data is below code == year[,5] - 1:length(year[,1]) names(year) - c('month','days','year','temps', duration) month.days - as.vector(table(year[,1])) months - rep(month.name[1:12], month.days) month.counts - cumsum(as.vector( table(year[,1]))) namposts - c(1, month.counts[1:11]) mlabs - month.name[1:12] temprange - range(year$temps, na.rm=TRUE) p - ggplot(year, aes(duration, temps, colour=months)) + geom_line() + opts(legend.position = none, title=Yearly temperatures, axis.text.x = theme_blank(), axis.ticks = theme_blank()) p p - p + geom_vline(xintercept=month.counts) + ylab(Temperature (C)) + xlab(Daily Temperatures) p # this is where I see the problem. p - p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) p = DATA = year - structure(list(month = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L), days = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
Re: [R] Putting names on a ggplot
Thanks Stefan, the annotate approach works beautifully. I had not got that far in Hadley's book apparently :( I'm not convinced though that the explaination you shouldn't use aes in this case since nampost, temprange, ... are not part of the dataframe year. makes sense since it seems to work in this case unless I am missing something obvious. Mind you I'm good at missing the obvious especially in ggplot. Example = library(ggplot2) month - rep(month.abb[1:12], each=30) days - rep(1:30, 12) temps - rnorm(length(month), mean=25,sd=8) duration - 1:length(month) timedata - data.frame(month, days, temps, duration) head(timedata) mbs - c(1,seq(30, 360,by=30)) namposts - mbs[1:12] mlabs - month.name[1:12] trange - range(timedata$temps) drange - range(duration) p - ggplot(timedata, aes(duration, temps, colour=month)) + geom_line() + opts(legend.position = none, title=Yearly temperatures, axis.text.x = theme_blank(), axis.ticks = theme_blank()) p - p + geom_vline(xintercept= mbs) + ylab(Temperature (C)) + xlab(Daily Temperatures) + geom_text(aes(x = namposts+2.5, y = trange[2], label = mlabs), data = timedata, size = 2.5, colour='black', hjust = 0, vjust = 0) p = --- On Sat, 10/17/09, m...@z107.de m...@z107.de wrote: From: m...@z107.de m...@z107.de Subject: Re: [R] Putting names on a ggplot To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Saturday, October 17, 2009, 5:53 PM hi, On Sat, Oct 17, 2009 at 02:04:43PM -0700, John Kane wrote: Putting names on a ggplot p - p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) you shouldn't use aes in this case since nampost, temprange, ... are not part of the dataframe year. It should also work with geom_text i guess, but I prefere annotate for thinks like that: p + annotate(text,x=namposts+2.5, y = temprange[2], label= mlabs,size=2.5,colour='black', hjust = 0, vjust = 0) regards, stefan __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] Putting names on a ggplot
--- On Sun, 10/18/09, m...@z107.de m...@z107.de wrote: From: m...@z107.de m...@z107.de Subject: Re: [R] Putting names on a ggplot To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Sunday, October 18, 2009, 6:05 PM hello, On Sun, Oct 18, 2009 at 08:29:19AM -0700, John Kane wrote: Thanks Stefan, the annotate approach works beautifully. I had not got that far in Hadley's book apparently :( I'm not convinced though that the explaination you shouldn't use aes in this case since nampost, temprange, ... are not part of the dataframe year. makes sense since it seems to work in this case unless I am missing something obvious. Mind you I'm good at missing the obvious especially in ggplot. hmm, I thought that aes() is used to map variables from the used dataset (data=...) to parts of the plot. But obviously this is wrong, since your example below works. In my (maybe out of date) pdf version of Hadley's book an page 46 it says: |Any variable in an aes() specification must be contained inside the |plot or |layer data. This is one of the ways in which ggplot2 objects are |guaranteed |to be entirely self-contained, so that they can be stored and |re-used. I just realized I deleted Hadley's pdf so I cannot check this but it sounds right. so, maybe the problem with your version is, you map variables of your environment (namposts, trange) to aesthetic, which works fine in your current environment, but fails if you save the plot and load it in another environmento. | Error in eval(expr, envir, enclos) : object 'namposts' not found If you don't use save() on plots (I do not) this maybe not a problem for you. That's interesting. We're getting different error messages. I get p Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 12, 366 which makes your first idea seem more reasonable but I don't see why my other example would work if it was a data.frame problem :( Thanks for following up on this. I just installed 2.9.2 yesterday so I think I'm up to date on ggplot2 . Example = library(ggplot2) month - rep(month.abb[1:12], each=30) days - rep(1:30, 12) temps - rnorm(length(month), mean=25,sd=8) duration - 1:length(month) timedata - data.frame(month, days, temps, duration) head(timedata) mbs - c(1,seq(30, 360,by=30)) namposts - mbs[1:12] mlabs - month.name[1:12] trange - range(timedata$temps) drange - range(duration) p - ggplot(timedata, aes(duration, temps, colour=month)) + geom_line() + opts(legend.position = none, title=Yearly temperatures, axis.text.x = theme_blank(), axis.ticks = theme_blank()) p - p + geom_vline(xintercept= mbs) + ylab(Temperature (C)) + xlab(Daily Temperatures) + geom_text(aes(x = namposts+2.5, y = trange[2], label = mlabs), data = timedata, size = 2.5, colour='black', hjust = 0, vjust = 0) p = --- On Sat, 10/17/09, m...@z107.de m...@z107.de wrote: From: m...@z107.de m...@z107.de Subject: Re: [R] Putting names on a ggplot To: John Kane jrkrid...@yahoo.ca Cc: R R-help r-h...@stat.math.ethz.ch Received: Saturday, October 17, 2009, 5:53 PM hi, On Sat, Oct 17, 2009 at 02:04:43PM -0700, John Kane wrote: Putting names on a ggplot p - p + geom_text(aes(x = namposts + 2.5, y = temprange[2], label = mlabs), data = year, size = 2.5, colour='black', hjust = 0, vjust = 0) you shouldn't use aes in this case since nampost, temprange, ... are not part of the dataframe year. It should also work with geom_text i guess, but I prefere annotate for thinks like that: p + annotate(text,x=namposts+2.5, y = temprange[2], label= mlabs,size=2.5,colour='black', hjust = 0, vjust = 0) regards, stefan __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answe __ 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] Putting names on a ggplot
--- On Tue, 10/20/09, hadley wickham h.wick...@gmail.com wrote: From: hadley wickham h.wick...@gmail.com Subject: Re: [R] Putting names on a ggplot To: John Kane jrkrid...@yahoo.ca Cc: m...@z107.de, R R-help r-h...@stat.math.ethz.ch Received: Tuesday, October 20, 2009, 10:59 AM On Sun, Oct 18, 2009 at 10:29 AM, John Kane jrkrid...@yahoo.ca wrote: Thanks Stefan, the annotate approach works beautifully. I had not got that far in Hadley's book apparently :( I'm not convinced though that the explaination you shouldn't use aes in this case since nampost, temprange, ... are not part of the dataframe year. makes sense since it seems to work in this case unless I am missing something obvious. Mind you I'm good at missing the obvious especially in ggplot. It currently works (because I can't figure out how to make it an error) but you really should not do it. Hadley Now you tell me! I was a bit surprised when it worked the first time but I'm still stumbling around with ggplot. I'll put it into my list of things _not_ to do. I vote for fortunes too. __ Be smarter than spam. See how smart Spa k on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca __ 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] Inserting rows
?rbind df1 - data.frame(matrix(rep(0,9),nrow=3)) names(df1) - c(x1,x2,x3) rbind(df,df1) --- On Fri, 10/23/09, Ashta sewa...@gmail.com wrote: From: Ashta sewa...@gmail.com Subject: [R] Inserting rows To: R help r-help@r-project.org Received: Friday, October 23, 2009, 9:44 AM Hi all, I have the data set df with three varaibles, x1 x2 x3 1 2 5 2 4 1 5 6 0 1 1 2 I want to insert more rows ( eg, 3 rows with value filled with zeros) 1 2 5 2 4 1 5 6 6 1 1 2 0 0 0 0 0 0 0 0 0 Can any body help me out? Thanks __ 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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Change positions of columns in data frame
dataframe xx x1 x2 x3 1 2 5 2 4 1 5 6 0 1 1 2 data.frame(xx$x2,xx$x1,xx$x3) # or Awkward but works --- On Fri, 10/23/09, Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com wrote: From: Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com Subject: [R] Change positions of columns in data frame To: r-help@r-project.org Received: Friday, October 23, 2009, 10:19 AM Hi all, Probably a simple question, but I just can't find a simple answear in the older threads or anywhere else. I've added some new vectors as columns in a data frame using cbind(). As they're all put as the last columns inte the data frame, I would like to move them to specific positions. How do you do to change the position of a column in a data frame? I know I can use fieldTrial0809=data.frame(Sample_ID=as.factor(fieldTrial0809$Sample_ID), Plant_ID=as.factor(fieldTrial0809$Plant_ID), ...) to create a new data frame with the given columns in the specified order, but there must be an easier way..? All the best, Joel _ Nya Windows 7 - Hitta en dator som passar dig! Mer information. http://windows.microsoft.com/shop [[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. __ Be smarter than spam. See how smart SpamGuard is at giving ju __ 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] exclude data for boxplot stats using mathematical operator
Perhaps subset the data first? subset(x, x[,2] =0) --- On Mon, 10/26/09, e-letter inp...@gmail.com wrote: From: e-letter inp...@gmail.com Subject: [R] exclude data for boxplot stats using mathematical operator To: r-help@r-project.org Received: Monday, October 26, 2009, 3:25 AM Readers, I have a data set as follows: 1,1 2,2 3,3 4,4 5,3 6,2 7,-10 8,-9 9,-3 10,2 11,3 12,4 13,5 14,4 15,3 16,2 17,1 I entered this data set using the command 'read.csv'. I want to exclude values fewer than zero in column 2 so then I tried the following command: boxplot.stats(x[0,2],do.conf=FALSE) Error: syntax error, unexpected GT, expecting ',' in boxplot.stats(x[ Any help please? Yours, rhelp at conference.jabber.org r 251 __ 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. __ [[elided Yahoo spam]] __ 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] reshaping a data frame
Why not just unlist the data.frame and specify the number of rows in a matrix each time you need look at a different layout, assuming I understand the question. Example === aa - data.frame(1:100) bb - unlist(aa) (cc - matrix(bb, nrow=20)) --- On Mon, 10/26/09, Erin Hodgess erinm.hodg...@gmail.com wrote: From: Erin Hodgess erinm.hodg...@gmail.com Subject: [R] reshaping a data frame To: R help r-h...@stat.math.ethz.ch Received: Monday, October 26, 2009, 4:09 PM Dear R People: Suppose I have a data.frame, x.df, which has one column and 100 rows. Sometimes I need to see it as 20 rows and 5 columns, sometimes I need to see it as 10 rows with 10 columns. Is there a quick way to make those transformations, please? Thanks in advance, Sincerely, Erin [[elided Yahoo spam]] -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ 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. __ [[elided Yahoo spam]] __ 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] automatically adjusting axis limits
PLEASE provide commented, minimal, self-contained, reproducible code. particularly a sample data.set. At the moment it sounds like you have one variable (Wavelength) with a length of 56 and Reflectance with a length of 5,000. What format(s) are the data in? Data.frames? Clearly this is not the case but I don't understand the data layout at all --- On Tue, 10/27/09, Servet Ahmet Cizmeli sa.cizm...@usherbrooke.ca wrote: From: Servet Ahmet Cizmeli sa.cizm...@usherbrooke.ca Subject: [R] automatically adjusting axis limits To: r-help@r-project.org Received: Tuesday, October 27, 2009, 2:12 PM Dear R users, I am a newbie. Just switched from MATLAB. So thanks a lot for your patience. I have 5 spectra collected in field. Each spectra has two columns : Wavelength (56) and the actual measurement. Each measurement came in a different .txt file on disk (5 files in total). I wrote a script that reads every spectra in a for loop and constructs two variables : Wavelength (56) and Reflectance (56x5). I would like to plot Reflectance vs Wavelength i.e. overlay 5 spectra one one top of the other. plot(Wavelength, Reflectance) does not work (Matlab would do it): Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I then tried to construct the two matrices so that they have the same size (56x5) and plot it all at once with the command plot. This works but it is such a computationally inefficient way that I do not want to do this Why redundantly store wavelength data? Later I will have to process much more spectra so this is not a good practice for me. I then decided to draw the first spectra on the first run of the for loop with the command plot and add the subsequent graphs with the command lines. This works but the y-axes limits do not adjust automatically, leaving many spectra out of the axis limits ;( I don't want to set the axis limits by hand as I need this script to be completely autonomous. I don't want to program lines of code to calculate those limits myself either I am sure the mighty R can do it... BUT HOW (Matlab would easily do it with a single command) What I need is a command that will redraw the graph by automatically adjusting the axis limits. I have been searching for many days on the web, forums and mailing list archives but I still don't know how to do it. Please help thanks a lot from advance for your kindly help Servet __ 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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] R crashes
And PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- On Thu, 10/29/09, premmad mtechp...@gmail.com wrote: From: premmad mtechp...@gmail.com Subject: [R] R crashes To: r-help@r-project.org Received: Thursday, October 29, 2009, 6:13 AM My R crashes frequently when run with huge data. -- View this message in context: http://www.nabble.com/R-crashes-tp26110355p26110355.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com __ 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] polar.plot
--- On Fri, 10/30/09, Tony Greig tony.gr...@gmail.com wrote: From: Tony Greig tony.gr...@gmail.com Two questions: 1 - Say I have average speed and directions for tide and I would like to plot them on a polar plot, but with different colors so I can indicate the two directions. I'm using polar.plot from the plotrix library. How can I add a second b and dir.b series to a polar.plot? You may be able to set par(new=TRUE) but it looks to me like polar.plot sets the radius for each graph so you would need to come up with a way of dealing with this. library(plotrix) a = 3 dir.a = 85 b = 4 dir.b = 250 polar.plot(a, dir.a, start = 90, clockwise = T, show.grid.labels = T, radial.lim=c(0,5), line.col=2, lwd=2) 2 - Which parameter in polar.plot can I use to set the orientation for the grid labels which seem to default at 90 in my example above? start ? polar.plot(a, dir.a, start = 90, clockwise = T, show.grid.labels = T, radial.lim=c(0,5), line.col=2, lwd=2) op - par(new=TRUE) polar.plot(b, dir.b, start = 90, clockwise = T, show.grid.labels = T, radial.lim=c(0,5), line.col=1, lwd=2) par(op) __ [[elided Yahoo spam]] __ 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] how to loop thru a matrix or data frame , and append calculations to a new data frame?
Do you mean to apply the same calculation to each element? ? apply mydata - data.frame(aa = 1:5, bb= 11:15) mp5 - function(x) x*5 mp5data - apply(mydata, 2, mp5) mp5data This is functionally equivelent to a double if loop. mydata - data.frame(aa = 1:5, bb= 11:15) newdata - data.frame(matrix(rep(NA,10), nrow=5)) for (i in 1:length(mydata[1,])) { for (j in 1:5) { newdata[j,i] - mydata[j,i]*5 } } newdata --- On Fri, 10/30/09, Robert Wilkins robst...@gmail.com wrote: From: Robert Wilkins robst...@gmail.com Subject: [R] how to loop thru a matrix or data frame , and append calculations to a new data frame? To: r-help@r-project.org Received: Friday, October 30, 2009, 11:46 AM How do you do a double loop through a matrix or data frame , and within each iteration , do a calculation and append it to a new, second data frame? (So, if your original matrix or data frame is 4 x 5 , then 20 calculations are done, and the new data frame, which had 0 rows to start with, now has 20 rows) __ 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-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] how to loop thru a matrix or data frame , and append calculations to a new data frame?
Duh, thought of that after I'd left for dinner :( --- On Sat, 10/31/09, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] how to loop thru a matrix or data frame , and append calculations to a new data frame? To: John Kane jrkrid...@yahoo.ca Cc: r-help@r-project.org, Robert Wilkins robst...@gmail.com Received: Saturday, October 31, 2009, 2:00 PM On Oct 31, 2009, at 12:33 PM, John Kane wrote: Do you mean to apply the same calculation to each element? ? apply mydata - data.frame(aa = 1:5, bb= 11:15) mp5 - function(x) x*5 mp5data - apply(mydata, 2, mp5) mp5data It would have been much more compact (and in the spirit of functional programming) to just do: mp5data - mydata*5 # binary operations applied to dataframes give sensible results when the data types allow. mp5data aa bb [1,] 5 55 [2,] 10 60 [3,] 15 65 [4,] 20 70 [5,] 25 75 Many times the loops are implicit in the vectorized design of R. And that solution would not result in the structure requested, for which some further straightening would be needed: mp5data - as.vector(as.matrix(mydata)*5) mp5data [1] 5 10 15 20 25 55 60 65 70 75 -- David This is functionally equivelent to a double if loop. mydata - data.frame(aa = 1:5, bb= 11:15) newdata - data.frame(matrix(rep(NA,10), nrow=5)) for (i in 1:length(mydata[1,])) { for (j in 1:5) { newdata[j,i] - mydata[j,i]*5 } } newdata --- On Fri, 10/30/09, Robert Wilkins robst...@gmail.com wrote: From: Robert Wilkins robst...@gmail.com Subject: [R] how to loop thru a matrix or data frame , and append calculations to a new data frame? To: r-help@r-project.org Received: Friday, October 30, 2009, 11:46 AM How do you do a double loop through a matrix or data frame , and within each iteration , do a calculation and append it to a new, second data frame? (So, if your original matrix or data frame is 4 x 5 , then 20 calculations are done, and the new data frame, which had 0 rows to start with, now has 20 rows) __ 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-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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] look up and Missing
I'm not quite sure I understood the second queston but does this work? subset(temp, xx$v2==-9) subset(temp, xx$v2!= -9) --- On Sun, 11/8/09, Ashta sewa...@gmail.com wrote: From: Ashta sewa...@gmail.com Subject: [R] look up and Missing To: r-h...@stat.math.ethz.ch Received: Sunday, November 8, 2009, 10:23 AM HI R-Users Assume that I have a data frame 'temp' with several variables (v1,v2,v3,v4,v5.). v1 v2 v3 v4 v5 1 2 3 3 6 5 2 4 2 0 2 -9 5 4 3 6 2 1 3 4 1, I want to look at the entire row values of when v2 =-9 like 2 -9 5 4 3 I wrote K- list(if(temp$v2)==-9)) I wrote the like this but it gave me which is not correct. False false false false false 2. I want assign that values as missing if v2 = -9. (ie., I want exclude from the analysis How do I do it in R? Thanks in advance __ 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. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] Counting non-empty levels of a factor
With xx as your sample data will this work? See ?addmargins jj - table(xx) addmargins(jj, 2) # or for both margins addmargins(jj, c(1,2)) or apply(jj, 1, sum) --- On Sun, 11/8/09, sylvain willart sylvain.will...@gmail.com wrote: From: sylvain willart sylvain.will...@gmail.com Subject: [R] Counting non-empty levels of a factor To: r-help@r-project.org Received: Sunday, November 8, 2009, 8:38 AM Hi everyone, I'm struggling with a little problem for a while, and I'm wondering if anyone could help... I have a dataset (from retailing industry) that indicates which brands are present in a panel of 500 stores, store , brand 1 , B1 1 , B2 1 , B3 2 , B1 2 , B3 3 , B2 3 , B3 3 , B4 I would like to know how many brands are present in each store, I tried: result - aggregate(MyData$brand , by=list(MyData$store) , nlevels) but I got: Group.1 x 1 , 4 2 , 4 3 , 4 which is not exactly the result I expected I would like to get sthg like: Group.1 x 1 , 3 2 , 2 3 , 3 Looking around, I found I can delete empty levels of factor using: problem.factor - problem.factor[,drop=TRUE] But this solution isn't handy for me as I have many stores and should make a subset of my data for each store before dropping empty factor I can't either counting the line for each store (N), because the same brand can appear several times in each store (several products for the same brand, and/or several weeks of observation) I used to do this calculation using SAS with: proc freq data = MyData noprint ; by store ; tables brand / out = result ; run ; (the cool thing was I got a database I can merge with MyData) any idea for doing that in R ? Thanks in advance, King Regards, Sylvain Willart, PhD Marketing, IAE Lille, France __ 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. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Opt ernetexplorer/ __ 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] Complicated For Loop (to me)
I think that we probably need a sample database of your original data. A few lines of the dataset would probably be enough as long as it was fairly representative of the overall data set. See ?dput for a way of conveniently supply a sample data set. Otherwise off the top of my head, I would think that you could just put all your subsets into a list and use lapply but I'm simply guessing without seeing the data. --- On Mon, 11/9/09, agm. amur...@vt.edu wrote: From: agm. amur...@vt.edu Subject: Re: [R] Complicated For Loop (to me) To: r-help@r-project.org Received: Monday, November 9, 2009, 3:18 PM I've looked through ?split and run all of the code, but I am not sure that I can use it in such a way to make it do what I need. Another suggestion was using lists, but again, I am sure that the process can do what I need, but I am not sure it would work with so many observations. I might have been too simple in my code. Let me try to explain it more clearly: I've got a data set of 4500 observations. I have already subset it into race/ethnicity (which I did by simple code). Now I needed to subset each race/ethnicity again into 9 separate regions. I again did this by simple code. The problem is now, I need to calculate a percentage for three different variables for all 9 regions for each race. I was trying to do this through a loop command. So a snippet of my code is : names - c(white, black, asian, hispanic) for(j in 1:length(names)){ for(i in 1:9){ names[j].cd[i].es.wash - subset(names[j].cd[i], SLUNCH==1) es.cd[i].names.w - sum(names.cd[i].es.wash$NWEIGHT)/sum(names.cd[i]$NWEIGHT) } } Maybe that makes it clearer. If not, I apologize. Thanks for the help that I have already received. It is greatly appreciated. Tony -- View this message in context: http://old.nabble.com/Complicated-For-Loop-%28to-me%29-tp26269479p26272994.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get i __ 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] Noobie question on aggregate tapply and by
Here's one way with aggregate() library(car) # You probably will need to install it. aggregate(DF[,3-4], by=list(years), mean,na.rm=TRUE) recode(x, c(1,2)='A'; else='B') DF$years - recode(DF$years, c(5,6,7)= '5-7') DF You may also want to have a look at the reshape and plyr packages. --- On Sun, 4/25/10, steven mosher mosherste...@gmail.com wrote: From: steven mosher mosherste...@gmail.com Subject: [R] Noobie question on aggregate tapply and by To: r-help r-help@r-project.org Received: Sunday, April 25, 2010, 2:29 AM I have a 43MB dataframe ( 5 variables) and I'm trying to summarize subsets of the data. I've RTFM ( not very clear) and looked at a variety of samples but cant seem to figure out how to make these functions work. A sample of what I want to do would be this: ids-seq(1,50) years-c(rep(5,10),rep(6,10),rep(7,10),rep(8,20)) data-c(rep(23.2,7),rep(14.2,17),rep(29.2,6),rep(13.4,10),rep(16.3,5), NA, rep(40,4)) data2-c(rep(22.2,5),rep(13.2,8),NA, rep(29.8,16),rep(12.4,10),rep(16.3,5), rep(38,5)) DF-data.frame(ids,years,data,data2) That will give you a dataframe that is a good analog of what I have. i would like to calculate means ( with NA removed na.rm) for each level of years. data data2 5 xx. yy. 6 xx yz 7 ... ,,, 8 .. ... And then things like this: 5-7 : xx yy 8 : xy zz [[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-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] numerical or not?
I don't seem to be able to duplicate the problem. Using your read.table command I get a data.frame (which is of course a type of list) and something like sum(dat1[,1] gives me a numerical result. What variable is giving you the not numerical error message --- On Mon, 4/26/10, Laetitia Schmid laeti...@gmt.su.se wrote: From: Laetitia Schmid laeti...@gmt.su.se Subject: [R] numerical or not? To: r-help@r-project.org Received: Monday, April 26, 2010, 5:19 PM Hi, I've had a little problem for several weeks now. It is annoying and therefore I will ask for help: When I write a script with several iterations, I make it write out a text file to save the data during the run. For example I write: if (i %% 25) write.table(output,temporary_output.txt) Later on, when I read in this output and want to calculate things, R complains that x is not numeric. I read it in with the following command: dat1-read.table(temporary_output.txt,header=TRUE). It seems that R is saving my temporary output as a list. What is wrong here? And how can I do it better? This time I attached the temporary_output.txt: Thanks. Laetitia -Inline Attachment Follows- __ 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-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] How to make legend with line+ character
I suspect that you may have to construct the legend by hand (well, by explicit text commands anyway) Something like this seems to work and it should not be that difficult to write a function to handle the text commands. plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') text(1.4,6, label=-a- , col=red) text(2.5,6, label=dg1) --- On Mon, 4/26/10, Mario Valle mva...@cscs.ch wrote: From: Mario Valle mva...@cscs.ch Subject: [R] How to make legend with line+ character To: r-help@r-project.org r-help@r-project.org Received: Monday, April 26, 2010, 7:32 AM Dear all, I have a multiline plot with each line labeled with a different letter. But I'm not able to make the legend display the same kind of pattern '-a-', instead the letter is overwritten by the line. A simpler legend with only the letter is not very visible and the pt.bg does nothing with letters. Any idea? plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a') legend(left, legend=c(ds1,ds2), bty='n', col=1:2, lty=2,lwd=4,pch=letters) Thanks for your help! mario -- Ing. Mario Valle Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ 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-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] Newbie question
It depends on what kind of plot etc and which package you are using. The basic plot routines are summarized in ?plot.default with many of the parameters controlled by ?par I think at the simplist something like this would work and you can add colour plotting specs etc as you experiment. This assumes col1, c2 and col3 are separate vectors. plot(col, col2) lines(col1,col3) The package ggplot does very nice graphs but completely differently :) --- On Fri, 4/30/10, William Clapham william.clap...@ars.usda.gov wrote: From: William Clapham william.clap...@ars.usda.gov Subject: [R] Newbie question To: r-help@r-project.org Received: Friday, April 30, 2010, 10:42 AM If I have 3 columns of data, col 1 = Independent Var; cols 2 and 3 are Dep. Vars. I would like to produce a plot with both: col2=f(col1) and col3=f(col1). How do I do this such that I can control line parameters (line type, color, etc). I know that if I stack the data and col2 and col3 are treated as different factor levels, that I can accomplish this, but lose control over the line parameters. Any guidance is greatly appreciated. Bill __ 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-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] Scree diagram,
Presumably, a scree plot? Philip may find something useful here http://www.statmethods.net/advstats/factor.html --- On Sun, 5/2/10, Ista Zahn istaz...@gmail.com wrote: From: Ista Zahn istaz...@gmail.com Subject: Re: [R] Scree diagram, To: Philip Wong tombfigh...@mysinamail.com Cc: r-help@r-project.org Received: Sunday, May 2, 2010, 10:51 AM Hi Phillip, I've never heard of a scree _diagram_, I'm not even sure what that is. To get started with principal components analysis in R, I suggest the psych package. The package vignettes are quite detailed, I suggest starting there. Best, Ista On Sun, May 2, 2010 at 12:06 AM, Philip Wong tombfigh...@mysinamail.com wrote: hello, I've two questions today. 1) I'm trying to do a scree diagram, I did a Google for a specific command I could used to do so. All I could find is a screeplot. Are they the same command? 2) what command can I used to present a PC scores, eigenvectors of the PC scores, and component correlations? thanks! -- View this message in context: http://r.789695.n4.nabble.com/Scree-diagram-tp2122453p2122453.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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-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] adding year information to a scatter plot
I think that one of the packages, perhaps Hmisc or plotrix does this but you can also do it just using text() Example plot(b~a,data=df, xlim=c(min(df$a)-5,max(df$a)+5), ylim= c(min(df$b)-5,max(df$b)+5)) text( df$a+1,df$b, labels=df$year) Alternatively you can do this in ggplot library(ggplot) p - ggplot(df, aes(x=a, y=b, label=year)) p + geom_text() --- On Sun, 5/2/10, Ozan Bakis oba...@gsu-giam.net wrote: From: Ozan Bakis oba...@gsu-giam.net Subject: [R] adding year information to a scatter plot To: r-help@r-project.org Received: Sunday, May 2, 2010, 3:25 PM Hi R users, I would like to add year information to each point in a scatter plot. The following example shows what i mean: df=data.frame(year=c(2001,2002,2003),a=c(8,9,7),b=c(100,90,95)) df plot(b~a,data=df) Now, I would like to see which point belongs to 2001, 2002 and 2003 in the above graphic. Thank you very much, ozan [[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-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] / Operator not meaningful for factors
I think that you are correct. R has the annoying habit of converting character data to factors when you don't want it to while it is importing data. This is because the in the option stringsAsFactors is set to TRUE for some weird historical reasons. Try the command str(insert name of data) and see what happens. It should show you which columns of data are being treated as factors. You can convert the back to character or to numeric. See the FAQ Part 7 How do I convert factors to numeric? or you can use the String as options command in the read.table to FALSE Something like this should work, I think, but it's not tested read.table(C:/rdata/trees.csv, stringsAsFactors=FALSE) --- On Mon, 5/3/10, vincent.deluard vincent.delu...@trimtabs.com wrote: From: vincent.deluard vincent.delu...@trimtabs.com Subject: Re: [R] / Operator not meaningful for factors To: r-help@r-project.org Received: Monday, May 3, 2010, 6:22 PM Hi there, This will sound very stupid because I just started using R but I see you had similar problems. I just loaded a very large dataset (2950*6602) from csv into R. The format is ticker=row, date=column. Every time I want to compute basic operations, R returns In Ops.factor: not meaningful for factors I believe it is because R does not read the data as numbers but I am not sure. Can anybody help? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] Help needed with legend
A small executable example would help here. We don't even know how you are graphing this. There are several packages including lattice and ggplot as well as the base graphs. If you are doing this in base graphics have a look at ?text --- On Mon, 5/3/10, Nish nisha.mukte...@gmail.com wrote: From: Nish nisha.mukte...@gmail.com Subject: [R] Help needed with legend To: r-help@r-project.org Received: Monday, May 3, 2010, 3:10 PM Hello, I am new to R and need some help with the legend. How can I add a legend for two variables (in two columns) each having multiple values to be explained in the legend. For example: Var 1 Var 2 symbol - Higher symbol - Higher symbol - Avg symbol - Avg symbol - Lower symbol - Lower I know we can use the ncol option but not sure how to put in the values of the variable. Can we use the legend function of this? If yes, how? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Help-needed-with-legend-tp2124457p2124457.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] How to replace all NA values in a data.frame with another ( not 0) value
?replace Something like this should work replace(df1, is.na(df1), 000/000) --- On Tue, 5/4/10, Nevil Amos nevil.a...@gmail.com wrote: From: Nevil Amos nevil.a...@gmail.com Subject: [R] How to replace all NA values in a data.frame with another ( not 0) value To: r-h...@stat.math.ethz.ch Received: Tuesday, May 4, 2010, 8:54 AM I need to replace NA occurrences in multiple columns in a data.frame with 000/000 how do I achieve this? Thanks Nevil Amos __ 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-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] Show number at each bar in barchart?
Try this. My appologies for not giving the attribution but I forget who wrote it. my.values=10:15 x - barplot(my.values, ylim=c(0,11)) text(x, my.values, my.values, pos=3) text(x, my.values, wibble, pos=3) --- On Tue, 5/4/10, someone vonhof...@t-online.de wrote: From: someone vonhof...@t-online.de Subject: [R] Show number at each bar in barchart? To: r-help@r-project.org Received: Tuesday, May 4, 2010, 8:41 AM when i plot a barchart with 5 bars there is one bar pretty long and the others get smaller like (20, 80, 20, 5, 2) is there a way of displaying the number accoirding to each bar next to it? like in a bwplot the panel option N? -- View this message in context: http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] make a column from the row names
Have a look at ?substring --- On Tue, 5/4/10, Mohan L l.mohan...@gmail.com wrote: From: Mohan L l.mohan...@gmail.com Subject: [R] make a column from the row names To: r-help@r-project.org Received: Tuesday, May 4, 2010, 9:06 AM Dear All, avglog 01/11/09 02/11/09 03/11/09 04/11/09 9.75 4.50 4.50 8.67 avglog1 - data.frame(avglog) avglog1 avglog 01/11/09 9.75 02/11/09 4.50 03/11/09 4.50 04/11/09 8.67 The first column isnt a column, It's the row names. I makeing a column from the row names by using the following value1$Day - rownames(value1) value1 avglog Day 01/11/09 9.75 01/11/09 02/11/09 4.50 02/11/09 03/11/09 4.50 03/11/09 04/11/09 8.67 04/11/09 But I want like this : Day avglog Index 1 1 9.75 9.75*100 2 2 4.50 4.50*100 3 3 4.50 4.50*100 4 4 8.67 8.67*100 How to achieve it? Any help will be appreciated. Thanks Rg Mohan L [[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-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] / Operator not meaningful for factors
--- On Tue, 5/4/10, Petr PIKAL petr.pi...@precheza.cz wrote: From: Petr PIKAL petr.pi...@precheza.cz Subject: Re: [R] / Operator not meaningful for factors To: John Kane jrkrid...@yahoo.ca Cc: r-help@r-project.org, vincent.deluard vincent.delu...@trimtabs.com Received: Tuesday, May 4, 2010, 3:38 AM Hi r-help-boun...@r-project.org napsal dne 04.05.2010 00:50:00: I think that you are correct. R has the annoying habit of converting character data to factors when you don't want it to while it is importing data. This is because the in the option stringsAsFactors is set to TRUE for some weird historical reasons. It is a matter of opinion. I consider it quite useful feature. If I see by str(some.data) or summary(data0 that numeric columns are factors I know something is wrong with input. I'm not denying that it can be useful but IIRC from a discussion a couple of years ago, it was a fairly arbitary decision. On the other hand it can be very annoying when one has some kinds of data. and when I want to use ggplot, xyplot or just plot my data with different colours/sizes/pchs/ it is quite easy to use as.numeric(my.factor) to get numeric representation of levels. Finally you can easily change labels, concatenate levels and so on. Just my 2 cents. Regards Petr Try the command str(insert name of data) and see what happens. It should show you which columns of data are being treated as factors. You can convert the back to character or to numeric. See the FAQ Part 7 How do I convert factors to numeric? or you can use the String as options command in the read.table to FALSE Something like this should work, I think, but it's not tested read.table(C:/rdata/trees.csv, stringsAsFactors=FALSE) --- On Mon, 5/3/10, vincent.deluard vincent.delu...@trimtabs.com wrote: From: vincent.deluard vincent.delu...@trimtabs.com Subject: Re: [R] / Operator not meaningful for factors To: r-help@r-project.org Received: Monday, May 3, 2010, 6:22 PM Hi there, This will sound very stupid because I just started using R but I see you had similar problems. I just loaded a very large dataset (2950*6602) from csv into R. The format is ticker=row, date=column. Every time I want to compute basic operations, R returns In Ops.factor: not meaningful for factors I believe it is because R does not read the data as numbers but I am not sure. Can anybody help? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Operator-not- meaningful-for-factors-tp791563p2124697.html Sent from the R help mailing list archive at Nabble.com. __ 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-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-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] What is the best way to have R output tables in an MS Word format? (shaping R core)
For simply doing tables xtable has done some nice work for me. --- On Fri, 5/7/10, Joris Meys jorism...@gmail.com wrote: From: Joris Meys jorism...@gmail.com Subject: Re: [R] What is the best way to have R output tables in an MS Word format? (shaping R core) To: Duncan Murdoch murdoch.dun...@gmail.com Cc: r-h...@stat.math.ethz.ch Received: Friday, May 7, 2010, 6:48 AM Well, there's always RExcel to get all your R stuff into something M$ Ruffice can understand. And they're even working on a Word link if I got it right. Cheers Joris On Fri, May 7, 2010 at 12:24 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: chrish...@psyctc.org wrote: I've changed the subject line a bit here as Max is asking such a fundamental question. Max Kuhn sent the following at 01/05/2010 19:22: Chris, ... Why is it R Core's job to fulfill your wants and desires? I have a hard time thinking that very busy people would spend extra time doing something that they may or may not have a direct need for. Write it yourself or get a group of people together to do it. That what we did with odfWeave (for better or worse). If the task is beyond what you feel you can do, fund it. Ouch. OK. I'm hugely grateful for your work on odfWeave Max and sorry that Open Office isn't a solution for me at the moment. However, I don't think I'm being unreasonable or selfish. 1) Certainbly it's not R core's job to fulfil my wants and desires and they will have ways to discuss what would strengthen R for lots of us. Clearly I can submit a wishlist item to the R bugzilla and I should but that's very particulate: how can the team find out of wishes are common or would help increase use of R? There are files of key R core team members' wish lists on the R site but almost none relate in any way to output and some appear to be years old. I've worked with R (about 14 years I think) and as I look particularly at the recent release notes, I see a lot of work went into changing the help system which is one sort of output from R and a huge amount of work went into transitions in the object orientation (S3 to S4). I think that what I am suggesting is about a core issue of seeing a set of object properties for numeric output as including insertion of tabs, ideally as providing flexible presenting and viewing of all matrices, data frames and lists, and, some day, cross linkage of graphics into output. Ideally, as with the capacity of R to export its graphics in a number of formats, I'd love to see this capitalising on the work you have done for ODF and others have done for TeX etc. These strike me as central object handling issues, not things that should for ever be offloaded to the libraries/packages. I don't think that because something is important it needs to be in the part of R that R Core handles. The things that need to be there are things that can't be anywhere else. Things that can be elsewhere should be elsewhere, because the more that is in base R, the more time R Core spends on maintenance, and the less time on development of base R or on the other things we do (e.g. the things our employers pay us to do). We don't always follow this rule: in some cases, things that could be elsewhere are in base R because an R Core member doesn't mind taking on the maintenance, and it is easier to put them in base R than to create a new package for them. (Sweave is an example of this; there has been talk of moving it out of the base, but that hasn't happened yet.) But I don't think any members of R Core use any of those word processors called MS Word, and I don't see any need for core support for producing output for them. R already produces structured objects with all the semantics of XML objects (though it doesn't use that format to store them); it is simply a matter of deciding what format you'd like things to be displayed in, and then figuring out how to produce something in that format in a way that MS Word will understand. The first task is definitely something within the range of an R user. Getting it into some version of .doc or .docx or whatever is not at all easy, but it really has very little to do with R. It would make more sense to ask Microsoft to handle that part than it makes to ask R Core to do it. Duncan Murdoch 2) Do it myself: I wish! I'm a terrible programmer and work 50-70 hoursa week in my main jobs (I'm so outspoken here at the moment partly because I'm off work post-op.) I'm quite a good psychotherapist and capable of working in several different modes of psychotherapy and with individuals, couples, groups and families and I'm a fairly competent researcher and clinical director. I wish I'd been born or learned to be a better programmer as I wish I'd been more musical and able to
Re: [R] What is the best way to have R output tables in an MS
Let me see. I open a Word document and type, Dear Dr.Harrell, I open a new LaTeX document and type something like: \documentclass[10pt,a4paper]{letter} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \address{your name and address} \signature{your signature} \begin{document} \begin{letter}{name and address of the recipient} \opening{saying hello} Dear Dr Harrell, For a manager or secretary who is panicky at the thought of using a computer and who thinks of it as a glorified typewriter, which one wins? I think it was the initial investment in learning how to use the software. A simple WYSIWYG interface is learnable (is this a word?) in a few moments even if it may lead to some horrible results later. LaTex looks incredibly complicated to someone used to a fountain pen and an IBM Selectric typewriter (which was the high tec way of producing most documents in late 1960s and 1970s. Heck,when I learned to type we didn't even have electric typewriters! --- On Thu, 5/6/10, Frank E Harrell Jr f.harr...@vanderbilt.edu wrote: From: Frank E Harrell Jr f.harr...@vanderbilt.edu Subject: Re: [R] What is the best way to have R output tables in an MS To: r-help@r-project.org Received: Thursday, May 6, 2010, 7:44 PM Ted I can't resist offering my $.02, which is that I'm puzzled why LaTeX, being free, flexible, and powerful, is used only by millions of people and not tens of millions. du Frank On 05/06/2010 03:07 PM, (Ted Harding) wrote: Replying to Chris's latest message for the sake of preserving the thread, but deleting all of it to save space. Except: I had sympathy with Chris's original query, on the grounds that it was a good enquiry in principle, essentially pokinting towards the problem of incorporating R's formatted output (be it tables, graphics, ... ) into document-preparation software, whether it be noddy WYSIWYG like Word, or more sophisticated typesetting software such as TeX, the Adobe stable and other DTP software, or even the ancient UNIX troff dinosaur (re-evolved as GNU groff,but stil roaming the plains and consuming tough typesetting for breakfast just as its ancestor did). Given what he said in his latest message, I now have even more sympathy. It's not about begging in the streets for someone to charitably do the job for him! It's a job that could be a service to many, and if it attracts enough enthusiasm from enough of those who know how to do it then they will willingly plunge in. That's how Free Software works. The issue is about the enough enthusiasm and the enough of those who know. Many (possibly almost all) of the people who have developed R are mainly working with TeX/LaTex. R clearly has a well-developed interface to that language. But there are many people (of whom Chris has raised his head) who have needs or preferences for other software of whom some (as Chris spelled out) may totally lack support for R and LaTex, etc., from their organisations. I've pondered such issues many times myself, being one of the old nomadic troff-herders and still herding the groffs. My routine approach is as Chris described: grab the output from R (be it mouse-copied off-screen, from a saved file, or for graphics from a file of the coordinates of the graphical objects, or an EPS file), plant this into a groff document, and wrap it in formatting tags so that it comes out nicely. A bit time consuming, but since it's fairly straightforward in a markup language like g/troff, not so very time-consuming; and I dare say the same would be true for TeX/LaTex if Sweave Co did not exist. However, I would hate to have to do it for Word and the like! I bet that *is* time consuming. All of which is leading on to a suggestion that has been lurking in my mind for a while. How about an R device called xml? This would implement the XML extensible markup language which is basically capable of encapsulating any formatted material. The existing R devices seem to be confined to graphical output. XML can in principle cope with anything. Naturally, its function would be to save to file, not display on screen. I believe that Word (and maybe other MS Office software) can import XML. I know that XML can be converted to g/troff input (I've done it). It can no doubt be converted to TeX/LateX input. I'm not familiar enough with other document software to comment Then we would have a universal language for formatted R output, suitable for importing formatted R output into document preparation software. One would not need the full functionality of XML. Up to a point (I'm far from being an XML guru) I'd be prepared to assist with this, and in particular to test it out with groff. Any comments? Might there be a better suggestion than XML? Ted.
Re: [R] Removing points
?subset --- On Wed, 5/12/10, Blue.Egg avonpfe...@gmail.com wrote: From: Blue.Egg avonpfe...@gmail.com Subject: [R] Removing points To: r-help@r-project.org Received: Wednesday, May 12, 2010, 8:33 AM I have a some data, and imagine a column of how many parasitic eggs found in the stool of some children some of the children we do not have this data so we put -1 in stead. How can you remove the people with -1, to calculate means and do box plots. Thank you! -- View this message in context: http://r.789695.n4.nabble.com/Removing-points-tp2195945p2195945.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] Loading Intraday Time Series Data
Hi Steve, I think what you want to do is get a unique time-date from the first two columns. Try something like this: (changing the file name obviously. mydate should give you a time and date format that you can add to the existing data.frame. mydata - read.table(C:/rdata/dates.junk.csv, header=TRUE, sep=,, colClasses=c(character,character, numeric , numeric, numeric, numeric, numeric, numeric)) df1 - paste(mydata[,1], , mydata[,2]) mydates - strptime(df1, %d/%m/%Y %H%M) --- On Sun, 5/16/10, Steve Johns steve.jo...@verizon.net wrote: From: Steve Johns steve.jo...@verizon.net Subject: [R] Loading Intraday Time Series Data To: r-help@r-project.org Received: Sunday, May 16, 2010, 7:22 AM Hi, I am trying to load a data file that looks like this: |Date,Time,Open,High,Low,Close,Up,Down 05/02/2001,0030,421.20,421.20,421.20,421.20,11,0 05/02/2001,0130,421.20,421.40,421.20,421.40,7,0 05/02/2001,0200,421.30,421.30,421.30,421.30,0,5 05/02/2001,0230,421.60,421.60,421.50,421.50,26,1| etc. into an R timeseries or ts object. The key point is that both the date and time need to become part of the index. With zoo, this line will load the data: z - read.zoo(foo_hs.csv, format = %m/%d/%Y, sep=,, header = TRUE ) but the Time does not become part of the index this way. This means the index is non-unique, and that is not the goal. Could someone kindly show me a way, using R itself, to deal with the separate Date and Time columns so as to properly combine them into the index for the timeseries? Thanks! __ 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-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] Function that is giving me a headache- any help appreciated (automatic read )
I don't think you can do this precipitation!=NA) have a look at ?is.na --- On Tue, 5/18/10, stephen sefick ssef...@gmail.com wrote: From: stephen sefick ssef...@gmail.com Subject: [R] Function that is giving me a headache- any help appreciated (automatic read ) To: r-help@r-project.org Received: Tuesday, May 18, 2010, 12:38 PM note: whole function is below- I am sure I am doing something silly. when I use it like USGS(input=precipitation) it is choking on the precip.1 - subset(DF, precipitation!=NA) b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum) DF.precip - precip.1 DF.precip$precipitation - b$.data part, but runs fine outside of the function: days=7 input=precipitation require(chron) require(gsubfn) require(ggplot2) require(plyr) #021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS) #02102908 is the Flat Creek Gauge (ftbrfcms) #02133500 is the Drowning Creek (ftbrbmcm) #02341800 is the Upatoi Creek Near Columbus (ftbn) #02342500 is the Uchee Creek Near Fort Mitchell (ftbn) #02203000 is the Canoochee River Near Claxton (ftst) #02196690 is the Horse Creek Gauge at Clearwater, S.C. a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=; b - site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690 z - paste(a, days, b, sep=) L - readLines(z) #look for the data with USGS in front of it (this take advantage of #the agency column) L.USGS - grep(^USGS, L, value = TRUE) DF - read.table(textConnection(L.USGS), fill = TRUE) colnames(DF) - c(agency, gauge, date, time, time_zone, gauge_height, discharge, precipitation) pat - ^# +USGS +([0-9]+) +(.*) L.DD - grep(pat, L, value = TRUE) library(gsubfn) DD - strapply(L.DD, pat, c, simplify = rbind) DDdf - data.frame(gauge = as.numeric(DD[,1]), gauge_name = DD[,2]) both - merge(DF, DDdf, by = gauge, all.x = TRUE) dts - as.character(both[,date]) tms - as.character(both[,time]) date_time - as.chron(paste(dts, tms), %Y-%m-%d %H:%M) DF - data.frame(Date=as.POSIXct(date_time), both) #change precip to numeric DF[,precipitation] - as.numeric(as.character(DF[,precipitation])) precip.1 - subset(DF, precipitation!=NA) b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum) DF.precip - precip.1 DF.precip$precipitation - b$.data #discharge if(input==data){ return(DF) }else{ qplot(Date, discharge, data=DF, geom=line, ylab=Date)+facet_wrap(~gauge_name, scales=free_y)+coord_trans(y=log10)} if(input==precipitation){ #precipitation qplot(Date, precipitation, data=DF.precip, geom=line)+facet_wrap(~gauge_name, scales=free_y) }else{ qplot(Date, discharge, data=DF, geom=line, ylab=Date)+facet_wrap(~gauge_name, scales=free_y)+coord_trans(y=log10)} below is the whole function: USGS - function(input=discharge, days=7){ require(chron) require(gsubfn) require(ggplot2) require(plyr) #021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS) #02102908 is the Flat Creek Gauge (ftbrfcms) #02133500 is the Drowning Creek (ftbrbmcm) #02341800 is the Upatoi Creek Near Columbus (ftbn) #02342500 is the Uchee Creek Near Fort Mitchell (ftbn) #02203000 is the Canoochee River Near Claxton (ftst) #02196690 is the Horse Creek Gauge at Clearwater, S.C. a - http://waterdata.usgs.gov/nwis/uv?format=rdbperiod=; b - site_no=021973269,02102908,02133500,02341800,02342500,02203000,02196690 z - paste(a, days, b, sep=) L - readLines(z) #look for the data with USGS in front of it (this take advantage of #the agency column) L.USGS - grep(^USGS, L, value = TRUE) DF - read.table(textConnection(L.USGS), fill = TRUE) colnames(DF) - c(agency, gauge, date, time, time_zone, gauge_height, discharge, precipitation) pat - ^# +USGS +([0-9]+) +(.*) L.DD - grep(pat, L, value = TRUE) library(gsubfn) DD - strapply(L.DD, pat, c, simplify = rbind) DDdf - data.frame(gauge = as.numeric(DD[,1]), gauge_name = DD[,2]) both - merge(DF, DDdf, by = gauge, all.x = TRUE) dts - as.character(both[,date]) tms - as.character(both[,time]) date_time - as.chron(paste(dts, tms), %Y-%m-%d %H:%M) DF - data.frame(Date=as.POSIXct(date_time), both) #change precip to numeric DF[,precipitation] - as.numeric(as.character(DF[,precipitation])) precip.1 - subset(DF, precipitation!=NA) b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum) DF.precip - precip.1 DF.precip$precipitation - b$.data #discharge if(input==data){ return(DF) }else{ qplot(Date, discharge, data=DF, geom=line, ylab=Date)+facet_wrap(~gauge_name, scales=free_y)+coord_trans(y=log10)} if(input==precipitation){ #precipitation qplot(Date, precipitation, data=DF.precip, geom=line)+facet_wrap(~gauge_name, scales=free_y) }else{ qplot(Date, discharge, data=DF, geom=line, ylab=Date)+facet_wrap(~gauge_name, scales=free_y)+coord_trans(y=log10)} } -- Stephen Sefick Let's not spend our time and resources thinking about
Re: [R] question about graph
This is not enough information to let us give a good example but perhaps ?lines or ?points might help? Example aa - 1:5 bb - 1:5 cc - c(1.5,2.5,3.5,4.2,4.4) plot(aa,bb) lines(aa,cc,col='red') points(aa,cc, col=blue) --- On Sat, 5/22/10, khaz...@ceremade.dauphine.fr khaz...@ceremade.dauphine.fr wrote: From: khaz...@ceremade.dauphine.fr khaz...@ceremade.dauphine.fr Subject: [R] question about graph To: r-help@r-project.org Received: Saturday, May 22, 2010, 5:53 AM Hi, I have two different sets of data from two different populations. I want to plot these samples (for example: Line graph) by just one graph. could you please help me? Thanks Khazaei __ 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-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] website address for the pseuso-XLS files
The Prostatic_Neoplasm-miRNAs.DiseaseTargets.xls file seems to be an HTML table and seems to open with no problem in OpenOffice.org Writer/Web. OOo 3.2.0 when opened from within OOOo. At a guess it is some collection of PubMed references. I don't know if that's any use but it's a nice table in OOo Writer. It seems to bre another example of the misuse of the xls extension. Column names and first line of data below Disease NameMicroRNA Name StemLoopName miR_Chr.Pubmed ID Prostatic Neoplasms hsa-miR-222 hsa-mir-222X 19351827 --- On Tue, 5/25/10, mau...@alice.it mau...@alice.it wrote: From: mau...@alice.it mau...@alice.it Subject: [R] website address for the pseuso-XLS files To: ted.hard...@manchester.ac.uk Cc: r-h...@stat.math.ethz.ch Received: Tuesday, May 25, 2010, 8:24 AM http://gigamail.rossoalice.alice.it/messages/readMessageFrameset.aspx?DeliveryID=ba40cf18-29db-4404-a3ce-af26f760ecf9 Please, paste the website address above shown in your web browser address field. Make sure the whole string is pasted with no space or any other character. Telecom couldn't generate more clumsy website addresses Sorry for that. Thank you in advance, Maura tutti i telefonini TIM! [[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-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] write.csv fails with $ operator invalid for atomic
Where does the table come from? write.csv(t, file = t.csv) looks like it would work --- On Tue, 12/1/09, ggraves ggwra...@sfwmd.gov wrote: From: ggraves ggra...@sfwmd.gov Subject: [R] write.csv fails with $ operator invalid for atomic To: r-help@r-project.org Received: Tuesday, December 1, 2009, 1:36 PM I want to export a csv file so I can do other things with it. I issue this command to break down years as to whether it was windy or not: t-tapply(TURB,list(year,windy),mean,na.rm=T) which results in: t no yes 1990 21.516514 39.86400 1991 13.580435 28.87500 1992 12.171429 22.93913 1993 21.550893 26.41200 1994 12.003913 40.76928 1995 14.707917 35.39057 1996 22.041765 44.54927 1997 17.577625 31.60761 1998 26.283978 34.36190 1999 14.597922 43.85804 2000 30.805139 63.06042 2001 23.204545 36.64634 2002 21.062791 32.86696 2003 14.487111 33.68727 2004 36.294595 73.38125 2005 49.089583 114.28333 2006 44.941667 89.37917 2007 57.456667 70.00435 2008 52.251163 89.83864 2009 24.212821 37.49375 when I issue this command write.csv(t$table, file = t.csv) I get the error ERROR $ operator is invalid for atomic vectors ?? -- View this message in context: http://n4.nabble.com/write-csv-fails-with-operator-invalid-for-atomic-tp932414p932414.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] write.csv and header
Just write the headers once and append as many times as needed? You can append as many datasets as you want. --- On Wed, 12/16/09, rkevinbur...@charter.net rkevinbur...@charter.net wrote: From: rkevinbur...@charter.net rkevinbur...@charter.net Subject: Re: [R] write.csv and header To: Gustaf Rydevik gustaf.ryde...@gmail.com, Patrick Connolly p_conno...@slingshot.co.nz Cc: r-help@r-project.org Received: Wednesday, December 16, 2009, 3:05 PM I have a small request regarding this append feature. As it is now if the data is appended to the file so is the header. I would like to have the header only entered once and appends just append the data. Doable? Kevin Patrick Connolly p_conno...@slingshot.co.nz wrote: On Tue, 15-Dec-2009 at 01:55PM +0100, Gustaf Rydevik wrote: | Hi, | | ?write.table and the argument append should be of help. | example: | | sink(test.csv) | cat(-) | cat(\n) | cat(This is \n a test of header) | cat(\n) | cat(-) | cat(\n) | sink() | Or, instead of the use of sink() and cat(), one could use the write() function, also using the append = TRUE argument. | write.table(matrix(rnorm(100),nrow=10),file=test.csv,append=TRUE,sep=,) | | | regards, | Gustaf | | | -- | Gustaf Rydevik, M.Sci. | tel: +46(0)703 051 451 | address:Essingetorget 40,112 66 Stockholm, SE | skype:gustaf_rydevik | | [[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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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-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. __ Be smarter than spam. See how smart SpamGuard is at giving ju __ 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] How to print to file?
?sink perhaps? --- On Sat, 12/19/09, Peng Yu pengyu...@gmail.com wrote: From: Peng Yu pengyu...@gmail.com Subject: [R] How to print to file? To: r-h...@stat.math.ethz.ch Received: Saturday, December 19, 2009, 7:12 AM I don't find a function to print a string to file. Would somebody let me know what function I should use? __ 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-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] Two Easy questions
?text for the first question ? plot(xx$Eight, xx$Punctuation) text(xx$Eight, xx$Punctuation, xx$Name) You will need to play around with the values for Punctuation to get the names to be beside the dots --- On Thu, 12/24/09, Jose Narillos de Santos narillosdesan...@gmail.com wrote: From: Jose Narillos de Santos narillosdesan...@gmail.com Subject: [R] Two Easy questions To: r-help@r-project.org Received: Thursday, December 24, 2009, 9:27 AM Sorry all for these two easy questions: First, I have a matrix with trhee columns: A= Name Eight Puntuation Pepe 1,85 10 Paco 1,7 7 Pablo 1,82 6 I want to scatter the two columns (I could use pairs or other functions...) but the only doubt is that I cannot find the way to add in the associated intersection (the point scattered) the label Pepe Paco and so on...So next to point (1,8510) will appear Pepe. Imagine I can get it (if the points are closer and the associated names (labes) cross how can I modified them? If someone can send me a link to investigate will be perfect¡¡¡ Can anyone help me? Second, I have read that with R we can dowload directly stock market historical information from google or yahoo. Can anyone guide me how to do it or more easily where I can find information (a web link or something similar) Thanks for all¡¡¡ [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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. __ Looking for the perfect gift? Give the gift of Flickr! __ 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] Column naming issues using read.table
I'm not exactly an expert so this is not likely a good way to do it but if the actual variable names are constant across the files why not just read in the data and assign the names later? see skip in ?read.table. x - read.table(d:/junk1.txt, skip=2) should read in the data. You can clean up the file(s) for length, etc once you have read it/them in. Using your sample data I drop column one and only keep 2 of the three lines of data. xx - xx[1:2, -1] names(xx) -c(A, B,C,D,E, F) --- On Wed, 12/23/09, arthurbeer01 arthur_b...@hotmail.com wrote: From: arthurbeer01 arthur_b...@hotmail.com Subject: [R] Column naming issues using read.table To: r-help@r-project.org Received: Wednesday, December 23, 2009, 8:31 PM Hi, this is my first post so please be gentle. I quite new to R and using it for my biology degree. My problem is. Im trying to import data from a .csv file using the read.table command. The .csv file header starts on row 2 but is contained in column 1, i have 600 data files and for future ease would rather not edit each file seperatly. The data starts on row three and I only need the first 381 data points. The R error message using the code iv got so far is Error in read.table(file(s1-2c83.csv), header = FALSE, sep = ,, quote = , : more columns than column names The code I have so far is framename-read.table(file (s1-2c83.csv), header = FALSE, # FLASE indicates headers are not included in input file sep = ,, # must have , otherwise errors in table quote = , dec = ., row.names = 1, # must = 1 or extra column of row numbering is entered col.names = (Nr2sec,Cnt1X,Cnt1Y,Cnt2X,Cnt2Y,sec100,hour), as.is = FALSE, na.strings = NA, colClasses = NULL, nrows = 381, # rows to stop data.table recording (not input file row number!) skip = 2, # number of rows to skp before reading data from input file strip.white = FALSE, comment.char = ) write.csv(framename, file = s1-2c83-ok.csv) If I delete the line col.names, Iv manged to get the data read and saved to a new .csv file but cannot work out how to get the column headers renamed. The read.table (framename) displays the headers as v1,v2,v3 etc, this is what i cant change. Also it has the first column without a header (i think its the row number) which I dont want in the output file The read data file example s1-2c83.csv 1:Samplerate = 2 samps/sec 2: Nr Cnt1X Cnt1Y Cnt2X Cnt2Y sec100 hour 3: 1 53 84 43 2 22 12 4: 2 90 155 74 0 72 12 5: 3 90 155 74 0 121 12 Any help will be greatly appreciated after the 5hrs Iv spent already on this problem. Many thanks in advance Adam -- View this message in context: http://n4.nabble.com/Column-naming-issues-using-read-table-tp978241p978241.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Reading Input file
First of all there seems to be something wrong with your equation rate_name[i] = (paste(`rate', i, ‘.csv`, sep = ‘’)) Try this rate_name[i] - paste(rate,i,.csv, sep=) I am not --- On Sat, 12/26/09, Maithili Shiva maithili_sh...@yahoo.com wrote: From: Maithili Shiva maithili_sh...@yahoo.com Subject: Re: [R] Reading Input file To: Johannes Signer j.m.sig...@gmail.com Cc: r-help@r-project.org Received: Saturday, December 26, 2009, 8:09 AM Dear R helpers / Johannes Sir, Unfortunately it didn't work. I am getting following warning messages. 1: In neweate[i] = read.csv(rates[i]) : number of items to replace is not a multiple of replacement length. 2: similar message 3: similar message 4: similar message Let me be specific in my problem. I have three csv files as rate1.csv r1 r2 r3 r4 r5 r6 10.1 10.25 10.25 10.50 10.50 10.75 rate2.csv r1 r2 r3 r4 r5 r6 15.1 15.45 15.45 15.70 15.70 15.90 rate3.csv r1 r2 r3 r4 r5 r6 18.3 18.50 18.50 18.65 18.65 18.95 Normally I can read these files as newrate1 = read.csv('rate1.csv'') newrate2 = read.csv('rate2.csv') newrate3 = read.csv('rate3.csv') However, due to some other requirement first I have to define following R code n = 3 rate_name = NULL for (i in 1:n) rate_name[i] = (paste(`rate', i, ‘.csv`, sep = ‘’)) # rate_name gives rate1.csv rate2.csv ratë3.csv ### MY TASK I need to use the rate_names to read the actual rate1.csv, rate2.csv and rate3.csv files. When I use the following code newrate - list() for (i in 1:n) { newrate[i] = read.csv(rate_name[i]) } I get following warning messages 1: In newrate[i] = read.csv(rate_name[i]) : number of items to replace is not a multiple of replacement length 2: similar message 3: similar message ## APPROACH II PPP = matrix(data = rate_name, nrow = 1, ncol = 3, byrow = FALSE) X = matrix(data = NA, nrow = 3, ncol = 6, byrow = FALSE) for (j in 1:3) X = read.csv(PPP[1, j]) # X returns (i.e. only first record is taken) r1 r2 r3 r4 r5 r6 10.1 10.25 10.25 10.50 10.50 10.75 Please guide With regards Maithili --- On Sat, 26/12/09, Johannes Signer j.m.sig...@gmail.com wrote: From: Johannes Signer j.m.sig...@gmail.com Subject: Re: [R] Reading Input file To: Maithili Shiva maithili_sh...@yahoo.com Cc: r-help@r-project.org Date: Saturday, 26 December, 2009, 9:42 AM On Sat, Dec 26, 2009 at 10:21 AM, Maithili Shiva maithili_sh...@yahoo.com wrote: Dear R helpers I have some files in my say 'WORK' directory and the file names are say rate1.csv, rate2.csv, rate3.csv, rate4.csv Because of some other requirement, I need to run the following commands n = 4 rates = NULL for (i in 1:n) rates[i] = (paste(`rate', i, ‘.csv`, sep = ‘’)) # this gives me rate1.csv rate2.csv and so on #My problem is now I need to relate these file names with actual files and read these files # There are files rate1.csv, rate2.csv, rate3.csv, rate4.csv in my WORK directory. # If I individually define PPP = read.csv(‘rate[1]’) PPP # When I run PPP in R, it gives contents of the file rate1.csv i.e. I am able to read the required rate1 file. But if I run following commands, I get errors. newrate = NULL Maybe try: newrate - list() and leave everything else as it is. just an idea, for (i in 1:n) { newrate[i] = read.csv(rates[i]) } I need to read all these four files for my further analysis. Please guide. Regards Maithili The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. [[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. [[elided Yahoo spam]] [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
Re: [R] how to create a simple loop ?
An alternative approach (clumsy but probably not as clumsy as a loop) would be to create a sixth column as a factor and aggregate on that. Simple-minded example : === mydata - data.frame(matrix(rnorm(100),nrow=20)) mydata[,6] - c(rep(a,5),rep(b,20-10),rep(c,5)) aggregate(mydata[,5], by=list(mydata[,6]), mean) Set all the unwanted values to X and subset on that before calculating. --- On Sun, 12/27/09, Edouard Tallent tallen...@lycos.com wrote: From: Edouard Tallent tallen...@lycos.com Subject: [R] how to create a simple loop ? To: r-help@r-project.org Received: Sunday, December 27, 2009, 9:15 AM Hi everyone. And, Merry Xmas ! I have a 5-row matrix called “data”. There are headers. it look like this : Row 1 Row2 Row3 Row4 Row5 Line1 … … … … Line2 … … … … Line3 … … … … … Line 1838 … … … … I want to calculate several simple arithmetic means for Row5, that is from Line173 to Line193, from Line434 to Line455, from Line699 to Line724, from Line955 to Line977 A simple way is to individually compute these means. The first one (Line173 to Line193) is then obtained by : mean(data[173:193,5], na.rm = TRUE) That’s right ! But, I aim to automate this calculation by creating a loop. I tried many things, but I have been unsuccessful at using the ‘for’ loop function. Please, don’t explain things too hard as it is often the case that people wants to help but gets into too much sophistication. Someone can write that little code for this example ? Or suggest functions ? Thanks for your help. Cheers, Édouard. [[alternative(swapped) HTML version deleted]] This is MIME Epilogue -Inline Attachment Follows- __ 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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] refering to the 'boundaries' of a graph
I think what you are encountering is a standard R default. R, by default, adds 4% to the axes. I suspect that this is to avoid graphing points right on the x or x axis and thus obscuring them. Have a look at ?par xaxs for more information and how to change the default. --- On Mon, 12/28/09, Dean1 web13s...@yahoo.co.uk wrote: From: Dean1 web13s...@yahoo.co.uk Subject: [R] refering to the 'boundaries' of a graph To: r-help@r-project.org Received: Monday, December 28, 2009, 8:55 AM Please see this code for a demonstration of my problem... xlim - c(-1,5) plot(1:4, xlim=xlim) abline(v=xlim[1]) abline(v=xlim[2]) When I refer to xlim, it is not referring to the boundaries of the graphical region, it refers to the maximum and minimum xticks. My question is how can I refer to the x axis boundaries (and similarly y axis) of the graph? -- View this message in context: http://n4.nabble.com/refering-to-the-boundaries-of-a-graph-tp989790p989790.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Accessing member
Assuming the data set is called xx subset (xx, xx$V1==AB) or xx[1,] if you now AB is the first row of the data. --- On Mon, 12/28/09, Nick Torenvliet nick.torenvl...@gmail.com wrote: From: Nick Torenvliet nick.torenvl...@gmail.com Subject: [R] Accessing members To: r-help@r-project.org Received: Monday, December 28, 2009, 6:14 PM Consider the following fileLines V1 V2 V3 V4 V5 V6 V7 V8 1 AB 20091224 156.0 156.0 154.00 154.00 55 1198 2 AB.C 20091224 156.0 156.0 156.00 156.00 0 0 3 ABF10 20091224 156.0 156.0 156.00 156.00 55 444 4 ABH10 20091224 156.0 156.0 156.00 156.00 0 749 5 ABH11 20091224 157.2 157.2 157.20 157.20 0 0 6 ABH12 20091224 157.2 157.2 157.20 157.20 0 0 7 ABK10 20091224 157.2 157.2 157.20 157.20 0 5 8 ABK11 20091224 157.2 157.2 157.20 157.20 0 0 9 ABN10 20091224 157.2 157.2 157.20 157.20 0 0 10 ABN11 20091224 157.2 157.2 157.20 157.20 0 0 11 ABV10 20091224 157.2 157.2 157.20 157.20 0 0 12 ABV11 20091224 157.2 157.2 157.20 157.20 0 0 13 ABZ10 20091224 157.2 157.2 157.20 157.20 0 0 14 ABZ11 20091224 157.2 157.2 157.20 157.20 0 0 15 RS 20091224 395.0 395.0 381.42 381.42 12918 100618 16 RS.C 20091224 395.0 399.1 395.00 398.70 1680 0 17 RSF10 20091224 395.0 399.1 395.00 398.70 2277 3081 18 RSF11 20091224 420.3 420.3 420.30 420.30 50 203 19 RSF12 20091224 415.5 415.5 415.50 415.50 0 0 20 RSH10 20091224 401.1 403.9 399.50 403.60 9925 79548 21 RSH11 20091224 419.2 419.2 419.20 419.20 0 193 22 RSK10 20091224 406.9 409.9 406.40 409.90 264 5769 23 RSK11 20091224 415.5 415.5 415.50 415.50 0 0 24 RSN10 20091224 414.7 415.2 410.00 415.20 189 6391 25 RSN11 20091224 415.5 415.5 415.50 415.50 0 2 26 RSX10 20091224 414.9 417.9 413.00 417.30 213 5431 27 RSX11 20091224 415.5 415.5 415.50 415.50 0 0 28 WF 20091224 363.0 363.0 363.00 363.00 0 0 29 WW 20091224 152.0 152.0 152.00 152.00 0 0 attributes (fileLines) $names [1] V1 V2 V3 V4 V5 V6 V7 V8 $class [1] data.frame $row.names [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 fileLines[1,2] [1] 20091224 As expected! fileLines[1,3] [1] 156 As expected! fileLines[1,1] [1] AB 29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10 ABN11 ... WW Doh! How do I access the AB element directly? Nick [[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. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Newbie needs to count elements in a row
Could you just transpose the matrix? Otherwise you can write a simple function that should work. Try this -(mat1 - matrix(c(1, 2, 3, NA, 10, 2, NA, 8, 9, NA),nrow=2)) gl - function(x)length(x[!is.na(x)] apply(mat1, 1, gl) == -- On Tue, 12/29/09, Verena Weber verenawe...@gmx.de wrote: From: Verena Weber verenawe...@gmx.de Subject: [R] Newbie needs to count elements in a row To: r-help@r-project.org Received: Tuesday, December 29, 2009, 8:49 AM Hi, I have a n*m matrix and would like to count the number of elements not equal to NA in a ROW. e.g. x 1 2 3 NA 10 y 2 NA 8 9 NA Which function can I use to obtain 4 for row x and 3 for row y? Could you help me? I found some functions for columns but not for rows... [[elided Yahoo spam]] __ 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-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] iterating over a data frame the R way?
Uh what do you want to do to it/them? Here are a couple of R-type commands on a data.frame. mydata - data.frame(vec1 = seq(19,109, by=10), vec2 =seq(30,120, by=10)) mydata[,1]+mydata[,2] apply(mydata, 2, mean) --- On Thu, 12/31/09, donahc...@me.com donahc...@me.com wrote: From: donahc...@me.com donahc...@me.com Subject: [R] iterating over a data frame the R way? To: r-help@r-project.org Received: Thursday, December 31, 2009, 2:44 PM Hi, I have a data frame that was create by issuing a select against my sqlite database. I want to get each row from the data frame and use the each of the column values. The data frame looks like this: start_time end_time 09:30:00 10:00:00 10:00:01 10:30:00 etc Can a point me to a tutorial/example of doing this? I the other programming languages I'm familiar with I would just loop over the frame and access the elements, but I believe that's not the R way and can't find examples of doing this. Thanks! __ 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. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ 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] how to plot multiple density functions in one graph
?lines ?points --- On Mon, 1/4/10, John Westbury jrwestb...@gmail.com wrote: From: John Westbury jrwestb...@gmail.com Subject: [R] how to plot multiple density functions in one graph To: r-help@r-project.org Received: Monday, January 4, 2010, 3:13 PM Hello, I am new to R and have two easy questions. How can you plot multiple density functions in one graph? I have five beta densities that I would like to plot in one graph. I und ParetoAdventures of Dunsterforceerstand how to plot one beta density as a line: plot (x,(dbeta(x,shape1=,shape2=,), type =l) Does the distribution need to be added to R with an additional package? Maybe. Have look at http://finzi.psych.upenn.edu/R/library/PtProcess/html/dpareto.html for one possible source. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ 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] Data Frame Transpose
Well, if nothing else, you have missing comma. :) x01=y[,1]), x01=y[,1], x02=y[,2], x03=y[,3] -- fn - function(x) { y - t(x[,2]) data.frame( Croptype=x[1,1], Period =x[1,2], name=colnames(x)[2], x01=y[,1])x01=y[,1], x02=y[,2], x03=y[,3] } ---Problem here m - do.call( rbind, lapply(split(m,list(m$Period,m$Croptype)),fn) ) m - m[order(m$Period,m$Croptype),] I think I having a problem in here: x01=y[,1])x01=y[,1], x02=y[,2], x03=y[,3]. how to address with my data. I have variable Period. based on this http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg09264.html P_ID Croptype Period Ini_Age Area_Cut 83 SORI 1 31 528.2465512 84 SORI 1 32 74.55179899 85 SORI 1 33 72.45778618 86 SORI 1 34 139.5272947 82 SORI 2 28 1.711642933 83 SORI 2 29 2.50071 84 SORI 2 30 432.5139327 93 ORM 2 35 316.8422545 62 OTRM 3 30 64.60526438 82 SORI 3 27 26.93674606 3 SORM 3 35 223.3658345 82 SORI 4 26 2.50071 4 SORM 4 34 1008.643 5 OTRI 5 25 32.42603214 5 OTRM 5 29 65.9031344 5 SORM 5 32 223.1489321 5 SORM 5 33 72.59203041 5 SORM 5 35 222.8402746 6 OTRI 6 22 2.49851 6 OTRI 6 23 3.374626509 6 OTRI 6 24 96.13462257 6 OTRM 6 26 830.7463641 6 OTRM 6 27 731.6228643 6 OTRM 6 28 16.3519762 7 OTRM 7 26 1636.5693 8 OTRM 8 26 553.0050146 9 OTRM 9 26 894.414033 10 OTRM 10 24 38.72597099 10 OTRM 10 25 308.6452707 10 OTRM 10 26 786.1761969 10 SORM 10 31 235.8360136 To this. P_ID Croptype P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 83 SORI 31 84 SORI 32 85 SORI 33 86 SORI 34 82 SORI 28 83 SORI 29 84 SORI 30 93 SORM 35 62 OTRM 30 82 SORI 27 3 SORM 35 82 SORI 26 4 SORM 34 5 OTRI 25 5 OTRM 29 5 SORM 32 5 SORM 33 5 SORM 35 6 OTRI 22 6 OTRI 23 6 OTRI 24 6 OTRM 26 6 OTRM 27 6 OTRM 28 7 OTRM 26 8 OTRM 26 9 OTRM Thanks in advance. Noli __ 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. __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. __ 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] Bar plots with stacked and grouped (juxtaposed) bars together
I have the feeling that you can do this with ggplot2 but why? You are likely to be much better off using a dotchart. ?dotchart --- On Mon, 1/4/10, Elmer Wix elmer.cabekaziruronometu@gmail.com wrote: From: Elmer Wix elmer.cabekaziruronometu@gmail.com Subject: [R] Bar plots with stacked and grouped (juxtaposed) bars together To: r-help@r-project.org Received: Monday, January 4, 2010, 10:00 PM Using barplot, I can generate stacked bars if I pass beside=FALSE. I can generate grouped (juxtaposed) bars if I pass beside=TRUE. How can I generate stacked and grouped bars together? __ 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-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] (no subject)
It looks like superpose.eb is someone's function and not in a package. https://stat.ethz.ch/pipermail/r-help/2002-November/027299.html --- On Thu, 6/3/10, Rosario Garcia Gil m.rosario.gar...@genfys.slu.se wrote: From: Rosario Garcia Gil m.rosario.gar...@genfys.slu.se Subject: [R] (no subject) To: r-help@r-project.org r-help@r-project.org Received: Thursday, June 3, 2010, 11:33 AM Dear R users, I am trying to draw error bars in a bar plot, I use this code (tried many others which did not work): install.packages() library(gplots) y -c(39.02, 46.42) se - c(7.57,7.35) plot - barplot(y, beside=TRUE, col=0, ylim=c(0,47), axis.lty=1, main=far-red, xlab=latitude, names.arg=c(56N, 68N)) superpose.eb(plot, y, se, col=orange, lwd=2) Then I get an error saying that it cannot find the superpose.eb function. Why? Isn´t under gplots? Thanks Rosario __ 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-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] import text file into R
What does the text look like? --- On Thu, 6/3/10, dhanush dhana...@gmail.com wrote: From: dhanush dhana...@gmail.com Subject: [R] import text file into R To: r-help@r-project.org Received: Thursday, June 3, 2010, 7:32 AM can anyone tell me how to import a text file in R? the text file I want to import is a large file, about 800MB in size. Thanks in advance. I tried using the following data-read.table(file,header=T,sep=\t) -- View this message in context: http://r.789695.n4.nabble.com/import-text-file-into-R-tp2241525p2241525.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] horizontal and vertical line with arrow in a plot
# A very quick example of how to draw an arrow on a graph. plot(1:10) text(2,5, Point 5 , cex=.8) arrows(3,5, 4.5, 5) --- On Thu, 6/3/10, Roslina Zakaria zrosl...@yahoo.com wrote: From: Roslina Zakaria zrosl...@yahoo.com Subject: [R] horizontal and vertical line with arrow in a plot To: r-help@r-project.org Received: Thursday, June 3, 2010, 11:34 PM Hi r-users, I would like to add a plot of vertical line segment with arrow from (77,.6) to (77,0) and also a horizontal line segment with arrow from (0,0.6) to (77,.6) . So far this is what I have: plot(sq, cdf, type=l, lwd=4,col=blue,xaxs=i,yaxs=i, xlab= Rainfall (mm), ylab= Random no., main=Random number and rainfall totals (mm)) abline(v=77,h=0.6,col=2,lwd=2,lty=3) text(120,0.63, r = 0.6) text(120,0.05, x = 70) I also tried to use the 'diagram' and 'shape' package but not really sure how to use them. Thank you for all the help given. [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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-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] how to use 'points' function to plot two curves with errbar
The first thing we need to know is what errbar are you using? There are at least two, on in the Hmisc package and one in sfsmisc. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,reproducible code. I'm not sure what you are trying to do here but perhaps looking at new in ?par might hrlp you. Example: plot(1:10, col=red) par(new=TRUE) plot(10:1, col=blue) --- On Sat, 6/5/10, Yogesh Tiwari yogesh@googlemail.com wrote: From: Yogesh Tiwari yogesh@googlemail.com Subject: [R] how to use 'points' function to plot two curves with errbar To: r-h...@stat.math.ethz.ch Received: Saturday, June 5, 2010, 10:06 AM Dear R Users, I am using R on windows. how to use 'points' function to plot two curves with errbar I am doing like: x.val - as.integer(names(co2mean)) errbar(x.val, co2mean, co2mean + co2sd, co2mean - co2sd, xaxt='n', col=1, xlab=NA,ylab=NA)# obs error bar lines(x.val, co2mean, col=1, lwd=2) errbar(x.val, co2tm3.month.mean, co2tm3.month.mean + co2sd.tm3, co2tm3.month.mean - co2sd.tm3, xaxt='n', col=2, xlab=NA,ylab=NA)# model error bar lines(x.val, co2tm3.month.mean, col=2, lwd=2) Above code replaces first error bar and its line with second. Kindly help, how to use 'points' function here so both above can get over ploted Thanks, Regards, Yogesh PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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] variation
?var perhaps --- On Sat, 6/5/10, Adel ESSAFI adel.s...@imag.fr wrote: From: Adel ESSAFI adel.s...@imag.fr Subject: Re: [R] variation To: r-help@r-project.org Received: Saturday, June 5, 2010, 7:57 AM 2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ 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. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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-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] Matrix to Vector
m-matrix(seq(1,48),nrow=6,byrow=T) as.vector(t(m)) gives me the correct result. Any chance you may have already transformed m ? --- On Sat, 6/5/10, steven mosher mosherste...@gmail.com wrote: From: steven mosher mosherste...@gmail.com Subject: Re: [R] Matrix to Vector To: Henrique Dallazuanna www...@gmail.com Cc: r-help@r-project.org Received: Saturday, June 5, 2010, 2:44 PM as.vector(t(m)) [1] 1 9 17 25 33 41 2 10 18 26 34 42 3 11 19 27 35 43 4 12 20 28 36 44 5 13 21 29 37 45 6 14 22 30 38 46 7 15 23 31 39 47 8 16 24 [46] 32 40 48 the result I want is this: [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 [46] 46 47 48 On Sat, Jun 5, 2010 at 11:17 AM, Henrique Dallazuanna www...@gmail.comwrote: Try this: as.vector(t(m)) On Sat, Jun 5, 2010 at 3:12 PM, steven mosher mosherste...@gmail.comwrote: Given a matrix of m*n, I want to reorder it as a vector, using a row major transpose. so: m-matrix(seq(1,48),nrow=6,byrow=T) m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 2 3 4 5 6 7 8 [2,] 9 10 11 12 13 14 15 16 [3,] 17 18 19 20 21 22 23 24 [4,] 25 26 27 28 29 30 31 32 [5,] 33 34 35 36 37 38 39 40 [6,] 41 42 43 44 45 46 47 48 I want to reorder this as a vector copying by row, so that the final vector has elements ordered thusly: row 1, column 1:N (m[1,1:n]) maps to row 1-n, and m[2,1:n] maps to row[n+1:2n] ... this obviously is not a solution: as the inherent column major storage paradigm of a matrix defeats the approach. dim(m)-c(48,1) m [,1] [1,] 1 [2,] 9 [3,] 17 [4,] 25 [5,] 33 [6,] 41 [7,] 2 [8,] 10 [9,] 18 [10,] 26 [11,] 34 [12,] 42 [13,] 3 [14,] 11 [15,] 19 [16,] 27 [17,] 35 [18,] 43 [19,] 4 [20,] 12 [21,] 20 [22,] 28 [23,] 36 [24,] 44 [25,] 5 [26,] 13 [27,] 21 [28,] 29 [29,] 37 [30,] 45 [31,] 6 [32,] 14 [33,] 22 [34,] 30 [35,] 38 [36,] 46 [37,] 7 [38,] 15 [39,] 23 [40,] 31 [41,] 39 [42,] 47 [43,] 8 [44,] 16 [45,] 24 [46,] 32 [47,] 40 [48,] 48 I already have a version that loops through the data ( this is actually a portion of a data frame ) to reorder this into a vector, but I was hoping there was an elegant way [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] -Inline Attachment Follows- __ 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-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.