[datatable-help] Problem in reading the data set

Frank Erickson FErickson at psu.edu
Mon Oct 28 09:00:05 CET 2013


Hi Dila,

I think you have the wrong mailing list; this one is specifically for the
data.table package. You can see some other mailing lists here:
http://r.789695.n4.nabble.com/R-f789695.subapps.html

Since you only have one year to change, you can do something like

dat$Year <- ifelse(dat$Year==0,2000L,as.integer(dat$Year)+1900L)

You should run the right-hand side on its own first to make sure that it is
giving the correct result. The <- will overwrite the original column, and
the L and as.integer ensure that you store the new column as an integer.

For documentation, see for example help("<-") and help("ifelse")

Best,

Frank


On Mon, Oct 28, 2013 at 2:18 AM, dila radi <dila_radi21 at yahoo.com> wrote:

> Hi all,
>
> I have this kind of data. The data consist from year 1971-2000.
>
> Station Station ID Year Month Day Rainfall Amount(mm)
> Kuantan 48657   71      1       1       125
> Kuantan 48657   71      1       2       130.3
> Kuantan 48657   71      1       3       327.2
> Kuantan 48657   71      1       4       252.2
> Kuantan 48657   71      1       5       33.8
> Kuantan 48657   71      1       6       6.1
> Kuantan 48657   71      1       7       5.1
>
> ................................................................
> ..............................................................
> ................................................................
> ................................................................
>
> Kuantan 48657   00      12      24      0
> Kuantan 48657   00      12      25      2.7
> Kuantan 48657   00      12      26      0
> Kuantan 48657   00      12      27      0
> Kuantan 48657   00      12      28      20
> Kuantan 48657   00      12      29      15.5
> Kuantan 48657   00      12      30      6.4
> Kuantan 48657   00      12      31      9.3
>
> When I run for the Summary, the third column (year) give the output as
> below:
>
> Year
> Min.   : 0.00
> 1st Qu.:77.00
> Median :84.00
> Mean   :82.16
> 3rd Qu.:92.00
> Max.   :99.00
>
> The minimum should be 1971 and maximum is 2000. But R misinterpret 2000 as
> 00 value.
> How I want to solve this?
>
> Thank you in advance.
>
> Regards,
> Dila.
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Problem-in-reading-the-data-set-tp4679156.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131028/cf18fe99/attachment.html>


More information about the datatable-help mailing list