[R] Averaging dates?

2007-06-20 Thread Sérgio Nunes
Hi,

What's the best way to average dates?
I though mean.POISXct would work fine but...

 a
[1] 2007-04-02 19:22:00 WEST
 b
[1] 2007-03-17 16:23:00 WET
 class(a)
[1] POSIXt  POSIXct
 class(b)
[1] POSIXt  POSIXct
 mean(a,b)
[1] 2007-04-02 19:22:00 WEST
 mean(b,a)
[1] 2007-03-17 16:23:00 WET

?!

Thanks in advance for any advice,
--
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] No years() function?

2007-03-07 Thread Sérgio Nunes
Hi,

I'm trying to aggregate date values using the aggregate function. For example:

aggregate(data,by=list(weekdays(LM),months(LM)),FUN=length)

I would also like to aggregate by year but there seems to be no
years() function.
Should there be one? Is there any alternative choice?

Also, a hours() function would be great. Any tip on this?

Thanks in advance!
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error in length of vector ?

2007-03-02 Thread Sérgio Nunes
Hi,

I'm having a weird result with the length() function:

a
[... omited ...]
[9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00
[9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00
[1] NA

 length(LastModified)
[1] 9

 length(c(LastModified))
[1] 9

I was expecting to get 1 as an answer.
I'm trying to bind two vector, and I keep getting the error - number
of rows of result is not a multiple of vector length. Thus I tested
length and got this value.

Any hint?

Thanks in advance,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error in length of vector ?

2007-03-02 Thread Sérgio Nunes
Thanks. Using as.POSIXct() worked fine, length = 1.
Basically I cannot have a column of POSIXlt values in a matrix?

Sérgio Nunes

On 3/2/07, Petr Pikal [EMAIL PROTECTED] wrote:
 Hi

 you stepped on a difference between POSIXct and POSIXlt

 Details
 There are two basic classes of date/times. Class POSIXct represents
 the (signed) number of seconds since the beginning of 1970 as a
 ***numeric vector***. Class POSIXlt is a ***named list*** of
 vectors representing

 so you need to change your POSIXlt - named list to POSIXct by

 as.POSIXct(your vector)

 HTH
 Petr

 Maybe it could be useful to give some kind of warning into the help
 page of strptime e.g.

 Be aware of length of an objects created by strptime as POSIXlt
 class.  It is always 9. See Details section of  DateTimeClasses.


 On 2 Mar 2007 at 12:33, Sérgio Nunes wrote:

 Date sent:  Fri, 2 Mar 2007 12:33:46 +
 From:   Sérgio Nunes [EMAIL PROTECTED]
 To: r-help@stat.math.ethz.ch
 Subject:[R] Error in length of vector ?

  Hi,
 
  I'm having a weird result with the length() function:
 
  a
  [... omited ...]
  [9994] NA2003-12-03 16:37:00 2002-06-26
  18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00
  2007-02-24 15:49:00 [1] NA
 
   length(LastModified)
  [1] 9
 
   length(c(LastModified))
  [1] 9
 
  I was expecting to get 1 as an answer.
  I'm trying to bind two vector, and I keep getting the error - number
  of rows of result is not a multiple of vector length. Thus I tested
  length and got this value.
 
  Any hint?
 
  Thanks in advance,
  Sérgio Nunes
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html and provide commented,
  minimal, self-contained, reproducible code.

 Petr Pikal
 [EMAIL PROTECTED]



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Google Custom Search Engine for R

2007-02-23 Thread Sérgio Nunes
Hi,

Since R is a (very) generic name, I've been having some trouble
searching the web for this topic. Due to this, I've just created a
Google Custom Search Engine that includes several of the most relevant
sites that have information on R.

See it in action at:

http://google.com/coop/cse?cx=018133866098353049407%3Aozv9awtetwy

This is really a preliminary test. Feel free to add yourself to the
project and contribute with suggestions.

Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Google Custom Search Engine for R

2007-02-23 Thread Sérgio Nunes
Hi,

I've just created this search engine for testing today.
I think that if you volunteer as a contributor (see link on the left
side) you can then see and add to the list of sites.

I've also noticed that I can add sites by importing a XML file.
Is there any list of sites that could be easily converted to XML?

Sérgio Nunes

On 2/23/07, Matthew Keller [EMAIL PROTECTED] wrote:
 Hi Sergio,

 There was a discussion on this board recently about the difficulty of
 searching for R related material on the web. I think the custom
 google search engine is a good idea. It would be helpful if we could
 have access to the full list of websites it is indexing so that we
 could make suggestions about other sites that are missing. As it is,
 it only tells us that there are 35 websites, and shows us the first
 several.

 Also, you might check out Sasha Goodman's Rseek: http://www.rseek.org/

 Have you tried to compare the success of yours with Rseek?

 All the Best,

 Matt

 On 2/23/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
  Hi,
 
  Since R is a (very) generic name, I've been having some trouble
  searching the web for this topic. Due to this, I've just created a
  Google Custom Search Engine that includes several of the most relevant
  sites that have information on R.
 
  See it in action at:
 
  http://google.com/coop/cse?cx=018133866098353049407%3Aozv9awtetwy
 
  This is really a preliminary test. Feel free to add yourself to the
  project and contribute with suggestions.
 
  Sérgio Nunes
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


 --
 Matthew C Keller
 Postdoctoral Fellow
 Virginia Institute for Psychiatric and Behavioral Genetics


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Google Custom Search Engine for R

2007-02-23 Thread Sérgio Nunes
I just seen the link you suggested - RSeek - and it uses exactly the
same service from Google. The only difference is that it is not open
to new contributions. Maybe Sasha could open it to volunteers.

Also it seems to be much more complete than my initial attempt (as expected :).
I think that RSeek deserves a link in R's homepage.

Sérgio Nunes

On 2/23/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
 Hi,

 I've just created this search engine for testing today.
 I think that if you volunteer as a contributor (see link on the left
 side) you can then see and add to the list of sites.

 I've also noticed that I can add sites by importing a XML file.
 Is there any list of sites that could be easily converted to XML?

 Sérgio Nunes

 On 2/23/07, Matthew Keller [EMAIL PROTECTED] wrote:
  Hi Sergio,
 
  There was a discussion on this board recently about the difficulty of
  searching for R related material on the web. I think the custom
  google search engine is a good idea. It would be helpful if we could
  have access to the full list of websites it is indexing so that we
  could make suggestions about other sites that are missing. As it is,
  it only tells us that there are 35 websites, and shows us the first
  several.
 
  Also, you might check out Sasha Goodman's Rseek: http://www.rseek.org/
 
  Have you tried to compare the success of yours with Rseek?
 
  All the Best,
 
  Matt
 
  On 2/23/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
   Hi,
  
   Since R is a (very) generic name, I've been having some trouble
   searching the web for this topic. Due to this, I've just created a
   Google Custom Search Engine that includes several of the most relevant
   sites that have information on R.
  
   See it in action at:
  
   http://google.com/coop/cse?cx=018133866098353049407%3Aozv9awtetwy
  
   This is really a preliminary test. Feel free to add yourself to the
   project and contribute with suggestions.
  
   Sérgio Nunes
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 
  --
  Matthew C Keller
  Postdoctoral Fellow
  Virginia Institute for Psychiatric and Behavioral Genetics
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Working with temporal data

2007-02-16 Thread Sérgio Nunes
Hi again,

I'm still trying to read my data but I'm having some difficulties
converting it to dates.
My data file has lines and in each line a single date exists in the
format 2007/02/16 (without the ,). I've tried the following:

 d - readLines(file.dat)
 d
[1] 2006/08/09 2004/02/11 2004/06/09 ...
[2] ...

 d2 - as.Date(d, format=%Y/%m/$d)
 d2
[1] NA NA NA ...
...

I'm surely doing something wrong.
Any advice would be welcomed.

Thanks!
Sérgio Nunes

On 2/15/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
 Hi,

 I have several files with data in this format:

 20070102
 20070102
 20070106
 20070201
 ...

 The data is sorted and each line represents a date (MMDD). I would
 like to analyze this data using R. For instance, I would like to have
 a histogram by year, month or day.

 I've already made a simple Perl script that aggregates this data but I
 believe that R can be much more powerful and easy on this kind of
 work.

 Any suggestions on where to start?

 Thanks in advance,
 Sérgio Nunes


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Working with temporal data [Solved]

2007-02-16 Thread Sérgio Nunes
Just for the record, here are my steps for producing a date based histogram.
Data is stored in a file where each line only has a date - 2007/02/16

d-readLines(filename.dat)
d-as.Date(d, format=%Y/%m/%d)
pdf(yearly.pdf)
hist(d, years)
dev.off()

Instead of years you can also use days, weeks, months, secs,
mins, hours.

One final question, how could I easily filter my dataset if, for
instance, I only wanted to see results from 2006 ?

Thanks to all who helped,
Sérgio Nunes

On 2/15/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
 Hi,

 I have several files with data in this format:

 20070102
 20070102
 20070106
 20070201
 ...

 The data is sorted and each line represents a date (MMDD). I would
 like to analyze this data using R. For instance, I would like to have
 a histogram by year, month or day.

 I've already made a simple Perl script that aggregates this data but I
 believe that R can be much more powerful and easy on this kind of
 work.

 Any suggestions on where to start?

 Thanks in advance,
 Sérgio Nunes


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Working with temporal data

2007-02-15 Thread Sérgio Nunes
Hi,

I have several files with data in this format:

20070102
20070102
20070106
20070201
...

The data is sorted and each line represents a date (MMDD). I would
like to analyze this data using R. For instance, I would like to have
a histogram by year, month or day.

I've already made a simple Perl script that aggregates this data but I
believe that R can be much more powerful and easy on this kind of
work.

Any suggestions on where to start?

Thanks in advance,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Working with temporal data

2007-02-15 Thread Sérgio Nunes
Please note that I do not have values, only dates that represent
occurrences (one link, one date, one occurrence). This means that the
same date might appear several times in different rows. Nevertheless,
I think I can manage this based on your samples.

Thanks,

Sérgio Nunes


On 2/15/07, jim holtman [EMAIL PROTECTED] wrote:
 Here is a start on what you want to do.  This generates some test data and
 then does a couple of summaries:



  # generate some data
  N - 1000
  x - data.frame(date=as.character(2007 + sample(1:4, N, TRUE) * 100 +
 sample(1:31, N, TRUE)),
 + value=runif(N))
  head(x)  # display the data
date  value
 1 20070124 0.07904540
 2 20070117 0.17864565
 3 20070109 0.86078870
 4 20070205 0.93952259
 5 20070112 0.87904425
 6 20070323 0.01717623
  # assuming you read it in as character, convert to Date for processing
  x$date - as.Date(strptime(x$date, %Y%m%d))
  x - x[order(x$date), ] # order by date for plotting
  plot(x$date, x$value, type='l')   # plot the data
  # show counts by month
  table(months(x$date))

April February  JanuaryMarch
  238  236  253  237
  # average by month
  aggregate(x$value, list(months(x$date)), mean)
Group.1 x
 1April 0.4791387
 2 February 0.5010831
 3  January 0.5114135
 4March 0.4695668
 



 On 2/15/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
 
  Hi,
 
  I have several files with data in this format:
 
  20070102
  20070102
  20070106
  20070201
  ...
 
  The data is sorted and each line represents a date (MMDD). I would
  like to analyze this data using R. For instance, I would like to have
  a histogram by year, month or day.
 
  I've already made a simple Perl script that aggregates this data but I
  believe that R can be much more powerful and easy on this kind of
  work.
 
  Any suggestions on where to start?
 
  Thanks in advance,
  Sérgio Nunes
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Ploting graphics using X tints from a color

2005-12-13 Thread Sérgio Nunes
Hi,

I'm trying to draw a 2D plot using multiple tints of red. The
(simplified) setup is the following: || year | x | y ||

My idea is that each year is plotted with a different tint of red.
Older year (lightest) - Later year (darkest). I've managed to plot
this with different scales of grays simply by doing:

palette(gray(length(years):0/length(years)))

before the plot and for each year the color used is a different tint of gray.

So, is there any way to do this for any color?
Any tip or advice?

With this, I hope to visualize patterns in my dataset more easily.

Thanks in advance for any help.

Best regards,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Manipulating matrices

2005-12-13 Thread Sérgio Nunes
Hi,

I'm pretty new to R and I've been having some problems filtering data
in matrices.

I have the following initial dataset:

|| year | name | varA ||

I have multiple values for varA for the same year and the same name.
Having this as the input I would like to obtain the following:

|| year | name | {varA mean} ||

Where I only have one line for each year and name with the mean of
the values of varA in varA mean.

Is there a simple way to achieve this without using control structures
(for or while cycles)?

Thanks in advance for any help.

Best regards,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Simplifying matrices ?

2005-12-13 Thread Sérgio Nunes
Hi again,

the previous answers were great. I was able to do what was planned.
Now, I would like to do the following to a matrix:

|| year | event | team | total ||

where I can have multiple event per team, but each team only has
a year and a total. Thus, this table has multiple lines for the
same team where only the event changes.
Considering this, how can I output this:

|| year | team | total ||

where each team occurs only once, and the event was discarded.

Hope I made myself clear.
Thanks in advance.

This is a great mailing list.

Regards,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Change console language ?

2005-09-28 Thread Sérgio Nunes
Hi,

I'm pretty new to R, I've just installed version 2.1.1 on Windows.
I have a simple (it seems) doubt - how do I change the Console default
Language ?

It's set to Portuguese but I would like to view it in English.

Thanks in advance,
Sérgio Nunes

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html