[R] ggplot2

2012-03-05 Thread Ryan Garner
I just updated to R 2.14 with ggplot2 0.9 and am finding bugs.

 ggplot2  GPL-2  2.14.0

This example is taken from pg 101 in the ggplot book.

 plot - qplot(date, psavert, data = economics, geom = line) +
 ylab(Personal savings rate) + geom_hline(xintercept = 0, colour =
 grey50)'
 plot + scale_x_date(major = 10 years)
Error in continuous_scale(aesthetics, date, identity, breaks = breaks,  :
  unused argument(s) (major = 10 years) plot + scale_x_date(limits =
as.Date(c(2004-01-01, 2005-01-01)),format = %Y-%m-%d)
 plot + scale_x_date(limits = as.Date(c(2004-01-01, 2005-01-01)),format
 = %Y-%m-%d)
Error in continuous_scale(aesthetics, date, identity, breaks = breaks,  :
  unused argument(s) (format = %Y-%m-%d)

--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-tp4447745p4447745.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.


Re: [R] ggplot2

2012-03-05 Thread Ryan Garner
I found the addendum.

http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf

--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-tp4447745p4448150.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.


Re: [R] X11 graphics windows under CMD BATCH

2011-03-04 Thread Ryan Garner
I had this same issue. My quick and dirty solution was to create an infinite
loop at the end of my R plotting script and then manually kill the job with
Ctrl+C once I was done looking at the plot.

--
View this message in context: 
http://r.789695.n4.nabble.com/X11-graphics-windows-under-CMD-BATCH-tp838015p3335922.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.


Re: [R] Parallel Scan of Large File

2010-12-08 Thread Ryan Garner

Hi Jim,

Thanks for your insight. I used Linux split to split my large file into
smaller partitions. On the server I work on, multipath I/O access is enabled
and we use RAID for storage; thus, I don't think I can put each partition on
a spindle. I'm able to open multiple files at a time into stdin from the
command line:

 cat file1.txt | wc -l 
 cat file2.txt | wc -l 
 cat file3.txt | wc -l 
 cat file4.txt | wc -l 

But I'm still not sure how to read each partition in parallel. When I run
this code, it doesn't run in parallel, instead file.list gets filled with 1
cpu doing all the work.

R library(doMC)
R files - Sys.glob(x*) #
Grabs all the file partitions created by split
R file.list - lapply(files,function(x){file(x,r)})   #
Creates all the file partitions connections
R master - foreach (i = icount(length(open))) %dopar% # Attempt at
parallel readLines
+{
+   readLines(file.list[[i]],100)
+}

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Parallel-Scan-of-Large-File-tp3077545p3079110.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] Parallel Scan of Large File

2010-12-07 Thread Ryan Garner

Is it possible to parallel scan a large file into a character vector in 1M
chunks using scan() with the doMC package? Furthermore, can I specify the
tasks for each child?

i.e. I'm working on a Linux box with 8 cores and would like to scan in 8M
records at time (all 8 cores scan 1M records at a time) from a file with 40M
records total.

file - file(data.txt,r)
child - foreach(i = icount(40)) %dopar%
{
scan(file,what = character,sep = \n,skip = 0,nlines = 1e6)
}

Thus, each child would have a different skip argument. child[[1]]: skip = 0,
child[[2]]: skip = 1e6 + 1, child[[3]]: skip = 2e6 + 1, ... ,child[[40]]:
skip = 39e6 + 1. I would then end up with a list of 40 vectors with
child[[1]] containing records 1 to 100, child[[2]] containing records
101 to 200, ... ,child[[40]] containing records 3901 to
4000. 

Also, would one file connection suffice or does their need to be a file
connection that opens and closes for each child?




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Parallel-Scan-of-Large-File-tp3077545p3077545.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.


Re: [R] R cmd batch with parameters

2010-12-06 Thread Ryan Garner

http://projects.uabgrid.uab.edu/r-group/wiki/CommandLineProcessing
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-cmd-batch-with-parameters-tp3075376p3075587.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.


Re: [R] Non-visible functions: merge.data.table

2010-12-04 Thread Ryan Garner

Thanks Jim! I posted the specifics of what I'm trying to accomplish here:
http://r.789695.n4.nabble.com/Slow-Data-Table-Merge-td3072027.html
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Non-visible-functions-merge-data-table-tp3072051p3072075.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] Non-visible functions: merge.data.table

2010-12-03 Thread Ryan Garner

