First function blocking a project opening - r

I've just read this post: .First function in R as I have previously used the first function when instructed for a short online course in which script was shared and run through with attendees. I don't fully understand much in the post or the use of the first function (I'm a relative beginner), but I think it is related to an error message every time I try to open up a project in R studio, and the project won't open and the session won't close. I can still open the project directly from the Rproject file, but would like to get rid of this issue.
The error in the console is :
Error in ll(class = c("matrix")) : could not find function "ll"
Has something been overwritten in Rstudio? Could someone advise as to how to get rid of this?
Many thanks.

Related

Script to guarantee app deploy using rsconnect:deployApp

I am able to deploy my shiny app with:
rsconnect::deployApp(appName = 'Test', launch.browser = FALSE, forceUpdate = T)
However, it does not always successfully deploy the app. I plan to have this run in a script as a Scheduled Task, and want to make sure the deployApp finishes successfully (if the process doesn't succeed, try again).
I imagine you could place this in a while loop, but I am not sure how to include script that would recognize if the function executed successfully or failed. Anyone have ideas?
Error Messages:
Preparing to deploy application...DONE
Error: $ operator is invalid for atomic vectors
As I say in the comment above, I really don't think this is a good idea. To do it safely and robustly will take a lot of work. And the error message you quote above looks pretty "uncontrolled" to me, so I suspect it's got more to do with a problem in your app than a temporary issue with the publishing process. In which case, you will be in an infinitely loop unless you take steps to prevent it. Have you investigated what your publish record and remote deployment log tell you?
That said, this would be my approach if I had to do it.
Create a flag, deploymentFlag, say, in the global environment and set it to FALSE.
Write a function, onDeploymentFailure() say, which sets deploymentFlag to FALSE.
Wrap you call to deployApp in a while loop like this
while(!deploymentFlag) {
deploymentFlag <- TRUE
rsconnect::deployApp(
...,
on.failure=onDeploymentFailure,
logLevel="verbose",
recordDir=<some dir>
)
if (!deploymentFlag) {
...interrogate the publish record to try to determine what went wrong,
and correct it if possible...
}
}
For safety, especially whilst developing and testing, I'd make sure that each attempt wrote a different publish log and I'd limit the maximum number of attempts to a very small number: 1 to start with, then 2 or 3 after I'd solved the initial problems, and so on.

Dynamic output issue when rowset is empty

I'm running a u-sql script similar to this:
#output =
SELECT Tag,
Json
FROM #table;
OUTPUT #output
TO #"/Dir/{Tag}/filename.txt"
USING Outputters.Text(quoting : false);
The problem is that #output is empty and the execution crashes. I already checked that if I don't use {tag} in the output path the script works well (it writes an empty file but that's the expectable).
Is there a way to avoid the crash and simply don't output anything?
Thank you
The form you are using is not yet publicly supported. Output to Files (U-SQL) documents the only supported version right now.
That said, depending on the runtime that you are using, and the flags that you have set in the script, you might be running the private preview feature of outputting to a set of files. In that case, I would expect that it would work properly.
Are you able to share a job link?

How to write (or access?) log of errors and warnings in R

Can anyone tell me how to keep a simple log of errors and warnings thrown during sourcing of code in R? Specifically I want to write them to an object during sourcing so I can print them into a message after execution in case the user missed it as the lines scrolled by.
Background: I wrote a small data validation program, about 600 lines, that allows the user to select an excel file which will be automatically imported, processed, and exported again. I tried hard to include automatic checks in the code (such as checking for required column names and throwing a pop up box if not present), but am aware that I can't think of every possible error that could occur, especially with other users. What I would like is to have every error/warning/etc. that occurs during sourcing to be written to an object that I could then call later such as in a pop up box. I have been able to figure out every step except for creating the error log.
ErrorLog <- (code for collecting errors/warnings here)
(Program Code - already completed)
ErrorPopUp <- tkmessageBox(title = "ERRORS", message = paste("
Please note the following errors/warnings occurred during file processing:
",
ErrorLog ,
"To proceed and export file please press OK. To exit the program without
saving, please press cancel."), icon = "warning", type = "okcancel")
(code to continue and export or quit)
I appreciate any ideas, and thx for the patience as I saw many posts on advanced topics such as creating your own error messages or sending them to windows, but none for simply writing an object listing them.

Basic Alexa Skills

I have downloaded the Alexa Skills online tutorial found at:
https://github.com/amzn/alexa-skills-kit-js/blob/master/samples/reindeerGames/src/index.js
and followed (I think) all of the instructions in the tutorial found at:
https://developer.amazon.com/public/community/post/TxDJWS16KUPVKO/New-Alexa-Skills-Kit-Template-Build-a-Trivia-Skill-in-under-an-Hour
This is meant to be a tutorial for first time Alexa Skills developers. My question is, I get this error message once I hit the "Save and Test" button:
errorMessage": "Exception: TypeError: Cannot read property 'application' of undefined"
Does anyone know what the above error means or how to get rid of it?
Thanks v much.
This looks like a javascript error telling you that you are trying to use a property named application on an undefined variable.
JavaScript assigns the value "undefined" to any variable that you use but haven't set yet.
There are a several ways that you can debug problems in your Lambdas. Perhaps the easiest is to review the Logs. To do this:
Go to the Lambda console (where you upload your code to Lambda)
Select the Monitoring tab
Select "View logs in CloudWatch" (in the upper right)
Review the latest log, looking for a reported error in one of your files (typically index.js) and specifically the line number. That should help you find the error.
Note that the time stamps will be GMT, so probably won't match your actual time. This can be confusing if you have multiple entries. But the minutes should match, helping you verify that you're looking at the correct log entry.
A more advanced, and quicker way to debug Lambda problems, is the include a "test" request, and run this each time you upload code to Lambda.
To set this up:
Run one of your defined utterances in the ASK test page under the "Service Simulator" section.
Copy the code displayed below that in the "Lambda Request" section.
Now switch to the Lambda console for your Lambda function
Click the down arrow in the Actions button and select "Configure test event"
Paste the request you copied above into the text field
Click Save and Test.
Now each time you upload new code to Lambda, you can select "Test" and the request that you just saved will be run.
And best of all, the console log will be displayed in the lower right corner, saving you from having to switch to the logs and refresh to view them.

browseForOpenMultiple - crashing

I am trying to work with browseForOpenMultiple function inside Flex, sdk 3.5, I am trying to figure out a bug. The browseForOpenMultiple does not crash everytime, but it seems as though I can upload a file once, but when I go to upload a second file, it crashes when the browseForOpenMultiple function is called. Anyone have any ideas about possible causes?
Update:
private function browseForFiles():void
{
fileBrowser = new File();
fileBrowser.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
fileBrowser.addEventListener(Event.CANCEL, fileSelectionCancelled);
fileBrowser.browseForOpenMultiple("Select Desired Media File(s)", [(mode == "Media")? MediaTypes.getFileFilter() : MediaTypes.getVideoFilter()]);
}
So the code in our array of file extensions was crashing when there were over 60 items listed in an array that gets converted into a string for the FileFilter. This may not be an Adobe limit, but I wanted to make mention that the crash is fixed, so that others who may be encountering issues with browseForOpenMultiple will know what the issue was for this problem. This is not code that I originally wrote, so I will check into it for more clues, but for the time being, too many array items being joined together into a string for FileFilter object caused the crash.
It could be how it's construct the File, without a real file reference.
Try something like this :
var fileBrowser = File.desktopDirectory

Resources