Re: [R] uneven vector length issue with read.zoo?

2012-05-06 Thread knavero
For simplicity sake though, yes I understand the issue and solution, and the
solution using read.table, na.omit, and read.zoo is sound. Thanks Gabor! :)

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4613983.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] uneven vector length issue with read.zoo?

2012-05-06 Thread knavero
Yeah, I was unclear about what I mean by "uneven vector lengths". I should
say "uneven valid vectors" instead where "valid" refers to (1) a field
containing a value that is not NA, for this specific case, and (2) a value
that is compatible with the vector class assigned through colClasses etc.,
and therefore avoids the read.zoo error. I understand and agree that the
error is clear. I have no issue with that. My issue is with the need to use
read.table and then read.zoo shortly after (this seems inefficient).

I was simply pushing toward the idea of where this type of situation could
be avoided for future users in where if there are uneven valid vectors that
there would be a logical argument saying that it's okay to truncate to the
shortest valid vector (in this case columns 1 and 2). My raw data consisted
of a lot of uneven valid vectors. My expected thought of nulling out columns
3:5 would be that there would have no need for read.zoo to try to read in
the bad data entry rows in columns 1:2 containing NA's that's already
outside of the valid vector length.

Anyway, this is probably trivial now considering that this problem is
already solved haha, and also I don't mean to offend and criticize. I simply
see an efficiency opportunity and an opportunity to create more robust
source code. Why use read.table with read.zoo if you can just do it all with
read.zoo? Do you not agree?

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4613975.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] uneven vector length issue with read.zoo?

2012-05-06 Thread knavero
Right, but it seems to me that the error being the NA's in the index field
are caused by the longer vector lengths of columns 4 and 5. I would think
that the EOF in the scanf() (assuming C is used for the source code) would
be called where the NA's begin in columns 1 and 2 since columns 3:5 are
nulled out. Does this sound like a possible case?

So, if the read in data only contained columns 1 and 2, it wouldn't even
look at columns 3:5 and thus, rows 14 and so on wouldn't even be looked at
and that would be EOF already - resulting in no error. 

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4613384.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] uneven vector length issue with read.zoo?

2012-05-04 Thread knavero
"However, I do wonder why it still complains of the vector length even though
I nulled out the other columns. It's an interesting error to run into.
Probably looks at FUN before nulling out the other columns was my theory. "

Referring to just a straight up read.zoo in this case ^

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4609509.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] uneven vector length issue with read.zoo?

2012-05-04 Thread knavero
Hey Gabor, just trying to understand this here..sorry for the noob question:

DF1 <- read.table(URL, skip = 1, header = TRUE, sep = ",", fill = TRUE,
  as.is = TRUE) 

I'm not to familiar with as.is, however I quickly read the R documentation
on that. From my understanding it converts character to factor in terms of
atomic vector class/mode...sorta like what colClasses would do. Why is it
needed here for this specific case?

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4609382.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] uneven vector length issue with read.zoo?

2012-05-04 Thread knavero
Thank you for the suggestion Gabor. It's definitely more elegant than what I
had above. Instead of going from character representation to POSIXct to
chron, it looks at the character representation and goes straight to chron.
It's good. However, I do wonder why it still complains of the vector length
even though I nulled out the other columns. It's an interesting error to run
into. Probably looks at FUN before nulling out the other columns was my
theory.

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4609468.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
So with case (6) here's the general structure of what I have:

chw = read.table("crac.csv", skip = 1, header = TRUE,
   colClasses = rep(c("NULL", NA, "numeric", "NULL"),
  c(3, 1, 1, 24)),
   sep = ",")
chw$Time.1 = as.POSIXct(chw$Time.1, format = fmt, tz = TZ)
chw = na.omit(chw)
chw = read.zoo(chw, header = TRUE,
   colClasses = rep(c(NA, "numeric"), c(1, 1)),
   FUN = chr, aggregate = tail1)

You don't have to try this, but the main point is that 

read.table -> POSIXct -> na.omit -> read.zoo and chron

I guess this alternative solution is adequate along with using readLines.
Initially I was hoping just a simple read.zoo would do the trick. The catch
is that I need the index/timestamp column to be in chron format for an easy
na.approx function to deal with things. Thank you for the readLines
suggestion Rui. Much appreciated.

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604841.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
case (6) - regress back to read.table apparently

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604537.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
blank.lines.skip is not working either...

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604360.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
Actually case (4) didn't work. The issue is also with the index.."fill" only
seems to work with the dimensions/columns that contain the data associated
to the index. Dang.yeah, I need help here.

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604349.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
Case (4) - use the fill argument in ?read.tablethis looks useful...guess
I answered my own question...going to delete this thread now...

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604332.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
So far I see two options: (1) nrows argument to specify max number of rows to
read in or (2) go into excel, and put a bunch of NA's . Both which are
inefficient in that they're not so "automated".  For case (1), I have to
wait till an error pops up each time and deal with each one individually
taking into account the skip and header args, and for case (2), now I'm just
not even using R to do the dirty work...anyway, I'm going to continue to go
through this R documentation to see if I find anything else for ?read.table
and ?read.zoo.  

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604323.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
Make that 3 options actually. In case (3) I would have to take each category
on the spreadsheet and isolate each to its own csv file using excel. Fun
stuff...

--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287p4604329.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] uneven vector length issue with read.zoo?

2012-05-02 Thread knavero
I truncated and simplified my code and the read in data that I'm working with
to isolate the issue. Here is the read in data and R script respectively:

