[R] very beginner's question

2009-12-27 Thread Facetious Nickname

Begging the list's indulgence, an extremely dumb beginner's question.  I've got 
24 months' worth of numbers - ranging from 2 events per month, to 66 events per 
month.  I want to take a stab at making a reasonable guess as to what the next 
year's data would be, approximately, i.e., based on the 24 months I've got, I 
want to be able to tell someone: the 12 months after this will probably 
average about $number of events per month.  Assuming I'm able to navigate R 
with a minimum degree of proficiency, where would I start with this?  As you 
can doubtless tell, I'm not looking for anything sophisticated - just a 
reasonable estimate.  Am I going to be able to do better than a projected 
per-month guess based on $total/$number_of_months?

Thanks very much -
  
_
Hotmail: Trusted email with powerful SPAM protection.

[[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] very beginner's question

2009-12-27 Thread Gabor Grothendieck
See ?ets in the forecast package.


On Sun, Dec 27, 2009 at 2:51 PM, Facetious Nickname
facetious_nickn...@hotmail.com wrote:

 Begging the list's indulgence, an extremely dumb beginner's question.  I've 
 got 24 months' worth of numbers - ranging from 2 events per month, to 66 
 events per month.  I want to take a stab at making a reasonable guess as to 
 what the next year's data would be, approximately, i.e., based on the 24 
 months I've got, I want to be able to tell someone: the 12 months after this 
 will probably average about $number of events per month.  Assuming I'm able 
 to navigate R with a minimum degree of proficiency, where would I start with 
 this?  As you can doubtless tell, I'm not looking for anything sophisticated 
 - just a reasonable estimate.  Am I going to be able to do better than a 
 projected per-month guess based on $total/$number_of_months?

 Thanks very much -

 _
 Hotmail: Trusted email with powerful SPAM protection.

        [[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.


[R] A beginner's question about ggplot

2009-05-01 Thread MUHC-Research

Dear R-users,

I would have another question about the ggplot() function in the ggplot2
package.

All the examples I've read so far in the documentation make use of a single
neatly formatted data.frame. However, sometimes, one may be interested in
plotting on the same grid information or objects derived from two totally
different datasets and customize both displays. I still cannot tell how this
can be done using ggplot().

Here's an example.

###
## A very simple data.frame;

my.data = data.frame(X1 =
as.factor(rep(1:2,c(4,4))),X2=c(4,3,5,2,6,2,3,5),X3=c(1:3,2,2:4,5)) ;

## Let's say I want to add the X^2 line to the plot;

squared = data.frame(X=1:12,Y=((1:12)/2)^2) ;

## A scatterplot for my.data ;

p = ggplot(my.data,aes(x=X2,y=X3,group=X1)) ;
p = p+geom_point(aes(colour=X1)) ; 

#

How can squared be added to the plot? At first, I used

p+geom_line(data=squared,aes(x=X,y=Y,group=1,colour=green)) ;

but the plotted line is always blue! In fact, I can replace colour by any
character value and I will still get a blue line.

Although I may be wrong, I think this is pretty straightforward. Can anyone
give me a pointer as to how we can add arbitrary curves to a ggplot graph
and then customize them? A bit later, I'll have to overlay histograms
derived from totally different datasets and, if possible, I'd like to use
the ggplot2 library for that too, hence the importance of understanding how
ggplot objects can be mixed.

Thanks a lot,

Luc
-- 
View this message in context: 
http://www.nabble.com/A-beginner%27s-question-about-ggplot-tp23336793p23336793.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] A beginner's question about ggplot

2009-05-01 Thread hadley wickham
On Fri, May 1, 2009 at 12:22 PM, MUHC-Research
villa...@dms.umontreal.ca wrote:

 Dear R-users,

 I would have another question about the ggplot() function in the ggplot2
 package.

 All the examples I've read so far in the documentation make use of a single
 neatly formatted data.frame. However, sometimes, one may be interested in
 plotting on the same grid information or objects derived from two totally
 different datasets and customize both displays. I still cannot tell how this
 can be done using ggplot().

 Here's an example.

 ###
 ## A very simple data.frame;

 my.data = data.frame(X1 =
 as.factor(rep(1:2,c(4,4))),X2=c(4,3,5,2,6,2,3,5),X3=c(1:3,2,2:4,5)) ;

 ## Let's say I want to add the X^2 line to the plot;

 squared = data.frame(X=1:12,Y=((1:12)/2)^2) ;

 ## A scatterplot for my.data ;

 p = ggplot(my.data,aes(x=X2,y=X3,group=X1)) ;
 p = p+geom_point(aes(colour=X1)) ;

 #

 How can squared be added to the plot? At first, I used

 p+geom_line(data=squared,aes(x=X,y=Y,group=1,colour=green)) ;

 but the plotted line is always blue! In fact, I can replace colour by any
 character value and I will still get a blue line.

You have two alternatives:

p + geom_line(data=squared,aes(x=X,y=Y,group=1,colour=squared)) +
  labs(colour = Dataset)

p + geom_line(data=squared,aes(x=X,y=Y,group=1), colour=green)

see section 4.5.2 of the book for details.

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A beginner's question

2009-03-27 Thread minben
I am a new R-language user. I have set up a data frame mydata,one of
the colume of which is skill. Now I want to select the observations
whose skill value is equal to 1,by what command can I get it?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 beginner's question

2009-03-27 Thread Coen van Hasselt
Here's an example:

mydata-data.frame(skill=c(1,2,3,4),x=c(1,1,1,1))
mydata[mydata$skill==1,]


On Fri, Mar 27, 2009 at 16:40, minben minb...@gmail.com wrote:
 I am a new R-language user. I have set up a data frame mydata,one of
 the colume of which is skill. Now I want to select the observations
 whose skill value is equal to 1,by what command can I get it?

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 beginner's question

2009-03-27 Thread K. Elo
Hi,

minben wrote:
 I am a new R-language user. I have set up a data frame mydata,one of
 the colume of which is skill. Now I want to select the observations
 whose skill value is equal to 1,by what command can I get it?

Try this:
mydata1-mydatasubset(mydata, skill==1)

Maybe You should also read this introduction:
http://cran.r-project.org/doc/manuals/R-intro.pdf


Kind regards,
Kimmo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 beginner's question

2009-03-27 Thread Florin Maican

You can do like this:

1.
mydata[mydata$skill==1,]

2. 
   mydata[mydata[,skill]==1,]
  
/Forin


On Thu, 26 Mar 2009 23:40:32 -0700 (PDT)
minben minb...@gmail.com wrote:

 I am a new R-language user. I have set up a data frame mydata,one of
 the colume of which is skill. Now I want to select the observations
 whose skill value is equal to 1,by what command can I get it?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.
 


-- 
 Florin G. Maican
==

Ph.D. candidate,
Department of Economics,
School of Business, Economics and Law, 
Gothenburg University, Sweden   
---
P.O. Box 640 SE-405 30, 
Gothenburg, Sweden  

 Mobil:  +46 76 235 3039 
 Phone:  +46 31 786 4866 
 Fax:+46 31 786 4154  
 Home Page: http://maicanfg.googlepages.com/index.html
 E-mail: florin.mai...@handels.gu.se 

 Not everything that counts can be 
 counted, and not everything that can be 
 counted counts.
 --- Einstein ---

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 beginner's question

2009-03-27 Thread Paul Hiemstra

minben schreef:

I am a new R-language user. I have set up a data frame mydata,one of
the colume of which is skill. Now I want to select the observations
whose skill value is equal to 1,by what command can I get it?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  

To add the number of possibilities :):

subset(mydata, skill == 1)

cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.