In this section, we are going to do two things: If you were able to receive the e-mail on your mobile device using R's mailR package discussed in the previous section, you are ready for this next step. If it doesn't work, check your server details and email addresses. If everything is working you should be able to see the results using your mobile after tuning this code.
You will need to update the sever and account information as appropriate. User.name = "ername", #likely your email address Smtp = list(host.name = "",#check with IT or ISP #Email Trigger when "Hey R - Send Update" Ssl = TRUE #if using secure connection ),
Passwd = "your.password", #email password name = "ername", #likely your email address Recipients <- c ( ) #your mobile email here Sender <- #The email address R will use to send #Email Trigger when "Hey R - Send Update" library (mailR )
Using this information and R's mailR package, we can generate some code to send our message from the previous section to our mobile device via e-mail. If you are not sure about these items, check with IT or your internet service provider (ISP). To make this work, you will need to have the following information on hand: Now, we need to send it to our mobile device using R. E-mailing the Data from R to our Mobile DeviceĪwesome, we have the data in R and we generated the message we want to send. There is 5 minutes remaining before today’s shipping deadline. " minutes remaining before today's shipping deadline.")Ģ8 units of product shipping as of Fri Mar 01 16:55:23 2019. Paste0(Shipping_Product, " units of product shipping as of ", date(), #Detemine how many minute before the shipping dead line Shipping_Product <- sum(Product_Status$Count) ToShip <- grep(pattern = "Shipping Yesterday|Shipping Today", #Detemine how much product is shipping today as of right now Product_Status <- html_table(tbls)] #Get First Table Tbls <- html_nodes(page, "table") #Get the Tables " minutes remaining before today's shipping deadline." ) Paste0 (Shipping_Product, " units of product shipping as of ", date ( ), Product_Status$`Product Metrics` ) ] #The summary message to be e-mailed Shipping_Product <- sum (Product_Status$Count ) #Detemine how many minute before the shipping dead line ToShip <- grep (pattern = "Shipping Yesterday|Shipping Today", Product_Status <- html_table (tbls ) ] #Get First Table #Detemine how much product is shipping today as of right now Tbls <- html_nodes ( page, "table" ) #Get the Tables # Parse the HTML require (rvest ) #package to parse HTML page <- read_html ( "" ) #Get the Page
If you're not sure how to send an email from your mobile device, perhaps you'll find these texts useful: You'll need to pick something unique for your subject line like “Hey R – Send Update”, “Hey R – Run Report”, or something of that sort. If you know how to send an e-mail from your mobile device, you are off to a great start. Great! If you've got the idea, let's get into the details. There maybe some security considerations depending on how you implement this.Your desktop e-mail client needs to be open and receiving e-mails.Here is a little flow chart that sums it up: When the R script runs, it will get the data from the target data source, process the data, and e-mail the result back to your mobile device. The batch file will do two things i) launch headless R and ii) call the R script you want to run. For us, that application will be a simple batch file or shell script. Your ever vigilant desktop e-mail client receives the e-mail, and runs a “rule” you setup before leaving the office. First, let's pretend your mobile e-mail address is From your mobile, you send an E-mail to your desktop machine with the subject "Hey R – Send Update”. This is a big article, so here is quick summary of what we are going to do to get our data on demand on our mobile. Create an E-mail Trigger to Run the Batch File.E-mail Processed DEMO Results to our Mobile from R.Checkout a DEMO Scenario to Test our Process.Objectives: Run an R script from a mobile device