http://r.789695.n4.nabble.com/file/n4604287/test.csv test.csv 

http://pastebin.com/rCdaDqPm

Here is the terminal/R shell output that I hope the above replicates on your
screen:
> source("elecLoad.r", echo = TRUE)

> #Load packages
> library(zoo)

> library(chron)

> #Initial assignments for format (fmt), timezone (TZ), and user 
> #defined chron function (chr)
> fmt = "%m/%d/%y %I:%M %p"

> TZ = "PDT"

> chr = function(x) as.chron(x, fmt)

> #Read in data as zoo object using relevant arguments in read.zoo()
> #for details of arguments, see Kevin Navero or see ?read.zoo
> #and ?read.table  [TRUNCATED] 
Error in read.zoo("http://dl.dropbox.com/u/41922443/test.csv";, skip = 1,  : 
  index has bad entries at data rows: 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28

I was hoping that the "NULL" in colClasses() would've taken care of this
uneven vector length issue, however, that was not the case. Any ideas?
Thanks in advance. Sorry if my post didn't follow the forum rules exactly. I
tried to make small scale reproducible code and what not. I'm still a bit of
a noob here and there.



--
View this message in context: 
http://r.789695.n4.nabble.com/uneven-vector-length-issue-with-read-zoo-tp4604287.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] simple read in with zoo using POSIXlt

2012-04-15 Thread knavero
Thanks Gabor. Much appreciated.

--
View this message in context: 
http://r.789695.n4.nabble.com/simple-read-in-with-zoo-using-POSIXlt-tp4557138p4559762.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] simple read in with zoo using POSIXlt

2012-04-15 Thread knavero

Achim Zeileis-4 wrote
> 
> I don't know why you make this so complicated. Either use
> 
> read.zoo("test.txt", header = FALSE, sep = "\t",
>format = "%d/%m/%Y %H:%M", tz = "")
> 
> which yields a POSIXct time index. Alternatively, you can produce POSIXlt 
> via strptime:
> 
> read.zoo("test.txt", header = FALSE, sep = "\t",
>FUN = function(x) strptime(x, "%d/%m/%Y %H:%M"))
> 
> The former is recommended for use in zoo.
> 

Sorry, it's not that I'm trying to make it complicated, but rather specific.
As Gabor said in the earlier post, it seems POSIXlt is not a suitable
argument for read.zoo, and therefore explains the problem that I have been
having. Like I said, I was able to produce the solution that I wanted;
however, it was not as efficient and elegant as I was hoping it to be. When
going through 2 year span data sets, there is a noticeable difference in
speed when you use POSIXlt separately outside the read.zoo function. Anyway,
it's fine. I appreciate the feedback and suggestion. It definitely helps
bounce ideas around and possibly offers ways to expand R source code in the
future maybe. Thanks!


--
View this message in context: 
http://r.789695.n4.nabble.com/simple-read-in-with-zoo-using-POSIXlt-tp4557138p4559760.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] simple read in with zoo using POSIXlt

2012-04-14 Thread knavero

Achim Zeileis-4 wrote
> 
> You just need to declare that the index is in two columns (1 and 2) and 
> then provide a function that extracts a suitable object from it:
> 
> read.zoo("test.txt", header = FALSE, index = 1:2,
>FUN = function(x, y) strptime(paste(x, y), "%d/%m/%Y %H:%M"))
> 
> Use an additional as.POSIXct(...) around the strptime() call if you want 
> to use POSIXct instead of POSIXlt which is typically recommended.
> 
> See vignette("zoo-read", package = "zoo") for more examples.
> Z
> 

Unfortunately, it's not working as I hoped for. Let me elaborate,

new code:

http://pastebin.com/axpPB6M8

So for this, I understand that the read in works very well with POSIXct, but
I want to utilize the vectors contained with the POSIXlt class (wday, yday,
mon, etc.). Here's how the POSIXct read.zoo looks like in the shell when
copy pasted:

> test = read.zoo("http://dl.dropbox.com/u/41922443/test.txt";, 
+header = FALSE, sep = "\t",
+FUN = function(idx) as.POSIXct(strptime(idx, 
+   format = fmt, tz = "PDT"), format = fmt, tz = "PDT"),
+colClasses = rep(c(NA, "numeric", "NULL"), c(1, 1, 0)),
+aggregate = tail1)
> test
2010-01-07 00:15:00 2010-01-07 00:30:00 2010-01-07 00:45:00 2010-01-07
01:00:00 
   1333.6201333.3881335.343   
1334.251 
2010-01-07 01:15:00 2010-01-07 01:30:00 2010-01-07 01:45:00 2010-01-07
02:00:00 
   1331.5891328.6951329.151   
1329.077 
2010-01-07 02:15:00 2010-01-07 02:30:00 
   1327.6491326.789 

This is good when you just eyeball it, HOWEVER, when the date/time is looked
at by the machine, it doesn't see vectors that can be accessed, but the lame
numerical/double that is the UTC time from 1960 or whatever in seconds.
Proof of this is the following:

> unclass(index(test))
 [1] 1262823300 1262824200 1262825100 1262826000 1262826900 1262827800
 [7] 1262828700 1262829600 1262830500 1262831400
attr(,"tzone")
[1] "PDT"

Now with this code:

http://pastebin.com/pr2X78sX

This just pisses me offlet me elaborate...or well, eff it. I'll just
copy paste and you'll get my point:

> test = read.zoo("http://dl.dropbox.com/u/41922443/test.txt";, 
+header = FALSE, sep = "\t",
+FUN = function(idx) as.POSIXlt(strptime(idx, 
+   format = fmt, tz = "PDT"), format = fmt, tz = "PDT"),
+colClasses = rep(c(NA, "numeric", "NULL"), c(1, 1, 0)),
+aggregate = tail1)
> test
   0 
1326.789 

Basically, what the hell is 0 and 1326.789 doing there?.right? 


--
View this message in context: 
http://r.789695.n4.nabble.com/simple-read-in-with-zoo-using-POSIXlt-tp4557138p4558038.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] simple read in with zoo using POSIXlt

2012-04-14 Thread knavero

Achim Zeileis-4 wrote
> 
> You just need to declare that the index is in two columns (1 and 2) and 
> then provide a function that extracts a suitable object from it:
> 
> read.zoo("test.txt", header = FALSE, index = 1:2,
>FUN = function(x, y) strptime(paste(x, y), "%d/%m/%Y %H:%M"))
> 
> Use an additional as.POSIXct(...) around the strptime() call if you want
> to use POSIXct instead of POSIXlt which is typically recommended. 
> 

Ah I see. Yeah I'm familiar with the index = 1:2 argument of read.zoo.
However, I'm not sure if it's necessary here since I'm specifying one of the
arguments to be sep = "\t", and thus it sees one timestamp column as
"%m/%d/%Y %H:%M" format and the second column, being the data column,
separated via tab. So I'll try using strptime() and POSIXlt() on that column
as FUN = function(idx) as.POSIXlt(strptime(idx, format = "%m/%d/%Y %H:%M",
tz = "PDT")).

The reason I plan on using POSIXlt here as opposed to POSIXct is for
functionality reasons such that the class itself contains a list of vectors
that can be accessed i.e. sec, min, hour, ...wday, yday, etc. I'll post the
results in a few mins after testing it out on the shell here. Thanks for the
suggestion!!!  

--
View this message in context: 
http://r.789695.n4.nabble.com/simple-read-in-with-zoo-using-POSIXlt-tp4557138p4557990.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] simple read in with zoo using POSIXlt

2012-04-14 Thread knavero
Easy question a bit. So here's my code:

http://pastebin.com/F4iQPVy5

I am trying to read in a series of timestamps. However with POSIXlt as FUN
in read.zoo, the output is merely two numbers and is not the output that I'm
hoping for. The code above should reproduce the error.

Here is code that shows what I want it to do:

http://pastebin.com/GEPZ5R9B

The problem though, is that it's not that elegant since POSIXlt is outside
of read.zoo. Wondering if there's a way to put POSIXlt inside read.zoo and
compress things a bit to make the code run faster. Any ideas? Thanks.

Also, if there's any issues reading the file i uploaded to dropbox directly
off of the net with the code above, just use this:

http://r.789695.n4.nabble.com/file/n4557138/test.txt test.txt 

Hope I covered everything in a compact reproducible manner. Sorry if I made
a noob mistake. Still kind of new.

--
View this message in context: 
http://r.789695.n4.nabble.com/simple-read-in-with-zoo-using-POSIXlt-tp4557138p4557138.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] Trying to merge new data set to bottom of old data set. Both are zoo objects.

2012-04-04 Thread knavero
Okay, will do. Thanks for all the handy advice Gabor. Ugh, it's such a stupid
bug once I actually know what is going on. I need to go over my Unix
date/time format specifiers, and I'll probably use the rep function to
simplify and reducing the amount of code. A lot of that is definitely new to
me. As for shortening the read in data, I do it find it tricky sometimes
since you have to incrementally test it in the sense that you want to
shorten it to the point that it still reproduces the problem. Anyway, I'll
try to make the data significantly shorter in my next post if possible.
Thanks again.

--
View this message in context: 
http://r.789695.n4.nabble.com/Trying-to-merge-new-data-set-to-bottom-of-old-data-set-Both-are-zoo-objects-tp4530888p4532484.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] Trying to merge new data set to bottom of old data set. Both are zoo objects.

2012-04-03 Thread knavero
Here's a case where it doesn't work. Again, the problem is that when I use
the rbind or concatenate functions, the 2012 data set seems to go ahead of
the 2010 and 2011 portions of the data set. The problem seems dependent on
the text files I read in:

http://r.789695.n4.nabble.com/file/n4531011/old.txt old.txt 

http://r.789695.n4.nabble.com/file/n4531011/new.txt new.txt 

using this code:

http://pastebin.com/8W6KaaPQ

In a case where it works, and the data seemed to be in the right order, I
read in a different old.txt named old1.txt and somehow it seemed to work.
The contents and format were similar to that of new.txt where there was 18
columns with the same headers. Here are the files to use:

http://r.789695.n4.nabble.com/file/n4531011/old1.txt old1.txt 

http://r.789695.n4.nabble.com/file/n4531011/new.txt new.txt 

using this code:

http://pastebin.com/6iNF5bPd

That should clarify the issue I'm having. Let me know if a dput is necessary
here. However all the vectors and vector modes seem to check out okay.  



--
View this message in context: 
http://r.789695.n4.nabble.com/Trying-to-merge-new-data-set-to-bottom-of-old-data-set-Both-are-zoo-objects-tp4530888p4531011.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] Trying to merge new data set to bottom of old data set. Both are zoo objects.

2012-04-03 Thread knavero
Here is the data I'm working with:

http://r.789695.n4.nabble.com/file/n4530888/new.txt new.txt 

http://r.789695.n4.nabble.com/file/n4530888/old.txt old.txt 

My code is here:

http://pastebin.com/9jjs6Ahr

I'm looking for away to simply attach the new.txt to the bottom of old.txt
through R, else I'll just throw it in Excel to do some preprocessing. I've
looked into using merge, cbind, concatenate, and rbind. However, I'm running
into problems where the 2012 data keeps ending up on top before the 2010 and
2011 data or the function just adds more extra columns to the right side. Is
there a simple method of doing this? Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/Trying-to-merge-new-data-set-to-bottom-of-old-data-set-Both-are-zoo-objects-tp4530888p4530888.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] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread knavero
Ah yes, sorry about that Gabor. Found a pretty good example in ?read.zoo
where it has index = 1:3 and takes in times objects. I must have overlooked
it out of impatience. Thanks for the quick and simple feedback however.

