Re: [R] is it possible to combine multiple barplots?
Thank you for the helpful reply! I am relatively new to R (the software and the community) and was not aware of the example galler. Now I am. The example you found looks very close to what I am trying to do and I should be able to modify it. Best - P On Tue, Jun 9, 2009 at 4:45 PM, Titus von der Malsburgmalsb...@gmail.com wrote: On Tue, Jun 09, 2009 at 04:39:29PM +0200, Titus von der Malsburg wrote: is there a way to plot both of them in one plot, so that the bars for value 1 (dataA: 3, dataB: 5) would appear side by side, followed by the bars for value 2 etc.? Oh, I see you want something different. I should've read your message more closely. I found this example in the gallery: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=54 Maybe it's close enough to what you want to do. Titus -- Sharing Nicely at www.bokaap.net __ 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] is it possible to combine multiple barplots?
i am working with two sets of likert scale type (4 distinct values) data: dataA - rep(1:4, c(3,2,2,4)) dataB - rep(1:4, c(5,4,3,2)) i can now (bar)plot both of these separately and compare the distributions. plot(table(dataA), type='h') plot(table(dataB), type='h') is there a way to plot both of them in one plot, so that the bars for value 1 (dataA: 3, dataB: 5) would appear side by side, followed by the bars for value 2 etc.? thanks! best - P __ 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 and then executing command strings
Greg: Thanks for this concise explanation! I will have a look at the fortunes you mention. Best - P On Fri, May 15, 2009 at 7:36 PM, Greg Snow greg.s...@imail.org wrote: The arrow - is used to assign a value to a variable, the equals sign = is used to specify the value for a function argument. Recent versions of R allow = to be used for - at the top level and certain circumstances which some people find more convenient, but can also lead to confusion (purists always keep them separate). The code: parse( text - paste( ... Will take the results of paste, save them in a variable named text, then pass a copy to the first argument of parse, which is file, not text, so parse will just get confused (looking for a file named what your code is). The code: parse( text = paste( ... Will take the results of paste and pass them to the parse function as the text argument. But having said that, you should refer to fortune(106) (type that after loading the fortunes package) and possibly fortune(181). There are probably better ways to do what you want, Romain's second example is one way. -- 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 Philipp Schmidt Sent: Friday, May 15, 2009 8:35 AM To: Romain Francois Cc: r-help@r-project.org Subject: Re: [R] creating and then executing command strings On Fri, May 15, 2009 at 3:38 PM, Romain Francois romain.franc...@dbmail.com wrote: Hi, You can either parse and eval the string you are making, as in: eval( parse( text = paste(avg_,colname, - 0;, sep='') ) ) Or you can do something like this: df[[ paste( avg_, colname, sep = ) ]] - 0 Thanks you so much! I used the first version and it worked. What puzzles me, is that I am not able to use - instead of = (my R book says the two can be exchanged) or break the command into different parts and execute them one after another. I get various error messages when I try: eval( parse( text - paste(avg_,colname, - 0;, sep='') ) ) or text = paste(avg_,colname, - 0;, sep='') parse(text) eval(parse(text)) Anyway, thanks a lot - you greatly improved the likelihood of me not working on the weekend! Best - P __ 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. -- Sharing Nicely at www.bokaap.net __ 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] creating and then executing command strings
Hi: I very recently started experimenting with R and am occasionally running into very basic problems that I can't seem to solve. If there is an R-newbies forum that is more appropriate for these kinds of questions, please direct me to it. I'd like to automatically add vectors to a dataframe. I am able to build command strings that would do what I want, but R is not executing them. A simplified example: # Add three vectors called avg_col1, avg_col2, avg_col3 to dataframe df for(colname in c(col1, col2, col3)){ print(paste(df$avg_,colname, - 0;, sep='')) # Just using this to make sure the command is correct paste(avg_,colname, - 0;, sep='') # Does nothing } Output: [1] df$avg_col1 - 0; [1] df$avg_col2 - 0; [1] df$avg_col3 - 0; Thanks for your help! Best - P __ 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 and then executing command strings
On Fri, May 15, 2009 at 3:38 PM, Romain Francois romain.franc...@dbmail.com wrote: Hi, You can either parse and eval the string you are making, as in: eval( parse( text = paste(avg_,colname, - 0;, sep='') ) ) Or you can do something like this: df[[ paste( avg_, colname, sep = ) ]] - 0 Thanks you so much! I used the first version and it worked. What puzzles me, is that I am not able to use - instead of = (my R book says the two can be exchanged) or break the command into different parts and execute them one after another. I get various error messages when I try: eval( parse( text - paste(avg_,colname, - 0;, sep='') ) ) or text = paste(avg_,colname, - 0;, sep='') parse(text) eval(parse(text)) Anyway, thanks a lot - you greatly improved the likelihood of me not working on the weekend! Best - P __ 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.