Displaying 20 results from an estimated 7000 matches similar to: "Error in length of vector ?"
2007 Mar 07
2
No years() function?
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
2007 Feb 23
2
Google Custom Search Engine for R
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
2007 Jun 20
2
Averaging dates?
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
2007 Feb 15
3
Working with temporal data
Hi,
I have several files with data in this format:
20070102
20070102
20070106
20070201
...
The data is sorted and each line represents a date (YYYYMMDD). 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
2008 Jun 17
2
Measuring dispersion
Hi,
I'm looking for a function to measure the dispersion of a set of
values ranging from 0 to 1.
This function should be 0 if all the values are evenly spaced within
the interval and it should be > 0 if values are clustered.
The more clustered the values are, the higher should the function be.
An example:
[0; 0.2; 0.4; 0.6; 0.8; 1] - function should be ~ 0
[0; 0.1; 0.1; 0.15; 1] -
2005 Dec 13
4
Ploting graphics using X tints from a color
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
2007 Feb 16
1
Working with temporal data [Solved]
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",
2011 Aug 16
9
Rails Looping with different attributes
Hi Everyone,
I am trying to solve this problem, but couldn''t able to get the
solution. I hope i will get some help here.
I am using these three find methods to get different types of
devices. I dont have any relationships between any models.
windows_devices = BaseManagedEntity.find(:all,
:select => "b.BaseManagedEntityInternalId, c.NetworkName,
c.IPAddress,
2005 Dec 13
1
Manipulating matrices
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
2009 Jun 01
1
Bug in hist() when working with Dates ?
Hi,
It seems that hist() has a buggy behavior when breaking over "days".
The bug can be reproduced in a few steps:
> d=data.frame(date=c("2009-01-01", "2009-01-02", "2009-01-02"))
> d$date=as.Date(d$date)
> d$date
[1] "2009-01-01" "2009-01-02" "2009-01-02"
> h=hist(d$date, "days")
> h$count
[1] 3
2007 Jul 17
1
problem with length()
In the following, can anyone tell me why length(eee) returns 9? I
was expecting 15398, and when I try to add this vector to a data
frame with that many rows, it fails complaining that the vector is of
length 9. In what I thought was an identical situation with a
related dataset, the same code worked as expected.
> length(fff)
[1] 15398
> str(fff)
int [1:15398] 20010102 20010102
2009 Jan 28
2
length of POSIXlt object (PR#13482)
The length() of a POSIXlt object is given as 9 regardless of the actual
length. For example:
> make.date.time
function (year=c(2006,2006),month=c(8,8),day=2:5,hour=13,minute=45)
{# convert year, etc., into POSIXlt object
#
d=as.character(make.date(year,month,day))
t=paste(hour,minute,sep=":")
as.POSIXlt(paste(d,t))
}
> t=make.date.time()
> t
[1] "2006-08-02 13:45:00"
2005 Sep 28
1
Change console language ?
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
2009 Nov 19
6
Surprising length() of POSIXlt vector (PR#14073)
Arrays of POSIXlt dates always return a length of 9. This
is correct (they're really lists of vectors of seconds,
hours, and so forth), but other methods disguise them as
flat vectors, giving superficially surprising behaviour:
strings <- paste('2009-1-', 1:31, sep='')
dates <- strptime(strings, format="%Y-%m-%d")
print(dates)
# [1]
2006 Mar 06
1
Length of a vector of POSIX objects reported incorrectly?
I have a vector of POSIX times/dates (called "times") that I want to
plot. But I'm having trouble because R reports the length of the
vector incorrectly. Can someone help me figure out what's going on
here?
This code....
print(times)
print(class(times))
print(length(times))
Produces this...
.
.
.
[355] "2006-03-06 18:34:00" "2006-03-06 18:32:00"
2006 Sep 01
3
Date conversion with as.POSIXct and as.POSIXlt (PR#9196)
Full_Name: Erich Neuwirth
Version: 2.3.1
OS: Windows XP, Linux
Submission from: (NULL) (131.130.135.167)
Converting Sys.Date() to a POSIX compliant time type in different ways
produces inconsistent results:
> Sys.date()
[1] "2006-09-01"
> as.POSIXct(Sys.Date())
[1] "2006-09-01 02:00:00 CEST"
> as.POSIXlt(Sys.Date())
[1] "2006-09-01"
>
2011 Mar 24
5
subset and as.POSIXct / as.POSIXlt oddness
Dear R users,
Given this data:
x <- seq(1,100,1)
dx <- as.POSIXct(x*900, origin="2007-06-01 00:00:00")
dfx <- data.frame(dx)
Now to play around for example:
subset(dfx, dx > as.POSIXct("2007-06-01 16:00:00"))
Ok. Now for some reason I want to extract the datapoints between hours
10:00:00 and 14:00:00, so I thought well:
subset(dfx, dx >
2004 Oct 05
2
correct my method of estimating mean of two POSIXlt data frames
Hello, I searched the archives but could not come to a solution. I
have to two columns of information
t_start_cdt looks like:
> t_start_cdt[1:4]
[1] "2003-07-09 11:02:25" "2003-07-09 11:10:25" "2003-07-09 11:30:25"
[4] "2003-07-09 12:00:25"
> class(t_start_cdt)
[1] "POSIXt" "POSIXlt"
t_end_cdt looks like:
> t_end_cdt[1:4]
2002 Jul 02
1
POSIX formats have problems with NA (PR#1732)
# pure replication code at end
> # These work
>
> Sys.time() + NA
[1] NA
> as.POSIXlt(Sys.time(), "GMT") + NA
[1] NA
>
> class(Sys.time() + NA)
[1] "POSIXt" "POSIXct"
> class(as.POSIXlt(Sys.time(), "GMT") + NA)
[1] "POSIXt" "POSIXct"
>
> x <- Sys.time() + NA
> y <- as.POSIXlt(Sys.time(),
2009 Dec 22
1
as.Date function yields inconsistent results (PR#14166)
Full_Name: Mario Luoni
Version: 2.10.0
OS: Windows XP HE SP3
Submission from: (NULL) (217.194.59.134)
This piece of code:
zzz1 <- as.POSIXct("1999-03-18", tz="CET")
zzz2 <- as.POSIXlt("1999-03-18", tz="CET")
zzz1 == zzz2
as.Date(zzz1)
as.Date(zzz2)
yields TRUE for "zzz1==zzz2", but the two dates returned by as.Date are
different:
>