--
View this message in context: 
http://r.789695.n4.nabble.com/read-zoo-combining-two-columns-with-date-and-time-respectively-into-one-index-column-tp4495326p4496743.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] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread knavero
I actually just found an alternative solution which involves setting Excel's
or Libre Office Calc's fixed width option then saving it again as a .txt or
.csv. If there's a cleaner way of doing this within the R shell, I'm open to
ideas.

--
View this message in context: 
http://r.789695.n4.nabble.com/read-zoo-combining-two-columns-with-date-and-time-respectively-into-one-index-column-tp4495326p4495345.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] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread knavero
I have three columns in my raw data: date, time, and dry bulb temperature:

http://r.789695.n4.nabble.com/file/n4495326/weathDataSDCoron.txt
weathDataSDCoron.txt 

The date format is %Y%m%d and the time format is %H:%M. Any ideas on how to
read it in such that it looks at the first two columns and then merges it
into one column combining both the date and time? 

--
View this message in context: 
http://r.789695.n4.nabble.com/read-zoo-combining-two-columns-with-date-and-time-respectively-into-one-index-column-tp4495326p4495326.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] Wrong output due to what I think might be a data type issue (zoo read in problem)

2012-03-20 Thread knavero
Ah I see. Thank you very much Gabor and Joshua. Yes that makes sense since in
C, alpha characters are represented in single quotes as to represent the
ASCII value hence 'M'. I would've never imagined the raw data would be so
lame like that though. Thanks again! 

