Hello there,

I don't know if I'm addressing my question to the right e-mail address, I hope 
I do. Actually I have a little problem concerning writing a code in R. I try to 
briefly sum up my problem.

As you can see below, I created the functions "Equation1" and "Equation2" with 
some conditions.

      Equation1 <-function(x){
                             if (x<=0.25) y <-1-4*x
                             if (x>0.25)   y <-0
                             y
                             }

      Equation2 <-function(x){
                             if (x<=0.25)                y <-4*x
                             if (x>0.25 & x<=0.5)   y <-2-4*x
                             if (x>0.5)                   y <-0
                             y
                             }

      And then I generated a sequence of numbers from 0 to 1 using the 
following code:

      x <-seq(0,1,0.05)

      What I intended to do was to create 3 columns like below. In the first 
column you can find all the x values I created just before using the seq 
procedure and in the next 2 columns you can see all the calculated values of 
functions Equation1 and Equation2 respectively.

      x      Egyenlet1  Egyenlet2
      0.00      1.00    0.00
      0.05      0.80    0.20
      0.10      0.60    0.40
      0.15      0.40    0.60
      0.20      0.20    0.80
      0.25      0.00    1.00
      0.30      0.00    0.80
      0.35      0.00    0.60
      0.40      0.00    0.40
      0.45      0.00    0.20
      0.50      0.00    0.00
      0.55      0.00    0.00
      0.60      0.00    0.00
      0.65      0.00    0.00
      0.70      0.00    0.00
      0.75      0.00    0.00
      0.80      0.00    0.00
      0.85      0.00    0.00
      0.90      0.00    0.00
      0.95      0.00    0.00
      1.00      0.00    0.00

      Unfortunately I didn't know how to create these columns. Whenever I tried 
to send the following codes into R:
      "Equation1(x)" or "Equation1(x)" (remember x representing the values from 
0 to 1)
      ...I instantaneously got a warning message saying:

       [1]  1.0  0.8  0.6  0.4  0.2  0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -1.2 -1.4 
-1.6 -1.8 -2.0 -2.2 -2.4 -2.6 -2.8 -3.0
      Warning messages:
      1: In if (x <= 0.25) y <- 1 - 4 * x :
        the condition has length > 1 and only the first element will be used
      2: In if (x > 0.25) y <- 0 :
        the condition has length > 1 and only the first element will be used

      Could somebody please help me with this? I would greatly appreciate if 
somebody would reply.
      Thank you very much and have a pleasant day!

      Best regards,
      Laszlo

____________________________________________________________________________________________________
Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy 
jogilag, szakmailag vagy más módon védett információt tartalmazhat. 
Amennyiben nem Ön a levél címzettje akkor a levél tartalmának közlése, 
reprodukálása, másolása, vagy egyéb más úton történő terjesztése, 
felhasználása szigorúan tilos. Amennyiben tévedésből kapta meg ezt az 
üzenetet kérjük azonnal értesítse az üzenet küldőjét. Az Erste Bank 
Hungary Zrt. (EBH) nem vállal felelősséget az információ teljes és pontos 
- címzett(ek)hez történő - eljuttatásáért, valamint semmilyen 
késésért, kapcsolat megszakadásból eredő hibáért, vagy az információ 
felhasználásából vagy annak megbízhatatlanságából eredő kárért.

Az üzenetek EBH-n kívüli küldője vagy címzettje tudomásul veszi és 
hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az 
EBH folytonos munkamenetének biztosítása érdekében.


This e-mail and any attached files are confidential and/...{{dropped:19}}

______________________________________________
R-help@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.

Reply via email to