[R] Woring message in as.yearmon()
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Sep 10 20:27:16 CEST 2008
I can't reproduce that. When I run it I get no warning. Check
your versions:
> Lines <- "1946 4 1.27
+ 1946 5 1.27
+ 1946 6 1.27
+ 1946 7 1.27
+ 1946 8 1.52
+ 1946 9 1.52
+ 1946 10 1.52
+ 1946 11 1.52
+ 1946 12 1.62
+ 1947 1 1.62
+ 1947 2 1.62
+ 1947 3 1.62
+ 1947 4 1.87
+ 1947 5 1.87
+ 1947 6 1.87"
> res <- read.table(textConnection(Lines))
> library(zoo)
Warning message:
closing unused connection 3 (Lines)
> as.yearmon(paste(res[, 1], res[, 2], sep = "-"))
[1] "Apr 1946" "May 1946" "Jun 1946" "Jul 1946" "Aug 1946" "Sep 1946"
[7] "Oct 1946" "Nov 1946" "Dec 1946" "Jan 1947" "Feb 1947" "Mar 1947"
[13] "Apr 1947" "May 1947" "Jun 1947"
>
> R.version.string # Windows Vista
[1] "R version 2.7.2 (2008-08-25)"
> packageDescription("zoo")$Version
[1] "1.5-4"
On Wed, Sep 10, 2008 at 2:15 PM, Megh Dal <megh700004 at yahoo.com> wrote:
> I have following dataset:
>
>> res
> [,1] [,2] [,3]
> [1,] 1946 4 1.27
> [2,] 1946 5 1.27
> [3,] 1946 6 1.27
> [4,] 1946 7 1.27
> [5,] 1946 8 1.52
> [6,] 1946 9 1.52
> [7,] 1946 10 1.52
> [8,] 1946 11 1.52
> [9,] 1946 12 1.62
> [10,] 1947 1 1.62
> [11,] 1947 2 1.62
> [12,] 1947 3 1.62
> [13,] 1947 4 1.87
> [14,] 1947 5 1.87
> [15,] 1947 6 1.87
>
> Now I write following code :
>
>> as.yearmon(paste(res[,1], res[,2], sep="-"))
> [1] "Apr 1946" "May 1946" "Jun 1946" "Jul 1946" "Aug 1946" "Sep 1946" "Oct 1946" "Nov 1946" "Dec 1946"
> [10] "Jan 1947" "Feb 1947" "Mar 1947" "Apr 1947" "May 1947" "Jun 1947"
> Warning message:
> In if (nch == 1) "%Y-%m" else "%Y-%m-%d" :
> the condition has length > 1 and only the first element will be used
>
> Can anyone please tell me why this warning message is coming and what is the remedy?
>
> Regards,
>
> ______________________________________________
> 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