--
View this message in context: 
http://r.789695.n4.nabble.com/Wrong-output-due-to-what-I-think-might-be-a-data-type-issue-zoo-read-in-problem-tp4487682p4490172.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] Wrong output due to what I think might be a data type issue (zoo read in problem)

2012-03-20 Thread knavero
update temporary fix:

http://pastebin.com/dzj0W89H

--
View this message in context: 
http://r.789695.n4.nabble.com/Wrong-output-due-to-what-I-think-might-be-a-data-type-issue-zoo-read-in-problem-tp4487682p4488179.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] Wrong output due to what I think might be a data type issue (zoo read in problem)

2012-03-20 Thread knavero
found a temporary fix (I'm sure it's redundant and not as elegant, but here
it is):

require(zoo)
require(chron)
setwd("/home/knavero/Desktop/")

fmt = "%m/%d/%Y %H:%M"
tail1 = function(x) tail(x, 1)
rawData = read.zoo("weatherData.txt", header = T, FUN = as.chron,
   format = fmt, sep = "\t", aggregate = tail1)
   #colClasses = c(NA, "matrix"))

rawData = zoo(cbind(temp = as.vector(rawData)), time(rawData))

oneMin = seq(start(rawData), end(rawData), by = times("01:00:00"))
intData = na.approx(rawData, xout = oneMin)

par(mfrow = c(3, 1), oma = c(0, 0, 2, 0), mar = c(2, 4, 1, 1))

plot(rawData, type = "p", ylim = c(0, 100))
grid(col = "darkgrey")

plot(intData, type = "p", ylim = c(0, 100))
grid(col = "darkgrey")

Silly coding huh? It works thoughthe plots were just to double check
btw...nothing significant obviously


--
View this message in context: 
http://r.789695.n4.nabble.com/Wrong-output-due-to-what-I-think-might-be-a-data-type-issue-zoo-read-in-problem-tp4487682p4487739.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] Wrong output due to what I think might be a data type issue (zoo read in problem)

2012-03-20 Thread knavero
Here's the small scale version of the R script:

http://pastebin.com/sEYKv2Vv

Here's the file that I'm reading in:

http://r.789695.n4.nabble.com/file/n4487682/weatherData.txt weatherData.txt 

I apologize for the length of the data. I tried to cut it down to 12 lines,
however, it wasn't reproducing the bad output that I wanted to show. 

The problem is that my whole data set shifts down. For example, I have this
when the raw data is read in or scanned in as a zoo object:

"> rawData
(12/01/10 00:53:00) (12/01/10 01:53:00) (12/01/10 02:53:00) (12/01/10
03:53:00) 
 41  40  39 
38 
(12/01/10 04:53:00) (12/01/10 05:53:00) (12/01/10 06:53:00) (12/01/10
07:53:00) 
 38  37  36 
39 
(12/01/10 08:53:00) (12/01/10 09:53:00) (12/01/10 10:53:00) (12/01/10
11:53:00) 
 43  47  50 "

Then when I run it through my code, which should feed out the exact same
thing (the values at least), the output is this:

"> intData
(12/01/10 00:53:00) (12/01/10 01:53:00) (12/01/10 02:53:00) (12/01/10
03:53:00) 
   11.010.0 9.0
