[R] Rscript on Mac : specify R64 over R (32-bit version)
Hi, I have both R and R64 installed on Mac OSX 10.8 Mountain Lion (64-bit). When I run the command sessionInfo() from within Rscript, I get: R version 2.15.2 (2012-10-26) Platform: i386-apple-darwin9.8.0/i386 (32-bit) Is there a way to make Rscript point at the R64 rather than R (32-bit)? Thanks, Matt [[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] Problem Installing R to SuSE 10 via RPM
Hi, I'm trying to install R from an rpm locally to my account (the reason I'm not doing it through yast/yast2/zypper is that the sys admin isn't yet willing to install it, and doesn't want to support it, but will help me support it if I install it locally -- in short, policy problems rather than technical). Below is the SuSE version, Kernel version, and rpm install error I'm getting, as well as the error... Can anyone help me with the error? I'm trying to install R-base 2.14.1, but it is telling me that I need R-base version 2.14.1 as a dependency. Am I using the wrong rpm for an installation starting from scratch? I got the rpm from: http://download.opensuse.org/repositories/devel:/languages:/R:/base/SLE_10/x86_64/ Thanks, Matt pettis@swat:~/bin cat /etc/*-release SUSE Linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 2 pettis@swat:~/bin uname -a Linux swat 2.6.16.60-0.34-smp #1 SMP Fri Jan 16 14:59:01 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux pettis@swat:~/bin rpm -ivh R-base-devel-2.14.1-30.1.x86_64.rpm warning: R-base-devel-2.14.1-30.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 793371fe error: Failed dependencies: R-base = 2.14.1 is needed by R-base-devel-2.14.1-30.1.x86_64 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem Installing R to SuSE 10 via RPM
Thanks, will do! I thought devel included base, but evidently, that's not the case... On Fri, Jan 13, 2012 at 10:58 AM, Gavin Blackburn gavin.blackb...@strath.ac.uk wrote: I think it's saying you need to install R-base before R-base-devel. You'll need to add a cran repository as SUSE might not have the most up-to-date version of R. This is the code for Ubuntu I assume it's the same, just change the distro and keyserver: sudo apt-get update sudo add-apt-repository 'deb http://cran.ma.imperial.ac.uk/bin/linux/ubuntu oneiric/' gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 gpg -a --export E084DAB9 | sudo apt-key add - You may also want to get Sun java, again, change distro and keyserver: sudo add-apt-repository ppa:ferramroberto/java sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.comB725097B3ACC3965 sudo apt-get update sudo apt-get install sun-java6-jdk sun-java6-plugin Then run: sudo apt-get install r-base r-base-dev sudo R CMD javareconf Cheers, Gavin. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Matthew Pettis Sent: 13 January 2012 16:43 To: r-help@r-project.org Subject: [R] Problem Installing R to SuSE 10 via RPM Hi, I'm trying to install R from an rpm locally to my account (the reason I'm not doing it through yast/yast2/zypper is that the sys admin isn't yet willing to install it, and doesn't want to support it, but will help me support it if I install it locally -- in short, policy problems rather than technical). Below is the SuSE version, Kernel version, and rpm install error I'm getting, as well as the error... Can anyone help me with the error? I'm trying to install R-base 2.14.1, but it is telling me that I need R-base version 2.14.1 as a dependency. Am I using the wrong rpm for an installation starting from scratch? I got the rpm from: http://download.opensuse.org/repositories/devel:/languages:/R:/base/SLE_10/x86_64/ Thanks, Matt pettis@swat:~/bin cat /etc/*-release SUSE Linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 2 pettis@swat:~/bin uname -a Linux swat 2.6.16.60-0.34-smp #1 SMP Fri Jan 16 14:59:01 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux pettis@swat:~/bin rpm -ivh R-base-devel-2.14.1-30.1.x86_64.rpm warning: R-base-devel-2.14.1-30.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 793371fe error: Failed dependencies: R-base = 2.14.1 is needed by R-base-devel-2.14.1-30.1.x86_64 [[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. -- Do not seek to follow in the footsteps of the wise men of old. Seek what they sought. - Matsuo Munefusa (Basho) [[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] Converting data.frame from long to wide format
Hi, I was wondering if there is an easy way that I am missing for turning a long dataframe into a wide one. Below is sample code that will make what I have and, in comments, the form of what I want: # Have: dataframe like 'df' df - expand.grid( x=LETTERS[1:3], y=LETTERS[4:6]) df$z - letters[1:length(df[,1])] # Want: data.frame that has following form: # A B C # D a b c # E d e f # F g h i I looked at 'xtabs' and 'cast' from reshape/reshape2, but unless I'm misunderstanding something, these will work only for the 'z' column being numeric, not textual. Is there an easy way to do this with 'z' being textual rather than numeric? tia, Matt [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting data.frame from long to wide format
Hi Jonathan, Thank you very much! I was about to recall this after I found this discussion (https://stat.ethz.ch/pipermail/r-help/2008-June/164440.html), but I think your solution is more tidy. Thank you very much! Matt On Wed, Dec 8, 2010 at 8:33 PM, Jonathan Christensen dzhona...@gmail.comwrote: Matt, library(reshape2) wide.df - dcast(df, y ~ x) Works great for me. Jonathan On Wed, Dec 8, 2010 at 7:26 PM, Matthew Pettis matthew.pet...@gmail.com wrote: Hi, I was wondering if there is an easy way that I am missing for turning a long dataframe into a wide one. Below is sample code that will make what I have and, in comments, the form of what I want: # Have: dataframe like 'df' df - expand.grid( x=LETTERS[1:3], y=LETTERS[4:6]) df$z - letters[1:length(df[,1])] # Want: data.frame that has following form: # A B C # D a b c # E d e f # F g h i I looked at 'xtabs' and 'cast' from reshape/reshape2, but unless I'm misunderstanding something, these will work only for the 'z' column being numeric, not textual. Is there an easy way to do this with 'z' being textual rather than numeric? tia, Matt [[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. -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting data.frame from long to wide format
Thank you Phil, your method worked great! Again, I was about to write back and add some facts -- all of the columns need to be 'character'... when I tried my and Jonathan's solutions with columns that were factors, I got errors. Here's what happened when I tried to use the 'dcast' method on my actual (not contrived) data with factors: -- county_sibley - subset(tmp, county_id == 72) county_sibley - subset(county_sibley, prct_std == GIBBON)[,c(prct_std,prct_name,year)] county_sibley$prct_name - factor(as.character(county_sibley$prct_name)) county_sibley$prct_std - factor(county_sibley$prct_std) county_sibley$year - factor(county_sibley$year) print(county_sibley) prct_std prct_name year 3515 GIBBONGIBBON 2002 7631 GIBBONGIBBON 2006 9085 GIBBONGIBBON 2010 str(county_sibley) 'data.frame': 3 obs. of 3 variables: $ prct_std : Factor w/ 1 level GIBBON: 1 1 1 $ prct_name: Factor w/ 1 level GIBBON: 1 1 1 $ year : Factor w/ 3 levels 2002,2006,..: 1 2 3 county_sibley_wide - dcast(county_sibley, prct_std ~ year, value_var = prct_name) Error in names(data) - array_names(res$labels[[2]]) : 'names' attribute [3] must be the same length as the vector [1] -- Converting all used columns to character made the 'cast' and 'dcast' solution work, so that should be noted. Thanks to everybody, Matt On Wed, Dec 8, 2010 at 8:53 PM, Phil Spector spec...@stat.berkeley.eduwrote: Another way, using just base R is reshape(df,idvar='y',timevar='x',v.names='z',direction='wide') y z.A z.B z.C 1 D a b c 4 E d e f 7 F g h i - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Wed, 8 Dec 2010, Matthew Pettis wrote: Hi Jonathan, Thank you very much! I was about to recall this after I found this discussion (https://stat.ethz.ch/pipermail/r-help/2008-June/164440.html), but I think your solution is more tidy. Thank you very much! Matt On Wed, Dec 8, 2010 at 8:33 PM, Jonathan Christensen dzhona...@gmail.com wrote: Matt, library(reshape2) wide.df - dcast(df, y ~ x) Works great for me. Jonathan On Wed, Dec 8, 2010 at 7:26 PM, Matthew Pettis matthew.pet...@gmail.com wrote: Hi, I was wondering if there is an easy way that I am missing for turning a long dataframe into a wide one. Below is sample code that will make what I have and, in comments, the form of what I want: # Have: dataframe like 'df' df - expand.grid( x=LETTERS[1:3], y=LETTERS[4:6]) df$z - letters[1:length(df[,1])] # Want: data.frame that has following form: # A B C # D a b c # E d e f # F g h i I looked at 'xtabs' and 'cast' from reshape/reshape2, but unless I'm misunderstanding something, these will work only for the 'z' column being numeric, not textual. Is there an easy way to do this with 'z' being textual rather than numeric? tia, Matt [[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. -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[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. -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[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] Need help Upgrading to R version =v2.11 on Ubuntu Hardy Heron (8.04 LTS)
Hi, I'd like to use ggplot2, which I think works best on some R release =v2.11 or so. However, with Ubuntu Hardy Heron 8.04 LTS, 'aptitude' packages show me only a version for 2.6. Can I install more recent version on this Ubuntu version, and if so, what is the most painless way to do this (is there some way to use 'aptitude'? Can I download a binary? Do I have to build from scratch?). thanks in advance, Matt [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need help Upgrading to R version =v2.11 on Ubuntu Hardy Heron (8.04 LTS)
Sorry, solved by me RTFM... The directions pertaining to what I needed to do are found here: http://cran.r-project.org/bin/linux/ubuntu/ Sorry to bother y'all, Matt On Mon, Dec 6, 2010 at 10:57 PM, Matthew Pettis matthew.pet...@gmail.comwrote: Hi, I'd like to use ggplot2, which I think works best on some R release =v2.11 or so. However, with Ubuntu Hardy Heron 8.04 LTS, 'aptitude' packages show me only a version for 2.6. Can I install more recent version on this Ubuntu version, and if so, what is the most painless way to do this (is there some way to use 'aptitude'? Can I download a binary? Do I have to build from scratch?). thanks in advance, Matt -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[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] Controlling print width settings for 'print' on command line
Hi, I'm using R interactively from a PuTTy command line, and when I print a dataframe (default, but just entering the name of the data frame), the display is using only half of the available horizontal width in which to print columns. How to I tell R how many columns it can/should use for printing? Thanks, Matt [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Controlling print width settings for 'print' on command line
Worked perfect, thank you very much! Matt On Mon, Dec 6, 2010 at 11:53 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi Matt, I'm not certain if this will work with PuTTy, but in general (and on Konsole/other terminals I've run R in) you can set it with the width argument of options() see: ?options I believe it is 80 by default, so something like: options(width = 160) might be about right. Cheers, Josh On Mon, Dec 6, 2010 at 9:48 PM, Matthew Pettis matthew.pet...@gmail.com wrote: Hi, I'm using R interactively from a PuTTy command line, and when I print a dataframe (default, but just entering the name of the data frame), the display is using only half of the available horizontal width in which to print columns. How to I tell R how many columns it can/should use for printing? Thanks, Matt [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[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] Printing data.frame data: alternatives to print?
Hi, I have a data frame with two factors (well, more, but 2 for simple consideration), and I want to display the different combinations of the them that actually occur in the data. In reality, there are too many of them to do to do a 'table' call and have one col vertical and one col horizontal (I don't want any of the factors listed horizontally). Before I try to write a function to do this for me, I was wondering if there were alternate printing styles for data that already exist, and if someone could direct me to them? Inclded is a sample code and 2 possibilities (others welcome for consideration) of how I want to display some data. Thanks, Matt - df - data.frame( f1=rep(c(Maj I, Maj II, Maj III), each=3), f2=c(Minor A, Minor A, Minor A, Minor A, Minor B, Minor B, Minor B, Minor C, Minor C) ) - What I want printed is something like: --- f1 f2 Maj I Minor A Maj II Minor A Minor B Maj III Minor B Minor C --- or --- f1 f2 Maj I Minor A Maj II Minor A Maj II Minor B Maj III Minor B Maj III Minor C __ 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] Printing data.frame data: alternatives to print?
I think that'll work... thanks! matt On Fri, Oct 29, 2010 at 9:45 AM, jim holtman jholt...@gmail.com wrote: Is this what you want: df f1 f2 1 Maj I Minor A 2 Maj I Minor A 3 Maj I Minor A 4 Maj II Minor A 5 Maj II Minor B 6 Maj II Minor B 7 Maj III Minor B 8 Maj III Minor C 9 Maj III Minor C df[!duplicated(df),] f1 f2 1 Maj I Minor A 4 Maj II Minor A 5 Maj II Minor B 7 Maj III Minor B 8 Maj III Minor C On Fri, Oct 29, 2010 at 9:53 AM, Matthew Pettis matthew.pet...@gmail.com wrote: Hi, I have a data frame with two factors (well, more, but 2 for simple consideration), and I want to display the different combinations of the them that actually occur in the data. In reality, there are too many of them to do to do a 'table' call and have one col vertical and one col horizontal (I don't want any of the factors listed horizontally). Before I try to write a function to do this for me, I was wondering if there were alternate printing styles for data that already exist, and if someone could direct me to them? Inclded is a sample code and 2 possibilities (others welcome for consideration) of how I want to display some data. Thanks, Matt - df - data.frame( f1=rep(c(Maj I, Maj II, Maj III), each=3), f2=c(Minor A, Minor A, Minor A, Minor A, Minor B, Minor B, Minor B, Minor C, Minor C) ) - What I want printed is something like: --- f1 f2 Maj I Minor A Maj II Minor A Minor B Maj III Minor B Minor C --- or --- f1 f2 Maj I Minor A Maj II Minor A Maj II Minor B Maj III Minor B Maj III Minor C __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity - Worship without sacrifice - Knowledge without character __ 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] ggplot2: facet_grid with only one level does not display the graph with the facet_grid level in title
Hi All, Here is the code that I'll be referring to: p - ggplot(wastran.data, aes(PER_KEY, EVENTS)) (p - p + facet_grid( pool.short ~ .) + stat_summary(aes(y=EVENTS), fun.y = sum, geom=line) + opts(axis.text.x = theme_text(angle = 90, hjust=1), title=Events (15min.) vs. Time: Facet pool, strip.text.y = theme_text()) ) Now, depending on preceding parameters, the 'pool.short' factor variable in 'wastran.data' can have one distinct factor level or it can have more than one. When 'pool.short' has more than one factor level, the graph performs as I expect, with multiple rows of graphs with the value of the 'pool.short' variable displayed on the right-hand side of the graph. When 'pool.short' has only one factor level, the value is NOT displayed on the right-hand side. However, I'd still like it displayed, even though it has only one value. Can someone tell me how to tweak this code to make it still display when it has only 1 factor level? If this code is unclear, I will be happy to take some time and generate an artificial but reproducible self-contained example. I left in the stat_summary layer in this code in case it is interfering with the desired output (but I suspect is is superfluous, but I am not confident enough to say that with absolute certainty). Thanks, Matt [[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] dataframe, transform, strsplit
Hi, I have a dataframe that has a column of vectors that I need to extract off the character string before the first '.' character and put it into a separate column. I thought I could use 'strsplit' for it within 'transform', but I can't seem to get the right invocation. Here is a sample dataframe that has what I have, what I want, and what I get. Can someone tell me how to get what is in the 'want' column from the 'have' column programatically? tia, Matt df - data.frame(have=c(a.b.c, d.e.f, g.h.i), want=c(a,d,g)) df.xform - transform(df, get=strsplit(as.character(have), split=., fixed=TRUE)[[1]][1]) df.xform [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dataframe, transform, strsplit
Thanks Gabor and Jim, Both solutions worked equally well for me (now I have an embarrassment of riches for a solution :-) ). Now that my main problem is solved, I am happy, but I was wondering if anyone would care to comment as to why my 'strsplit' solution doesn't behave the way I think it should... Thank you both again, Matt On Mon, Oct 25, 2010 at 12:09 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Mon, Oct 25, 2010 at 12:53 PM, Matthew Pettis matthew.pet...@gmail.com wrote: Hi, I have a dataframe that has a column of vectors that I need to extract off the character string before the first '.' character and put it into a separate column. I thought I could use 'strsplit' for it within 'transform', but I can't seem to get the right invocation. Here is a sample dataframe that has what I have, what I want, and what I get. Can someone tell me how to get what is in the 'want' column from the 'have' column programatically? tia, Matt df - data.frame(have=c(a.b.c, d.e.f, g.h.i), want=c(a,d,g)) df.xform - transform(df, get=strsplit(as.character(have), split=., fixed=TRUE)[[1]][1]) df.xform Try replacing the dot [.] and everything thereafter .* with nothing like this: transform(df, want = sub([.].*, , have)) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Seven Deadly Sins (Gandhi): - Wealth without work - Politics without principle - Pleasure without conscience - Commerce without morality - Science without humanity- Worship without sacrifice - Knowledge without character [[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] POSIXct: Extract the hour for a list of elements
Hi, I have a list/data.frame 'pk' of POSIXct dates, and I'd like to extract the hour for each row. I know that if I have an individual POSIXct object, I can extract the hour by converting to a new object with: new.lt - as.POSIXlt(single POSIXct object) new.lt$hour But I can't figure out how to apply this for a list of such dates in a vectorized form. I can write a loop, I guess and implement this, but I think I'm missing a way that takes advantage of vectorization. Here is my loop to just print the hour extracts: for (ct in pk) { lt - as.POSIXlt(ct, origin=1970-01-01) print(lt$hour) } So is there a shorter vectorization idiom that lets me do this? I can't figure out how to use 'lapply' to apply the '$' operator... Thanks, Matt [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] POSIXct: Extract the hour for a list of elements
Thank you! That solution worked! I thought I'd tried something similar to that, but obviously I didn't. Here's a self-contained example, for posterity and completeness: z.df - data.frame(times=c(Sys.time(), Sys.time() + 3600)) as.POSIXlt(z.df[,1])$hour And this gives me what I want. Thank you again! Matt On Fri, Sep 24, 2010 at 5:50 PM, Phil Spector spec...@stat.berkeley.eduwrote: Matthew - It's a bit simpler than you think: as.POSIXlt(pk)$hour should return what you want. (If not, please provide a reproducible example.) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 24 Sep 2010, Matthew Pettis wrote: Hi, I have a list/data.frame 'pk' of POSIXct dates, and I'd like to extract the hour for each row. I know that if I have an individual POSIXct object, I can extract the hour by converting to a new object with: new.lt - as.POSIXlt(single POSIXct object) new.lt$hour But I can't figure out how to apply this for a list of such dates in a vectorized form. I can write a loop, I guess and implement this, but I think I'm missing a way that takes advantage of vectorization. Here is my loop to just print the hour extracts: for (ct in pk) { lt - as.POSIXlt(ct, origin=1970-01-01) print(lt$hour) } So is there a shorter vectorization idiom that lets me do this? I can't figure out how to use 'lapply' to apply the '$' operator... Thanks, Matt [[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. -- Pardon him. Theodotus: he is a barbarian, and thinks that the customs of his tribe and island are the laws of nature. -- George Bernard Shaw, Caesar and Cleopatra [[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] Barchart in lattice package: controlling order of bars in plot and color of a selected bar
Hi, I'm using the lattice function 'barchart' to make a series of 4 histograms. Currently, the y-axis values are graphed in order of the y-axis variable. I'd like to have the y-axis values sorted in ascending order of the x-axis values so that the longest bar horizontally is on top of the graph (in it's seciton) and the shortest bar is on the bottom. I can do this in 'barplot' with normal graphics; how can I do this in the lattice barchart function? In addition, i use the 'col' parameter in 'barplot' to make one particular value be a different color than the rest. Is this sort of control available in lattice's barchart? I didn't see it when reading the documentation. Thanks, Matt ### Regular barplot code that works # w02-08 ar pre-sorted in descending Sum oder, # barcolor column has names of colors to use. opar - par(mfrow=c(1,4)) barplot(w02[,Sum], horiz=T, col=w02[,barcolor], names.arg=w02[,sts.dist], main=2002) barplot(w04[,Sum], horiz=T, col=w04[,barcolor], names.arg=w04[,sts.dist], main=2004) barplot(w06[,Sum], horiz=T, col=w06[,barcolor], names.arg=w06[,sts.dist], main=2006) barplot(w08[,Sum], horiz=T, col=w08[,barcolor], names.arg=w08[,sts.dist], main=2008) ### Attempt with lattice # work contains w02-08 stacked on top of each other barchart(sts.dist[order(Sum),] ~ Sum | year, data=work, layout=c(4,1), main=Ranking of best turnout by SD) __ 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] Casting lists to data.frames, analog to SAS
I have a specific question and a general question. Specific Question: I want to do an analysis on a data frame by 2 or more class variables (i.e., use 2 or more columns in a dataframe to do statistical classing). Coming from SAS, I'm used to being able to take a data set and have the output of the analysis in a dataset for further manipulation. I have a data set with vote totals, with one column being the office name being voted on, and the other being the party of the candidate. My votes are in the column vc.n. I did the analysis I want with: work - by(sd62[,vc.n], sd62[,c(office.nm,party.abbr)], sum) the str() output of work looks like: str(work) 'by' int [1:9, 1:11] NA 30 NA NA 0 0 0 NA 33 25678 ... - attr(*, dimnames)=List of 2 ..$ office.nm : chr [1:9] ATTORNEY GENERAL GOVERNOR LT GOVERNOR SECRETARY OF STATE STATE AUDITOR ... ..$ party.abbr: chr [1:11] CP DFL DFL2 GP ... - attr(*, call)= language by.default(data = sd62[, vc.n], INDICES = sd62[, c(office.nm, party.abbr)], FUN = sum) work is now a list. I'd really like to have work be a data frame with 3 columns: The rows of the first two columns show the office and party levels being considered, and the third being the sum of the votes for that level combination. How do I cast this list/output into a data frame? using 'as.data.frame' doesn't work. General Question: I assume the answer to the specific question is dependent on my understanding list objects and accessing their attributes. Can anyone point me to a good, throrough treatment of these R topics? Specifically how to read and interpret the output of the str(), and attributes() function, how to extract the values of the 'by' output object into a data frame, etc.? Thanks, Matt [[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] Casting lists to data.frames, analog to SAS
Resubmitting: Told I had a problem with a character set -- now submitting in plain text I have a specific question and a general question. Specific Question: I want to do an analysis on a data frame by 2 or more class variables (i.e., use 2 or more columns in a dataframe to do statistical classing). Coming from SAS, I'm used to being able to take a data set and have the output of the analysis in a dataset for further manipulation. I have a data set with vote totals, with one column being the office name being voted on, and the other being the party of the candidate. My votes are in the column vc.n. I did the analysis I want with: work - by(sd62[,vc.n], sd62[,c(office.nm,party.abbr)], sum) the str() output of work looks like: str(work) 'by' int [1:9, 1:11] NA 30 NA NA 0 0 0 NA 33 25678 ... - attr(*, dimnames)=List of 2 ..$ office.nm : chr [1:9] ATTORNEY GENERAL GOVERNOR LT GOVERNOR SECRETARY OF STATE STATE AUDITOR ... ..$ party.abbr: chr [1:11] CP DFL DFL2 GP ... - attr(*, call)= language by.default(data = sd62[, vc.n], INDICES = sd62[, c(office.nm, party.abbr)], FUN = sum) work is now a list. I'd really like to have work be a data frame with 3 columns: The rows of the first two columns show the office and party levels being considered, and the third being the sum of the votes for that level combination. How do I cast this list/output into a data frame? using 'as.data.frame' doesn't work. General Question: I assume the answer to the specific question is dependent on my understanding list objects and accessing their attributes. Can anyone point me to a good, throrough treatment of these R topics? Specifically how to read and interpret the output of the str(), and attributes() function, how to extract the values of the 'by' output object into a data frame, etc.? Thanks, Matt __ 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] Casting lists to data.frames, analog to SAS
Thank you very much -- this was very helpful for differentiating among the aggregating methods! Matt On Wed, Jan 14, 2009 at 3:42 PM, Marc Schwartz marc_schwa...@comcast.net wrote: on 01/14/2009 02:51 PM Matthew Pettis wrote: I have a specific question and a general question. Specific Question: I want to do an analysis on a data frame by 2 or more class variables (i.e., use 2 or more columns in a dataframe to do statistical classing). Coming from SAS, I'm used to being able to take a data set and have the output of the analysis in a dataset for further manipulation. I have a data set with vote totals, with one column being the office name being voted on, and the other being the party of the candidate. My votes are in the column vc.n. I did the analysis I want with: work - by(sd62[,vc.n], sd62[,c(office.nm,party.abbr)], sum) the str() output of work looks like: str(work) 'by' int [1:9, 1:11] NA 30 NA NA 0 0 0 NA 33 25678 ... - attr(*, dimnames)=List of 2 ..$ office.nm : chr [1:9] ATTORNEY GENERAL GOVERNOR LT GOVERNOR SECRETARY OF STATE STATE AUDITOR ... ..$ party.abbr: chr [1:11] CP DFL DFL2 GP ... - attr(*, call)= language by.default(data = sd62[, vc.n], INDICES = sd62[, c(office.nm, party.abbr)], FUN = sum) work is now a list. I'd really like to have work be a data frame with 3 columns: The rows of the first two columns show the office and party levels being considered, and the third being the sum of the votes for that level combination. How do I cast this list/output into a data frame? using 'as.data.frame' doesn't work. General Question: I assume the answer to the specific question is dependent on my understanding list objects and accessing their attributes. Can anyone point me to a good, throrough treatment of these R topics? Specifically how to read and interpret the output of the str(), and attributes() function, how to extract the values of the 'by' output object into a data frame, etc.? Thanks, Matt Matt, Welcome to R. The help pages for each function, while they can be intentionally terse, are a good first place to look. Many will include links/references to related sources. An Introduction to R is a good general place to start. A more thorough treatment is in the R Language Definition manual. There are also a plethora of contributed documents: http://cran.r-project.org/other-docs.html and books on R and using R within specific domains: http://www.r-project.org/doc/bib/R-books.html There are (at least) three ways to generate summary statistics based upon multi-level groupings. These include by(), tapply() and aggregate(). The key difference between the three is the class/structure of the results object and the print (output) method. In the specific case of aggregate(), it must also return a scalar. Thus for example, unlike with by() and tapply(), you cannot use summary(), which returns multiple values. Thus the choice for which approach to take, to an extent, is founded on what you may subsequently do with the data. As an example, using the same set of data (warpbreaks): str(warpbreaks) 'data.frame': 54 obs. of 3 variables: $ breaks : num 26 30 54 25 70 52 51 26 67 18 ... $ wool : Factor w/ 2 levels A,B: 1 1 1 1 1 1 1 1 1 1 ... $ tension: Factor w/ 3 levels L,M,H: 1 1 1 1 1 1 1 1 1 2 ... # Use by() by(warpbreaks[, 1], list(wool = warpbreaks$wool, tension = warpbreaks$tension), sum) wool: A tension: L [1] 401 -- wool: B tension: L [1] 254 -- wool: A tension: M [1] 216 -- wool: B tension: M [1] 259 -- wool: A tension: H [1] 221 -- wool: B tension: H [1] 169 Note, because the result of using by() is at its core, a matrix/table, you can also do the following, explicitly using the print method for a table: print.table(by(warpbreaks[, 1], list(wool = warpbreaks$wool, tension = warpbreaks$tension), sum)) tension wool L M H A 401 216 221 B 254 259 169 which gives you printed output in the same format as tapply() below, without altering the structure of the result itself. # tapply() directly gives you a tabular output tapply(warpbreaks[, 1], list(wool = warpbreaks$wool, tension = warpbreaks$tension), sum) tension wool L M H A 401 216 221 B 254 259 169 Note that the structure of the result from by() and the result from tapply() are quite similar: str(by(warpbreaks[, 1], list(wool = warpbreaks$wool, tension = warpbreaks$tension), sum)) by [1:2, 1:3] 401 254 216 259 221 169 - attr(*, dimnames)=List of 2 ..$ wool : chr [1:2] A B ..$ tension: chr [1:3] L M H - attr(*, call
[R] How can I easily rbind a list of data frames into one data frame?
Hi, I have a list output from the 'lapply' function where the value of each element of a list is a data frame (each data frame in the list has the same column types). How can I rbind all of the list entry values into one data frame? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Newbie: Ranking a data frame, grouped by 2 or more columns
Hi, I'd like to rank obs in a data frame as subset by 2 or more columns... The example input would look like the following: ++++ x y v -- -- -- a w 200 a w 100 b w 500 b w 200 b z 300 b z 400 ++++ And the data frame I want to create is below: ++++ x y v rank -- -- -- a w 2001 a w 1002 b w 5001 b w 2002 b z 3002 b z 4001 ++++ Can someone help me with this? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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: Ranking a data frame, grouped by 2 or more columns
Thanks! I think 'ave' was what I was looking for... On Fri, Sep 26, 2008 at 6:28 PM, jim holtman [EMAIL PROTECTED] wrote: Try this: x V1 V2 V3 1 a w 200 2 a w 100 3 b w 500 4 b w 200 5 b z 300 6 b z 400 x$rank - ave(x$V3, x$V1, x$V2, FUN=rank) x V1 V2 V3 rank 1 a w 2002 2 a w 1001 3 b w 5002 4 b w 2001 5 b z 3001 6 b z 4002 On Fri, Sep 26, 2008 at 4:54 PM, Matthew Pettis [EMAIL PROTECTED] wrote: Hi, I'd like to rank obs in a data frame as subset by 2 or more columns... The example input would look like the following: ++++ x y v -- -- -- a w 200 a w 100 b w 500 b w 200 b z 300 b z 400 ++++ And the data frame I want to create is below: ++++ x y v rank -- -- -- a w 2001 a w 1002 b w 5001 b w 2002 b z 3002 b z 4001 ++++ Can someone help me with this? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Equivalent of 'first.var' or 'last.var' from SAS in R?
Hi, I want to sort a data frame by multiple columns and then take the first record in each unique level of the by group I used to sort the data frame. Does someone have an example of how to do this? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Equivalent of 'first.var' or 'last.var' from SAS in R?
Thanks to Peter and Phil, this was indeed my idea. On Thu, Sep 25, 2008 at 2:26 PM, Peter Dalgaard [EMAIL PROTECTED] wrote: Matthew Pettis wrote: Hi, I want to sort a data frame by multiple columns and then take the first record in each unique level of the by group I used to sort the data frame. Does someone have an example of how to do this? Thanks, Matt Something like this aggregate(airquality,airquality[Month],head,1) Month Ozone Solar.R Wind Temp Month Day 1 541 190 7.4 67 5 1 2 6NA 286 8.6 78 6 1 3 7 135 269 4.1 84 7 1 4 839 83 6.9 81 8 1 5 996 167 6.9 91 9 1 where you probably want to lose the first column. or unsplit(lapply(split(aq,aq$Month), head,1),5:9) Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 32 NA 286 8.6 78 6 1 62135 269 4.1 84 7 1 93 39 83 6.9 81 8 1 12496 167 6.9 91 9 1 This also works, but the tail variant is harder: unsplit(lapply(split(aq,aq$Month), [,1,),5:9) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] print.data.frame : row.name = FALSE not having intended effect
Hi, Does anybody know if row.name = FALSE actually works in v2.6.2? Because it isn't working for me... here is some sample code and output: ++++++++++ print(x,row.names = FALSE) party_abbr candidate_name votes_candidate 2 DFLAMY KLOBUCHAR 1,278,849 5 R MARK KENNEDY 835,653 4 IPROBERT FITZGERALD 71,194 3 GP MICHAEL JAMES CAVLAN 10,714 1 CP BEN POWERS 5,408 10 WI WRITE-IN** 901 8 WI PETER IDUSOGIE** 29 6 WICHARLES ALDRICH** 15 9 WI REBECCA WILLIAMSON** 5 7 WI JOHN ULDRICH** 4 ++++++++++ Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] print.data.frame : row.name = FALSE not having intended effect
Never mind -- the answer is buried in my own question... I was looking at documentation for version 2.7.2, and when I looked at the one for 2.6.2, I see the row.names option isn't in that release. Any suggestions on how I can code around that in 2.6.2, so I don't have to upgrade to 2.7.2 just yet? Thanks, Matt On Tue, Sep 23, 2008 at 8:49 PM, Matthew Pettis [EMAIL PROTECTED] wrote: Hi, Does anybody know if row.name = FALSE actually works in v2.6.2? Because it isn't working for me... here is some sample code and output: ++++++++++ print(x,row.names = FALSE) party_abbr candidate_name votes_candidate 2 DFLAMY KLOBUCHAR 1,278,849 5 R MARK KENNEDY 835,653 4 IPROBERT FITZGERALD 71,194 3 GP MICHAEL JAMES CAVLAN 10,714 1 CP BEN POWERS 5,408 10 WI WRITE-IN** 901 8 WI PETER IDUSOGIE** 29 6 WICHARLES ALDRICH** 15 9 WI REBECCA WILLIAMSON** 5 7 WI JOHN ULDRICH** 4 ++++++++++ Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] print.data.frame : row.name = FALSE not having intended effect
Thanks Rolf, I'm running this on Ubuntu Hardy Heron, and as far as I can tell from http://packages.ubuntu.com/search?keywords=r-basesearchon=namessuite=hardysection=all , v2.6.2 is the version they have available. The painless upgrade for me is to use 'aptitude' to get v2.7.x, otherwise I have to build it from scratch... Unless you know of a repository of binaries that has v2.7.x? Thanks, Matt On Tue, Sep 23, 2008 at 9:08 PM, Rolf Turner [EMAIL PROTECTED] wrote: On 24/09/2008, at 1:55 PM, Matthew Pettis wrote: Never mind -- the answer is buried in my own question... I was looking at documentation for version 2.7.2, and when I looked at the one for 2.6.2, I see the row.names option isn't in that release. Any suggestions on how I can code around that in 2.6.2, so I don't have to upgrade to 2.7.2 just yet? Why not just upgrade? It's painless, and should be done anyhow. Be that as it may, here's the code for print.data.frame from R 2.7.2: function (x, ..., digits = NULL, quote = FALSE, right = TRUE, row.names = TRUE) { n - length(row.names(x)) if (length(x) == 0L) { cat(NULL data frame with, n, rows\n) } else if (n == 0L) { print.default(names(x), quote = FALSE) cat(0 rows (or 0-length row.names)\n) } else { m - as.matrix(format.data.frame(x, digits = digits, na.encode = FALSE)) if (!isTRUE(row.names)) dimnames(m)[[1]] - if (identical(row.names, FALSE)) rep.int(, n) else row.names print(m, ..., quote = quote, right = right) } invisible(x) } cheers, Rolf Turner ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ## -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] print.data.frame : row.name = FALSE not having intended effect
Thanks Dirk, One more question, then... I looked at the link, but haven't tried all the steps, but I am worried that the original listings in /etc/apt/sources.list will mask the version of r-base-dev I want to install... How do I make sure to point it at the right repository (sorry for asking Ubuntu questions on the R list, but actually, right now, it looks like ubuntuforums is having website issues...) thanks, Matt On Tue, Sep 23, 2008 at 9:22 PM, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: On 23 September 2008 at 20:55, Matthew Pettis wrote: | Never mind -- the answer is buried in my own question... I was looking | at documentation for version 2.7.2, and when I looked at the one for | 2.6.2, I see the row.names option isn't in that release. | | Any suggestions on how I can code around that in 2.6.2, so I don't | have to upgrade to 2.7.2 just yet? Or take the other route: use R 2.7.2, packaged conveniently for your Ubuntu system via CRAN. See here: http://cran.us.r-project.org/bin/linux/ubuntu/ Dirk -- Three out of two people have difficulties with fractions. -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Hmisc and Ubuntu (aptitude install)
Thank You All, I think all of this may have been due to shared library conflict headaches. At one point, I inadvertently upgraded my Perl install to 5.10, and I think that messed up a lot of my libraries. I have now started with a clean Ubuntu install, and am going to see if I can work my way back up to installing R and making that work. I will recontact the list if this problem persists through this reimaging of my server. Thanks again, Matt On Mon, Sep 22, 2008 at 8:20 AM, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: On Mon, Sep 22, 2008 at 08:48:12AM -0400, Vincent Goulet wrote: Matthew, As per the CRAN Ubuntu README http://cran.r-project.org/bin/linux/ubuntu/ install the Ubuntu r-base-dev package to compile R packages from sources. Well there should be a working r-cran-hmisc package. You simply got a '404' error indicating that your network access (using http) to the external Ubuntu mirror was broken. Fix that, or download the package by hand. It may be easier to just install the missing package. That said, Vincent is of course entirely correct on the need for r-base-dev. Dirk Vincent Le lun. 22 sept. à 00:08, Matthew Pettis a écrit : Hi, I'm trying to get the Hmisc module on my Ubuntu Hardy Heron install. I tried getting Hmisc from within R by issuing the standard 'install.packages' command, but it said I needed 'gfortran' to compile. I thought I could circumvent this by using 'aptitude' to get the package 'r-cran-hmisc', but when I got it, the package had critical missing parts (got 404s). So, I'll be trying to go back and download 'gfortran', but can anybody tell me if this aptitude ubuntu package should be kept up to date and is just currently overlooked? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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. -- Three out of two people have difficulties with fractions. -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Hmisc and Ubuntu (aptitude install)
Hi All, After rebuilding my Ubuntu image, I followed the instruction in this thread, and everything worked out fine -- thank you again. So, I'll just add: if you use R and perl, and don't have to download perl5.10, then don't do it, at least not yet. Or, if you do, then you will have a lot of shared object tweaking. Matt On Mon, Sep 22, 2008 at 1:22 PM, Matthew Pettis [EMAIL PROTECTED] wrote: Thank You All, I think all of this may have been due to shared library conflict headaches. At one point, I inadvertently upgraded my Perl install to 5.10, and I think that messed up a lot of my libraries. I have now started with a clean Ubuntu install, and am going to see if I can work my way back up to installing R and making that work. I will recontact the list if this problem persists through this reimaging of my server. Thanks again, Matt On Mon, Sep 22, 2008 at 8:20 AM, Dirk Eddelbuettel [EMAIL PROTECTED] wrote: On Mon, Sep 22, 2008 at 08:48:12AM -0400, Vincent Goulet wrote: Matthew, As per the CRAN Ubuntu README http://cran.r-project.org/bin/linux/ubuntu/ install the Ubuntu r-base-dev package to compile R packages from sources. Well there should be a working r-cran-hmisc package. You simply got a '404' error indicating that your network access (using http) to the external Ubuntu mirror was broken. Fix that, or download the package by hand. It may be easier to just install the missing package. That said, Vincent is of course entirely correct on the need for r-base-dev. Dirk Vincent Le lun. 22 sept. à 00:08, Matthew Pettis a écrit : Hi, I'm trying to get the Hmisc module on my Ubuntu Hardy Heron install. I tried getting Hmisc from within R by issuing the standard 'install.packages' command, but it said I needed 'gfortran' to compile. I thought I could circumvent this by using 'aptitude' to get the package 'r-cran-hmisc', but when I got it, the package had critical missing parts (got 404s). So, I'll be trying to go back and download 'gfortran', but can anybody tell me if this aptitude ubuntu package should be kept up to date and is just currently overlooked? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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. -- Three out of two people have difficulties with fractions. -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Newbie: Formatting numbers with commas
Hi, Search through the R archives, and couldn't find my answer... how do you format numbers with commas (standard American, one every three digits)? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Hmisc and Ubuntu (aptitude install)
Hi, I'm trying to get the Hmisc module on my Ubuntu Hardy Heron install. I tried getting Hmisc from within R by issuing the standard 'install.packages' command, but it said I needed 'gfortran' to compile. I thought I could circumvent this by using 'aptitude' to get the package 'r-cran-hmisc', but when I got it, the package had critical missing parts (got 404s). So, I'll be trying to go back and download 'gfortran', but can anybody tell me if this aptitude ubuntu package should be kept up to date and is just currently overlooked? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Fwd: Reporting with down and across variables
[Reposting with changed example and font spec removed] Hi, I want to take the dataframe df generated below and reshape the data with column names being w, x, y, and the different levels of z. The values under the different levels of z are the corresponding values of r. I've tried reshape and cast, and I can't seem to find the right combination. Any help is appreciated, Matt - # Generate data w - c(a,b) x - c(c,d) y - c(e,f) z - c(g,h) df - expand.grid(w=w,x=x,y=y,z=z) df$r - rnorm(16,mean=0,sd=1) - Wanted output: w x y g h - - - - - a c e 0.10.2 a c f -0.4 0.32 a d e ... ... __ 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] Reporting with down and across variables
[Reposting with changed example] Hi, I want to take the dataframe df generated below and reshape the data with column names being w, x, y, and the different levels of z. The values under the different levels of z are the corresponding values of r. I've tried reshape and cast, and I can't seem to find the right combination. Any help is appreciated, Matt - # Generate data w - c(a,b) x - c(c,d) y - c(e,f) z - c(g,h) df - expand.grid(w=w,x=x,y=y,z=z) df$r - rnorm(16,mean=0,sd=1) - Wanted output: w x y g h - - - - - a c e 0.10.2 a c f -0.4 0.32 a d e ... ... [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reporting with down and across variables
It does, thanks! Did I miss in the documentation that the variable has to be named 'value'? On Thu, Sep 18, 2008 at 10:08 AM, hadley wickham [EMAIL PROTECTED] wrote: On Thu, Sep 18, 2008 at 10:03 AM, Matthew Pettis [EMAIL PROTECTED] wrote: [Reposting with changed example] Hi, I want to take the dataframe df generated below and reshape the data with column names being w, x, y, and the different levels of z. The values under the different levels of z are the corresponding values of r. I've tried reshape and cast, and I can't seem to find the right combination. Any help is appreciated, Matt - # Generate data w - c(a,b) x - c(c,d) y - c(e,f) z - c(g,h) df - expand.grid(w=w,x=x,y=y,z=z) df$r - rnorm(16,mean=0,sd=1) Well if you change that last line to : df$value - rnorm(16,mean=0,sd=1) Then I think the following does what you want: cast(df, w + x + y ~ z) Hadley -- http://had.co.nz/ -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Reporting with down and across variables
Hi, I have a dataframe like the following: xfact yfact zfact response --- --- --- -- x1 y1 z1 r1 x1 y1 z2 r2 ... I want output that looks like: ___ zfac levels___ xfact yfact z1 z2 ... zn --- --- ... x1 y1 r1 r2rn How can I go about this? Thanks, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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] Newbie: 'table' output in columns rather than matrix
Hi, Coming to R from SAS... I have a data.frame A with 2 long factors x and y. I want to get a count of the number of rows with each level of x and y jointly. 'table' seemed like it would work, but as I have many levels, the matrix output is pretty useless to me (and I don't care about zero values). How can I get output that looks like: A$x A$y Freq -- - --- x1y18 x1y3 10 ... Thanks a ton, Matt -- It is from the wellspring of our despair and the places that we are broken that we come to repair the world. -- Murray Waas __ 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.