I've downloaded the data.table package from CRAN and R-Forge and still
can't utilize merge.data.table for faster merges. How do I make this
function visible?

 install.packages(data.table,repos=http://R-Forge.R-project.org;)
trying URL
'http://R-Forge.R-project.org/src/contrib/data.table_1.5.1.tar.gz'
Content type 'application/x-gzip' length 616492 bytes (602 Kb)
opened URL

 library(data.table)
 methods(merge)
[1] merge.data.frame  merge.data.table* merge.default

   Non-visible functions are asterisked


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Non-visible-functions-merge-data-table-tp3071879p3071879.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.


Re: [R] Subset POSIXlt Field

2010-10-05 Thread Ryan Garner

This should work:
 test -subset(wild,ID==2830  Date==as.POSIXlt(2010-08-17))

If not, here's another solution:
 dates - c(2010-05-28,2010-08-17)
 dates - as.POSIXlt(dates)
 id - c(2830,2830)
 data - data.frame(id,dates)
 test - data[data$id == 2830  data$dates == as.POSIXlt(2010-08-17), ]
 test
id  dates
2 2830 2010-08-17
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Subset-POSIXlt-Field-tp2956822p2956890.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.


Re: [R] Linux System Function

2010-04-24 Thread Ryan Garner

Clever solution. I use paste alot and didn't think to use it for this
problem. Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linux-System-Function-tp2063058p2063113.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] Linux System Function

2010-04-23 Thread Ryan Garner

How do I pass a filename as an argument to the system command to count the
number of records in that file? I only know how to do it by hardcoding it.

HARDCODING EXAMPLE
 test - matrix(1:20,ncol=5)
 write(x = test,file = test.txt)
 records - as.numeric(system(cat test.txt | wc -l,intern = TRUE))
 records
[1] 4

??? NON-HARCODING EXAMPLE ???
 file = test.txt
 records - as.numeric(system(cat file | wc -l,intern = TRUE))
cat: file: No such file or directory
 records - as.numeric(system(cat test.txt | wc -l,intern = TRUE))
