[R] time series contains internal NAs error

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Jan 19 16:02:34 CET 2009


On Mon, 19 Jan 2009, Gabor Grothendieck wrote:

> The statement to read in the data is missing from your post but
> I suspect that you are representing the data as daily data so its filling
> in 364 or 365 NA's between points.  Represent it as the annual data
> that it is.

One further pointer: Also look at
   help("sunspots")

> Try this:
>
> Lines <- "Sunspots,Datefield
> 9.5,1/1/1900
> 2.7,1/1/1901
> 5,1/1/1902
> 24.4,1/1/1903
> 42,1/1/1904
> 63.5,1/1/1905
> 53.8,1/1/1906
> 62,1/1/1907
> 48.5,1/1/1908
> 43.9,1/1/1909
> 18.6,1/1/1910
> 5.7,1/1/1911
> 3.6,1/1/1912
> 1.4,1/1/1913
> 9.6,1/1/1914
> 47.4,1/1/1915
> 57.1,1/1/1916
> 103.9,1/1/1917
> 80.6,1/1/1918
> 63.6,1/1/1919
> 37.6,1/1/1920
> 26.1,1/1/1921
> 14.2,1/1/1922
> 5.8,1/1/1923
> 16.7,1/1/1924
> 44.3,1/1/1925
> 63.9,1/1/1926
> 69,1/1/1927
> 77.8,1/1/1928
> 64.9,1/1/1929
> 35.7,1/1/1930
> 21.2,1/1/1931
> 11.1,1/1/1932
> 5.7,1/1/1933
> 8.7,1/1/1934
> 36.1,1/1/1935
> 79.7,1/1/1936
> 114.4,1/1/1937
> 109.6,1/1/1938
> 88.8,1/1/1939
> 67.8,1/1/1940
> 47.5,1/1/1941
> 30.6,1/1/1942
> 16.3,1/1/1943
> 9.6,1/1/1944
> 33.2,1/1/1945
> 92.6,1/1/1946
> 151.6,1/1/1947
> 136.3,1/1/1948
> 134.7,1/1/1949
> 83.9,1/1/1950
> 69.4,1/1/1951
> 31.5,1/1/1952
> 13.9,1/1/1953
> 4.4,1/1/1954
> 38,1/1/1955
> 141.7,1/1/1956
> 190.2,1/1/1957
> 184.8,1/1/1958
> 159,1/1/1959
> 112.3,1/1/1960
> 53.9,1/1/1961
> 37.5,1/1/1962
> 27.9,1/1/1963
> 10.2,1/1/1964
> 15.1,1/1/1965
> 47,1/1/1966
> 93.8,1/1/1967
> 105.9,1/1/1968
> 105.5,1/1/1969
> 104.5,1/1/1970
> 66.6,1/1/1971
> 68.9,1/1/1972
> 38,1/1/1973
> 34.5,1/1/1974
> 15.5,1/1/1975
> 12.6,1/1/1976
> 27.5,1/1/1977
> 92.5,1/1/1978
> 155.4,1/1/1979
> 32.27,1/1/1980
> 54.25,1/1/1981
> 59.65,1/1/1982
> 63.62,1/1/1983"
>
> library(chron)
> library(zoo)
> z <- read.zoo(textConnection(Lines), header = TRUE, sep = ",",
> 	FUN = function(x) as.yearmon(chron(x)), index = 2)
> acf(z)
>
>
> On Mon, Jan 19, 2009 at 9:34 AM, Harsh <singhalblr at gmail.com> wrote:
>> Very Sorry for the oversight.
>>
>> The dataset that I have used is:
>>
>> Sunspots,Datefield
>> 9.5,1/1/1900
>> 2.7,1/1/1901
>> 5,1/1/1902
>> 24.4,1/1/1903
>> 42,1/1/1904
>> 63.5,1/1/1905
>> 53.8,1/1/1906
>> 62,1/1/1907
>> 48.5,1/1/1908
>> 43.9,1/1/1909
>> 18.6,1/1/1910
>> 5.7,1/1/1911
>> 3.6,1/1/1912
>> 1.4,1/1/1913
>> 9.6,1/1/1914
>> 47.4,1/1/1915
>> 57.1,1/1/1916
>> 103.9,1/1/1917
>> 80.6,1/1/1918
>> 63.6,1/1/1919
>> 37.6,1/1/1920
>> 26.1,1/1/1921
>> 14.2,1/1/1922
>> 5.8,1/1/1923
>> 16.7,1/1/1924
>> 44.3,1/1/1925
>> 63.9,1/1/1926
>> 69,1/1/1927
>> 77.8,1/1/1928
>> 64.9,1/1/1929
>> 35.7,1/1/1930
>> 21.2,1/1/1931
>> 11.1,1/1/1932
>> 5.7,1/1/1933
>> 8.7,1/1/1934
>> 36.1,1/1/1935
>> 79.7,1/1/1936
>> 114.4,1/1/1937
>> 109.6,1/1/1938
>> 88.8,1/1/1939
>> 67.8,1/1/1940
>> 47.5,1/1/1941
>> 30.6,1/1/1942
>> 16.3,1/1/1943
>> 9.6,1/1/1944
>> 33.2,1/1/1945
>> 92.6,1/1/1946
>> 151.6,1/1/1947
>> 136.3,1/1/1948
>> 134.7,1/1/1949
>> 83.9,1/1/1950
>> 69.4,1/1/1951
>> 31.5,1/1/1952
>> 13.9,1/1/1953
>> 4.4,1/1/1954
>> 38,1/1/1955
>> 141.7,1/1/1956
>> 190.2,1/1/1957
>> 184.8,1/1/1958
>> 159,1/1/1959
>> 112.3,1/1/1960
>> 53.9,1/1/1961
>> 37.5,1/1/1962
>> 27.9,1/1/1963
>> 10.2,1/1/1964
>> 15.1,1/1/1965
>> 47,1/1/1966
>> 93.8,1/1/1967
>> 105.9,1/1/1968
>> 105.5,1/1/1969
>> 104.5,1/1/1970
>> 66.6,1/1/1971
>> 68.9,1/1/1972
>> 38,1/1/1973
>> 34.5,1/1/1974
>> 15.5,1/1/1975
>> 12.6,1/1/1976
>> 27.5,1/1/1977
>> 92.5,1/1/1978
>> 155.4,1/1/1979
>> 32.27,1/1/1980
>> 54.25,1/1/1981
>> 59.65,1/1/1982
>> 63.62,1/1/1983
>>
>> I convert the Datefield column to class Date, by using Datefield<-
>> as.Date(Datefield,format="%m/%d/%Y")
>> Then I create a time series object by using
>> dtxts<- xts(Sunspots,order.by = Datefield)
>>
>> On using the ACF function
>> acf(dtxts,plot= TRUE,xaxt = "n",col="red",na.action = na.omit)
>> I get the error
>> Error in na.omit.ts(as.ts(x)) : time series contains internal NAs
>>
>> The peculiar issue is that I do not get the above error on
>> - R 2.7 on Ubuntu in India
>> - R 2.8 on Windows in India
>>
>> The error appears when I execute this code on an R 2.8 implementation
>> running on a Fedora machine in the USA.
>>
>> Is it a problem with the locale?
>>
>> Thanks for the help. Really appreciate it.
>>
>> Harsh Singhal
>> Decisions Systems
>> Mu Sigma Inc.
>> Chicago, USA
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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 at 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.
>
>




More information about the R-help mailing list