8.0 
(12/01/10 04:53:00) (12/01/10 05:53:00) (12/01/10 06:53:00) (12/01/10
07:53:00) 
8.0 7.0 6.0
9.0 
(12/01/10 08:53:00) (12/01/10 09:53:00) (12/01/10 10:53:00) (12/01/10
11:53:00) 
   13.017.020.0   
24.0 "

Finally, my dput(rawData) and dput(intData):

"> dput(rawData)
structure(c(11L, 10L, 9L, 8L, 8L, 7L, 6L, 9L, 13L, 17L, 20L, 
24L, 27L, 27L, 27L, 26L, 23L, 21L, 20L, 21L, 18L, 16L, 14L, 14L, 
12L, 10L, 12L, 11L, 10L, 10L, 11L, 14L, 16L, 20L, 23L, 27L, 25L, 
26L, 29L, 28L, 27L, 26L, 24L, 24L, 25L, 24L, 23L, 23L, 21L, 20L, 
18L, 19L, 18L, 18L, 16L, 18L, 21L, 24L, 25L, 27L, 27L, 29L, 29L,..." 

"> dput(intData)
structure(c(11, 10, 9, 8, 8, 7, 6, 9, 13, 17, 20, 24, 27, 27, 
27, 26, 23, 21, 20, 21, 18, 16, 14, 14, 12, 10, 12, 11, 10, 10, 
11, 14, 16, 20, 23, 27, 25, 26, 29, 28, 27, 26, 24, 24, 25, 24, 
23, 23, 21, 20, 18, 19, 18, 18, 16, 18, 21, 24, 25, 27, 27, 29, 
29, 28, 26, 25, 24, 22, 22, 22, 21, 21, 21, 20, 21, 21, 20, 21,..." 

I am not sure how to interpret this, however I have tried researching on
what the "L" following the number is, and it seems they are "list" values? 
Also, I have read ?colClasses in the R manual, and have tried colClasses.
>From experience using C, there seems to be a related error message saying:

"scan() expected 'a real', got 'M'"

What is "M"? Is that matrix? Any clarification of the issue and solution is
appreciated. I apologize in advance for any noob mistake related to asking
questions correctly according to forum specifications. Thanks for any help!
I will keep messing around with colClassesI feel like I am close to a
solution..however, am very far from understanding the problem.



--
View this message in context: 
http://r.789695.n4.nabble.com/Wrong-output-due-to-what-I-think-might-be-a-data-type-issue-zoo-read-in-problem-tp4487682p4487682.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
Thanks Gabor. colClasses did the trick. Also, I'll be sure to minimize the
reproducible example the next time around using a text quote. Sorry about
the noob mistake.

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4473370.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
Heh, a one liner fix huh? This was going to be my alternative solution (got
this coded as soon as the character strings theory arrived, and yes I'll use
dput next time, sorry about that again and for all the miscommunication):

require(zoo); require(chron)

setwd("/home/knavero/Desktop")
rawData = read.table("dataout_2471_843.csv", header = T, sep = ",")
rawData$Meter.ID = NULL

pwr = as.vector(rawData$KW.ch..1..set.0.)
idx = as.vector(rawData$Date...Time)
idx = as.chron(idx, format = "%m/%d/%Y %H:%M")

newData = zoo(cbind(pwr = pwr), idx)
newData = newData[newData$pwr > 0]

Guess I won't be needing that ^  anymore. And here I thought i redefined
logic where 0 > 0 ha...I knew it was too good to be true. Thanks for all the
help. Much appreciated.


--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4473072.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
"If you showed the output of dput(yourData) or even str(yourData)
others could see what types the columns are.  Ordinary printed output can
make numeric, character, and factor data look the same.  Comparisons
involving strings do not always return the same value as comparisons
involving the equivalent numbers.  E.g.,

  > y <- c("0.00", "0.01", "10.1", "20.2", "0.00")
  > z <- zoo(y, as.POSIXct("2012-03-14")+(1:5)*24*60*60)
  > z # looks like numeric data, but it is not
  2012-03-15 2012-03-16 2012-03-17 2012-03-18 2012-03-19
0.00   0.01   10.1   20.2   0.00
  > str(z)
  'zoo' series from 2012-03-15 to 2012-03-19
Data: chr [1:5] "0.00" "0.01" "10.1" "20.2" "0.00"
Index:  POSIXct[1:5], format: "2012-03-15" "2012-03-16" "2012-03-17"
"2012-03-18" "2012-03-19"
  > z[z>0]
  2012-03-15 2012-03-16 2012-03-17 2012-03-18 2012-03-19
0.00   0.01   10.1   20.2   0.00
  > z[z>"0.00"]
  2012-03-16 2012-03-17 2012-03-18
0.01   10.1   20.2
  > "0.0" > 0
  [1] TRUE "

Ah I see. So it's seeing the ASCII values I'm assuming. Yeah, I think this
was the case I was running into. It seems it's just dependent on the raw
data because recently when I was reading in raw data as zoo, this didn't
happen. However, my dput results show quoted values, technically strings.
Thank you for pointing this out. I'll remember to use dput next time. Noob
mistake. Won't happen again.

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4473057.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
Additionally, the dput(rawData) output:

dput(rawData)
structure(list(Date...Time = structure(1:1040, .Label = c("2/11/12 12:45
", 
"2/11/12 13:00 ", "2/11/12 13:15 ", "2/11/12 13:30
", 
"2/11/12 13:45 ", "2/11/12 14:00 ", "2/11/12 14:15
", 
"2/11/12 14:30 ", "2/11/12 14:45 ", "2/11/12 15:00
", 
"2/11/12 15:15 ", "2/11/12 15:30 ", "2/11/12 15:45
", 
"2/11/12 16:00 ", "2/11/12 16:15 ", "2/11/12 16:30
", 
"2/11/12 16:45 ", "2/11/12 17:00 ", "2/11/12 17:15
", 
"2/11/12 17:30 ", "2/11/12 17:45 ", "2/11/12 18:00
", 
"2/11/12 18:15 ", "2/11/12 18:30 ", "2/11/12 18:45
", 
"2/11/12 19:00 ", "2/11/12 19:15 ", "2/11/12 19:30
", 
"2/11/12 19:45 ", "2/11/12 20:00 ", "2/11/12 20:15
", 
"2/11/12 20:30 ", "2/11/12 20:45 ", "2/11/12 21:00
", 
"2/11/12 21:15 ", "2/11/12 21:30 ", "2/11/12 21:45
", 
"2/11/12 22:00 ", "2/11/12 22:15 ", "2/11/12 22:30
", 
"2/11/12 22:45 ", "2/11/12 23:00 ", "2/11/12 23:15
", 
"2/11/12 23:30 ", "2/11/12 23:45 ", "2/12/12 00:00
", 
"2/12/12 00:15 ", "2/12/12 00:30 ", "2/12/12 00:45
", 
"2/12/12 01:00 ", "2/12/12 01:15 ", "2/12/12 01:30
", 
"2/12/12 01:45 ", "2/12/12 02:00 ", "2/12/12 02:15
", 
"2/12/12 02:30 ", "2/12/12 02:45 ", "2/12/12 03:00
", 
"2/12/12 03:15 ", "2/12/12 03:30 ", "2/12/12 03:45
", 
"2/12/12 04:00 ", "2/12/12 04:15 ", "2/12/12 04:30
", 
"2/12/12 04:45 ", "2/12/12 05:00 ", "2/12/12 05:15
", 
"2/12/12 05:30 ", "2/12/12 05:45 ", "2/12/12 06:00
", 
"2/12/12 06:15 ", "2/12/12 06:30 ", "2/12/12 06:45
", 
"2/12/12 07:00 ", "2/12/12 07:15 ", "2/12/12 07:30
", 
"2/12/12 07:45 ", "2/12/12 08:00 ", "2/12/12 08:15
", 
"2/12/12 08:30 ", "2/12/12 08:45 ", "2/12/12 09:00
", 
"2/12/12 09:15 ", "2/12/12 09:30 ", "2/12/12 09:45
", 
"2/12/12 10:00 ", "2/12/12 10:15 ", "2/12/12 10:30
", 
"2/12/12 10:45 ", "2/12/12 11:00 ", "2/12/12 11:15
", 
"2/12/12 11:30 ", "2/12/12 11:45 ", "2/12/12 12:00
", 
"2/12/12 12:15 ", "2/12/12 12:30 ", "2/12/12 12:45
", 
"2/12/12 13:00 ", "2/12/12 13:15 ", "2/12/12 13:30
", 
"2/12/12 13:45 ", "2/12/12 14:00 ", "2/12/12 14:15
", 
"2/12/12 14:30 ", "2/12/12 14:45 ", "2/12/12 15:00
", 
"2/12/12 15:15 ", "2/12/12 15:30 ", "2/12/12 15:45
", 
"2/12/12 16:00 ", "2/12/12 16:15 ", "2/12/12 16:30
", 
"2/12/12 16:45 ", "2/12/12 17:00 ", "2/12/12 17:15
", 
"2/12/12 17:30 ", "2/12/12 17:45 ", "2/12/12 18:00
", 
"2/12/12 18:15 ", "2/12/12 18:30 ", "2/12/12 18:45
", 
"2/12/12 19:00 ", "2/12/12 19:15 ", "2/12/12 19:30
", 
"2/12/12 19:45 ", "2/12/12 20:00 ", "2/12/12 20:15
", 
"2/12/12 20:30 ", "2/12/12 20:45 ", "2/12/12 21:00
", 
"2/12/12 21:15 ", "2/12/12 21:30 ", "2/12/12 21:45
", 
"2/12/12 22:00 ", "2/12/12 22:15 ", "2/12/12 22:30
", 
"2/12/12 22:45 ", "2/12/12 23:00 ", "2/12/12 23:15
", 
"2/12/12 23:30 ", "2/12/12 23:45 ", "2/13/12 00:00
", 
"2/13/12 00:15 ", "2/13/12 00:30 ", "2/13/12 00:45
", 
"2/13/12 01:00 ", "2/13/12 01:15 ", "2/13/12 01:30
", 
"2/13/12 01:45 ", "2/13/12 02:00 ", "2/13/12 02:15
", 
"2/13/12 02:30 ", "2/13/12 02:45 ", "2/13/12 03:00
", 
"2/13/12 03:15 ", "2/13/12 03:30 ", "2/13/12 03:45
", 
"2/13/12 04:00 ", "2/13/12 04:15 ", "2/13/12 04:30
", 
"2/13/12 04:45 ", "2/13/12 05:00 ", "2/13/12 05:15
", 
"2/13/12 05:30 ", "2/13/12 05:45 ", "2/13/12 06:00
", 
"2/13/12 06:15 ", "2/13/12 06:30 ", "2/13/12 06:45
", 
"2/13/12 07:00 ", "2/13/12 07:15 ", "2/13/12 07:30
", 
"2/13/12 07:45 ", "2/13/12 08:00 ", "2/13/12 08:15
", 
"2/13/12 08:30 ", "2/13/12 08:45 ", "2/13/12 09:00
", 
"2/13/12 09:15 ", "2/13/12 09:30 ", "2/13/12 09:45
", 
"2/13/12 10:00 ", "2/13/12 10:15 ", "2/13/12 10:30
", 
"2/13/12 10:45 ", "2/13/12 11:00

Re: [R] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
"I'm getting a 404 on the dropbox linklooking at your pastebin
link, my guess is that those numbers are in fact greater than zero,
but are very small so they appear as zeros in the print method.

If you want to send your data, it's easier to simply give us
dput(rawData) and copy and paste the result into the email thread.

I sincerely doubt that the world's most powerful and commonly used
statistical software, after 20 years of development, can't test for
something being greater than a literal."

Right, sorry about the miscommunication. Did you try the attached file I
uploaded 2 hours before the post above? I just noticed the more button here
can attach files. Here it is:

http://r.789695.n4.nabble.com/file/n4473011/dataout_2471_843.csv
dataout_2471_843.csv 

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4473011.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
attached http://r.789695.n4.nabble.com/file/n4472408/dataout_2471_843.csv
dataout_2471_843.csv 

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472408.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
Here's the exact error I'm receiving:

http://pastebin.com/mNsPauwk

Tracked each output along the way. Starting to think there's a bug in the
source code. 

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472337.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
"You're missing a comma between 0 and "]" in the last line if your goal  
is to retrieve the rows that satisfy that condition (and if the  
condition makes any sense). Haven't tested the rest of your code,  
though.

?Extract


> The outputs that I'm getting, however, are
> printing out 0's down the columns. I've tried various methods assuming
> various theories, read the R manual via "?" for different possible
> solutions, Googled stuff, tried the ifelse function which produces  
> the same
> error, tried creating logical vectors to get a better visual of what  
> the
> process is, tried doing all of the above on a small sample data set  
> (which
> actually works correctly for some reason, but doesn't work on the  
> actual raw
> data), and basically have done a lot of research and trial and error  
> before
> posting on here. Help is much appreciated. Thank you.
>
> P.S. I hope I asked this correctly on the forum (putting  
> reproducible code
> that reproduces the error, etc.).
... [show rest of quote]

If there is an error then you should post the complete error message."

About to post the error because it's still showing up. I understand the ","
is supposed to act as an (x, y) or (i, j) separator such that [,1] would be
column 1 similar to how rawData$KW.ch..1..set.0. looks at the same column.
Let me know if you're able to retrieve the csv file from the dropbox link.
Again, it should prompt you to download it. I would've put a smaller sample
size, but the logical condition seemed to work on a small scale version
unfortunately, thus being unable to reproduce the problem.

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472301.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
"> Here's the raw data I'm working with (will be available temporarily):
>
> http://dl.dropbox.com/u/41922443/dataout_2471_843.csv

Nothing appears. "

^ Clicking on the link should prompt you to download a csv file and save it
somewhere in your HDD.

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472215.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
"> The outputs that I'm getting, however, are
> printing out 0's down the columns. I've tried various methods assuming
> various theories, read the R manual via "?" for different possible
> solutions, Googled stuff, tried the ifelse function which produces  
> the same
> error, tried creating logical vectors to get a better visual of what  
> the
> process is, tried doing all of the above on a small sample data set  
> (which
> actually works correctly for some reason, but doesn't work on the  
> actual raw
> data), and basically have done a lot of research and trial and error  
> before
> posting on here. Help is much appreciated. Thank you.
>
> P.S. I hope I asked this correctly on the forum (putting  
> reproducible code
> that reproduces the error, etc.).
... [show rest of quote]

If there is an error then you should post the complete error message."

Hm, technically there is no "error message"? It just prints zeros (the wrong
output) as a result of explicitly making the logical condition " > 0". But
anyway, I'll be sure to copy paste the error output next time. Thanks for
the advice.

--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4472236.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] logical test not functioning correctly on zoo series...what the hell?

2012-03-14 Thread knavero
Here's the raw data I'm working with (will be available temporarily):

http://dl.dropbox.com/u/41922443/dataout_2471_843.csv

Next, here's the code I want to impose (error that I'm seeing SHOULD
reproduce on your shell when script is executed...btw using Ubuntu Linux
11.10 if that makes a difference):

http://pastebin.com/LDNw8UT0

The issue specifically is the last line of code in which I want to print out
any value greater than 0. The outputs that I'm getting, however, are
printing out 0's down the columns. I've tried various methods assuming
various theories, read the R manual via "?" for different possible
solutions, Googled stuff, tried the ifelse function which produces the same
error, tried creating logical vectors to get a better visual of what the
process is, tried doing all of the above on a small sample data set (which
actually works correctly for some reason, but doesn't work on the actual raw
data), and basically have done a lot of research and trial and error before
posting on here. Help is much appreciated. Thank you. 

P.S. I hope I asked this correctly on the forum (putting reproducible code
that reproduces the error, etc.). If I made some noob mistake, I apologize
in advance so please don't be mad at me. I will clarify if necessary.









--
View this message in context: 
http://r.789695.n4.nabble.com/logical-test-not-functioning-correctly-on-zoo-series-what-the-hell-tp4471654p4471654.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] Filter/Ceiling for unwanted data - zoo

2012-03-05 Thread knavero
thinking of using an "ifelse" statement, curious if there's a more elegant
way of going about this

--
View this message in context: 
http://r.789695.n4.nabble.com/Filter-Ceiling-for-unwanted-data-zoo-tp4447595p4447791.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] Filter/Ceiling for unwanted data - zoo

2012-03-05 Thread knavero
Here's my script:

http://pastebin.com/zx3TCtXg

I want to draw attention to the code block where the read in of the raw data
is located. Is there a function that filters out unwanted data with respect
to a ceiling limit. For example, I want to remove any value over 500 kW in
the rawCool variable. Any ideas where to go with that? I figure it would be
an argument within read.zoo or an external function that manipulates the zoo
vector that was read in prior. I plan on looking into the zoo FAQ and the R
manual '?'. Any help pushing me towards the right direction is much
appreciated. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Filter-Ceiling-for-unwanted-data-zoo-tp4447595p4447595.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] Noob question - Identity argument within aggregate function?

2012-03-02 Thread knavero
Sorry, in regards to the previous post where I said aggregate(z, identity,
tail, 1), replace it with aggregate(z, identity, mean)

--
View this message in context: 
http://r.789695.n4.nabble.com/Noob-question-Identity-argument-within-aggregate-function-tp4439806p4440424.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] Noob question - Identity argument within aggregate function?

2012-03-02 Thread knavero
I've also searched "?identity" in the R shell and it doesn't seem to be the
definition I'm looking for for this particular usage of "identity" as an
argument in the aggregate function. I simply would appreciate a conceptual
explanation of what it does here and how it relates to the error.

--
View this message in context: 
http://r.789695.n4.nabble.com/Noob-question-Identity-argument-within-aggregate-function-tp4439806p4440420.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] Noob question - Identity argument within aggregate function?

2012-03-02 Thread knavero
z is a zoo object as a result from reading in the following series

z = suppressWarnings(zoo(1:8), c(1, 2, 2, 2, 3, 4, 5, 5))

This is what z is in the aggregate function. So then that brings us to
"aggregate(z, identity, tail, 1)". All I was trying to accomplish was trying
to reproduce an example shown on the zoo faq. I've read ?aggregate via
terminal and used "/identity" to search through the documentation for the
specific term "identity". I'm just trying to understand what identity is
used for because I do not understand the error statement. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Noob-question-Identity-argument-within-aggregate-function-tp4439806p4440413.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] Noob question - Identity argument within aggregate function?

2012-03-02 Thread knavero
>aggregate(z, identity, mean)
  1   2   3   4   5 
1.0 3.0 5.0 6.0 7.5 
> aggregate(z, mean)
Error: length(time(x)) == length(by[[1]]) is not TRUE

Can someone help me understand the error above and why "identity" is
necessary to satisfy the error




--
View this message in context: 
http://r.789695.n4.nabble.com/Noob-question-Identity-argument-within-aggregate-function-tp4439806p4439806.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] aggregating specific parts in zoo index column to perform sliding average

2012-02-28 Thread knavero
Thanks Gabor. Answering all my noob questions haha. Interesting strategy to
adjust the input raw data as opposed to Excel where one offsets the output
data instead. I'll remember that.

--
View this message in context: 
http://r.789695.n4.nabble.com/aggregating-specific-parts-in-zoo-index-column-to-perform-sliding-average-tp4426798p4429257.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] aggregating specific parts in zoo index column to perform sliding average

2012-02-27 Thread knavero
Here's my code:

http://pastebin.com/0yRxEVtm

The important parts are uncommented and should be easy to find using the
link above. For the following line of code, I plan on looking for a way to
offset it up 7 rows so that the 15 minute timestamp would be considered the
"median" of the subset being averaged to find the mean: 

avgCool = aggregate(intCool, trunc(time(intCool), times("00:15:00")), mean)

Currently the issue is that, with the truncate function, it "truncates" but
really rounds down the time series values to the 15 minute time stamp
earlier in the series. For example, let's say we have one minute intervals
0:00, 0:01, 0:02,,0:37. It takes 0:00 - 0:14 and replaces that with
0:00. Then it sees 0:15, and changes values from 0:15 - 0:29 to 0:15. In
effect, aggregating the values and creating subsets. 

What I want to do here is change 0:00 - 0:07 to 0:00, change 0:08 - 0:22 to
0:15, and change 0:23 - 0:37 to 0:30 in which 0:15 and 0:30 are the medians
of each subset. Anyway, I hope that makes sense. Any ideas on which function
will make this an easy job? Much thanks in advance.



--
View this message in context: 
http://r.789695.n4.nabble.com/aggregating-specific-parts-in-zoo-index-column-to-perform-sliding-average-tp4426798p4426798.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] question about user written function (newb question)

2012-02-26 Thread knavero
Quick newb question about R relating to the line of code below:

rawCool = read.zoo("cooling.txt", FUN = as.chron, format = "%m/%d/%Y %H:%M",
sep = "\t", aggregate = function(x) tail(x, 1))

I'm wondering what the specifics are for the argument where it has
"aggregate = function(x) tail(x, 1)". I understand that it removes the last
row of duplicates/aggregates in the zoo series. I'm confused as to why
"tail(x, 1)", a built in function in the utils package, requires the coder
to treat it as a user written function thus defining the assignment, in this
case an argument, with "function(x)". Why can't the coder just write
"tail(x, 1)" instead? Also, with the argument 'x', within tail, I'm assuming
it's looking at all columns simultaneously within the zoo series? Is that
correct to say? Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/question-about-user-written-function-newb-question-tp4422187p4422187.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.