On Mon, Nov 12, 2012 at 1:49 PM, alen <tarhouni_wael at hotmail.fr>
wrote:> I'm beginner with R language
>
> My goal is to write a function that takes an input Erlang entering your
>
> ? Name
>
> ? Name
>
> ? Date of birth.
>
> The program will calculate age and display output
>
> first
> I do know the system date (month, day, year)
>
> I find with Sys.Date ()
>
>
> I found a function. net to calculate the age
>
>
>
> Protected Sub calcul_age()
> Dim datetimenow = DateTime.Now
> Dim datedenaissance = CDate(TbDn.Text)
> Dim age As Integer
> age = CInt(Now.Year - datedenaissance.Year)
> If (datedenaissance.Month > Now.Month) Then
> age = age - 1
> End If
> If ((datedenaissance.Month = Now.Month) And (datedenaissance.Day >
> Now.Day)) Then
> age = age - 1
> End If
> Me.Label3.Text = " Age : " & age & " ans"
> End Sub
>
>
>
>
> So I need to find the equivalent of this function with R language
>
>
> so I think that I will start by :
>
> affichage<-function()
> {
>
> print( "enter the first name" )
> firstname <- scan(nmax=1)
> print( "enter the last name" )
> lastname <- scan(nmax=1)
> print( "enter the date of birth" )
> dateofbirth <- ........ here start the problem
>
> ........
> ............
>
>
> }
Hi Alen,
I'm afraid I'm confused: how does this tie into Erlang? Do you mean
the distribution or the programming language?
As to the question you've posed, try taking a look at
? readline
? as.Date (because readline gives you a character string)
Then take the difference between Sys.Date() and their DOB -- truncate
to a year and that's your answer.
Cheers,
Michael