Propose your Valentine with R

Deepanshu Bhalla 22 Comments
This post is dedicated to all the R programming lovers. It's not easy to impress tech-savvy valentine with conventional surprises.You might have tried all conventional surprises for your valentine. If your valentine is R programming lover, you can have an impact on her with your cool coding skill.

Wish Valentine with R


How to Use

Ask your valentine to run the following R program and see what you mean

Method 1 : Heart Curve
# Enter the name of person you love
mylove = "Katie"

# Load ggplot2 package
library(ggplot2)

# Create data frame
k = seq(0, 2*pi, pi/60)
mydata = data.frame(
  x = 16*sin(k)^3 +25,
  y = 13*cos(k) - 5*cos(2*k) - 2*cos(3*k) - cos(4*k) +20
)

# Generate Plot
Valentine = ggplot(data = mydata, aes(x, y)) +
  geom_polygon(aes(group = 1), fill = "red") +
  geom_text(aes(x = 25, y = 20, label = "Happy Valentine's Day!"),
            size = 8, colour = "white") +
  geom_text(aes(x = 15, y = 5, label = paste("To :", mylove)),
          size = 5, colour = "#444444")

Valentine

Method 2 : Text Message

paste(intToUtf8(acos(log(1))*180/pi-17),
      intToUtf8(atan(1/sqrt(3))*180/pi+2), toupper(substr(month.name[4],5,5)),
  intToUtf8(acos(exp(0)/2)*180/pi+2^4+3),toupper(substr(month.name[11],3,3)),
      LETTERS[3^2-2^2],intToUtf8(atan(1/sqrt(3))*180/pi+2),
      intToUtf8(acos(log(1))*180/pi-1), substr(month.name[10],1,1),
      intToUtf8(acos(log(1))*180/pi-5), sep = intToUtf8(0))

Don't tell your valentine what the program returns and make it a surprise.
Output

Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

22 Responses to "Propose your Valentine with R"
  1. getting an error

    Error in UseMethod("weekdays") :
    no applicable method for 'weekdays' applied to an object of class "c('double', 'numeric')"

    ReplyDelete
    Replies
    1. It seems R version issue. I have updated the code. It should work now. Thanks!

      Delete
  2. Replies
    1. It seems R version issue. I have updated the code. It should work now. Thanks!

      Delete
  3. I can't run it. I have next error:
    Error in UseMethod("weekdays") :
    no applicable method for 'weekdays' applied to an object of class "c('double', 'numeric')"

    ReplyDelete
    Replies
    1. It seems R version issue. I have updated the code. It should work now. Thanks!

      Delete
  4. Awesome. It is working for me. Yipeee :-)

    ReplyDelete
  5. Replies
    1. Updated the code. It should work now. See the snapshot of the output. I apologize for the inconvenience caused. Please confirm if it still does not work.

      Delete
  6. doesn't work, even with the new code

    ReplyDelete
    Replies
    1. Updated the code. It should work now. See the snapshot of the output. I apologize for the inconvenience caused. Please confirm if it still does not work.

      Delete
  7. thanks!!! My girlfriend loved it!!!

    ReplyDelete
  8. All because of "I LOVE YOU" ? Anyway, it's interesting, but what if my crush is not using R? Well done.

    ReplyDelete
  9. The way to print those characters one by one using code conversion. I liked it.

    ReplyDelete
  10. thank you very much. very funny program.

    ReplyDelete
  11. it will certainly work in R-fiddle

    ReplyDelete
  12. Thank you, very cool; how can I customize it to add the name of a specific person?

    ReplyDelete
Next → ← Prev