Error: unexpected symbol in records - as.numeric(system(cat test.txt

TFYH

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linux-System-Function-tp2063058p2063058.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] GGPLOT2: Reverse order of legend to match order of x-axis

2010-03-24 Thread Ryan Garner

How do I reverse the order of the legend in a bar plot to match order of the
x-axis? In other words, I want the stacked colors of the legend to match the
stacked colors of the bar plot. I tried this, but it didn't work.

colors - c(5 = red,4 = blue,3 = darkgreen)
p - qplot(factor(cyl), data=mtcars, geom=bar, fill=factor(gear))
p + scale_colour_manual(name = gear,values = colors,breaks =
c(5,4,3),labels = c(5 speed,4 speed,3 speed))

http://n4.nabble.com/file/n1689526/plot.jpeg 
-- 
View this message in context: 
http://n4.nabble.com/GGPLOT2-Reverse-order-of-legend-to-match-order-of-x-axis-tp1689526p1689526.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.


Re: [R] GGPLOT2: Reverse order of legend to match order of x-axis

2010-03-24 Thread Ryan Garner

Hadley, it doesn't work. Here is my step by step sequence following the
Wordpress site instructions.

R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 library(ggplot2)
Loading required package: proto
Loading required package: grid
Loading required package: reshape
Loading required package: plyr
Loading required package: digest
 ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar()
http://n4.nabble.com/file/n1689957/plot1.jpeg 
 levels(diamonds$cut)
[1] Fair  Good  Very Good Premium   Ideal
 diamonds$cut - factor(diamonds$cut, levels = rev(levels(diamonds$cut)))
 levels(diamonds$cut)
[1] Ideal Premium   Very Good Good  Fair
http://n4.nabble.com/file/n1689957/plot2.jpeg 
 ggplot(diamonds, aes(clarity, fill = cut, order = -as.numeric(cut))) +
 geom_bar()
http://n4.nabble.com/file/n1689957/plot3.jpeg 
 diamonds$cut - factor(diamonds$cut, levels = rev(levels(diamonds$cut)))
 ggplot(diamonds, aes(clarity, fill = cut, order = -as.numeric(cut))) +
 geom_bar()
http://n4.nabble.com/file/n1689957/plot4.jpeg 
-- 
View this message in context: 
http://n4.nabble.com/GGPLOT2-Reverse-order-of-legend-to-match-order-of-x-axis-tp1689526p1689957.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.


Re: [R] GGPLOT2: Reverse order of legend to match order of x-axis

2010-03-24 Thread Ryan Garner

Hah, my previous post was from my attempt on Windows Vista. It works fine on
Linux though.
-- 
View this message in context: 
http://n4.nabble.com/GGPLOT2-Reverse-order-of-legend-to-match-order-of-x-axis-tp1689526p1689997.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] Redhat Linux Install

2010-03-05 Thread Ryan Garner

I just installed R on Redhat Linux at work for the first time and have two
questions.

1. I tried to install R to have png and cairo capabilities and was
unsuccessful. Before running make, I ran ./configure --with-libpng=yes
--with-x=no --with-cairo=yes --with-readline-yes . R installed fine, but
when I run R and type capabilities()
 capabilities()
 jpeg pngtiff   tcltk X11   aqua   http/ftp 
sockets 
TRUE TRUE TRUE TRUEFALSEFALSE TRUE  TRUE 
  l  ibxmlfifo cledit iconv NLS  profmemcairo 
TRUEFALSE TRUE TRUE TRUE TRUEFALSE 

Why are png and cairo still FALSE?

2. I would also like to have X11 enabled. From reading the message board,
the consesus seems to be to install xorg-dev. I'm unable to do this because
I don't have root or super user priveleges. But if I'm able to log into my
work servers with PuTTY and Xming and run xemacs or xvim, does this mean
that X11 is already installed somewhere? If so, how do I specify this when
doing ./configure?

-- 
View this message in context: 
http://n4.nabble.com/Redhat-Linux-Install-tp1580181p1580181.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] ggsave in Linux

2010-02-24 Thread Ryan Garner

I have a script that creates a qplot that is then saved as a .png file which
works fine on Windows. But I also work on Linux servers via Putty and would
like to be able to create and save my plots to my working directory. Is
there a way I can ggsave my qplot without utilizing X11 in Linux? I don't
need to view the plot in Linux, I just want the plot created and immediately
saved to my working directory.

I get this error:
Error in grDevices::png(..., width = width, height = height, res = dpi,  :
  X11 is not available

-- 
View this message in context: 
http://n4.nabble.com/ggsave-in-Linux-tp1567860p1567860.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] Unordered Factors For ggplot?

2010-02-17 Thread Ryan Garner

I have data that comes into R already ordered. When I use ggplot, it orders
them which I don't want. How do I fix this without changing
options(contrast)?

The data I have is number of days:
30
29
...
20
19
...
10
9
...
1

When I plot with ggplot, it orders them by the first number only. So 3 ends
up coming before 29.
-- 
View this message in context: 
http://n4.nabble.com/Unordered-Factors-For-ggplot-tp1559146p1559146.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] ggplot stacked bar chart help

2010-02-05 Thread Ryan Garner

I'm trying to create a stacked bar chart with x=month, y=volume, and
factor=type.

volume   type   month
100A   SEP09
200A   OCT09
300A   DEC09
400B   SEP09
500B   OCT09
600B   DEC09
700C   SEP09
800C   OCT09
900C   DEC09

Following Hadley's examples, I get 3 bars with SEP09: 3-A, 3-B, 3-C, OCT09:
3-A, 3-B, 3-C, and NOV09: 3-A, 3-B, 3-C. I need SEP09: 100-A, 400-B, 700-C,
OCT09: 200-A, 500-B, 800-C, and NOV09: 300-A, 600-B, 900-C.
-- 
View this message in context: 
http://n4.nabble.com/ggplot-stacked-bar-chart-help-tp1470582p1470582.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.


Re: [R] ggplot stacked bar chart help

2010-02-05 Thread Ryan Garner

Almost there!

So my previous data example was just a small subset of my true data. I have
all the months from 2007-2009 in order. So when I create the barplot
following your script, it bins all 12 months for each year -- a stacked
barplot with 3 bars (2007,2008,2009), which I don't want. I want each month
to be a seperate bin. i.e. JAN07,FEB07,...,DEC09. Thanks for your help.

volume  type  month
100   A  JAN07
100   A  FEB07

100   A  DEC09
100   B  JAN07
100   B  FEB07

100   C  DEC09
100   C  JAN07
100   C  FEB07

100   C  DEC09
-- 
View this message in context: 
http://n4.nabble.com/ggplot-stacked-bar-chart-help-tp1470582p1470725.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.