[R] Wrong output due to what I think might be a data type issue (zoo read in problem)

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Mar 20 11:44:35 CET 2012


On Mon, Mar 19, 2012 at 11:34 PM, knavero <knavero at gmail.com> wrote:
> 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.
>

<snip>

>
> 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?

1 is a double.  1L is an integer.
> class(1)
[1] "numeric"
> class(1L)
[1] "integer"

> 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

There is an "M" in your data at line 9954:
1/3/2012 9:53	48
1/3/2012 10:53	M
1/3/2012 11:53	51

> 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 colClasses....I feel like I am close to a
> solution..however, am very far from understanding the problem.
>

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com



More information about the R-help mailing list