How to see original script or function from RData? - r

I created a very small script (without saving) in RCmdr top window, but I only saved the workspace.
When I reload this I can't see anything that was in the top window originally. My mistake I know, but is there a way to see any hint of the functions etc I may have called, from the workspace file? I can see the objects - but not what created them.

If you open a new R session, try hitting the up-arrow keys. The normally invisible .Rhistory file is usually loaded at the start of a new session if the prior session ended normally. If the session is open in a GUI hten you may be able to display the list of commands with a menu command. This may also display that file:
loadhistory(file = ".Rhistory")
The history is cumulative, so unless you had a really long session intervening you may still be able to get code going back for several session. I think it keeps the last 500 entries by default. Actually turns out to be 512. See:
?history

Related

Automatically Reinstantiate a Template Instance in Tosca

I am working with a Test Case that takes input from an excel file in Tosca. I'm using a Template Instance so the data from the excel gets loaded and I can use it in my test case. I know I can reinstantiate the Instance by clicking on the Reinstantiate button, but I'm running the Test Case from an external source, so I can't go to Tosca and click the button every time I need to update the input (the data of the excel input is different every time I run it).
Is there a way to make Tosca automatically Reinstantiate the Template Instance every time I run it?
No, unforunately there is NO way to do it automatically. It is not even possible without a great effort to (re)instantiate several templates at once.

Task Scheduler - Argument - Add timestamp to opened Excel document and close Excel

tldr - Task Scheduler, Edit Action, Argument = (open excel without app selection, add date-time to cell, close Excel)
I'm new to using Task Scheduler and am looking to add a date-time stamp into the opened Excel document.
It can be very simple, it just needs to be in the next cell/row and close. 
It also seems there is a difference in an application opening through Task Scheduler because it will ALWAYS ask what to open it with(yes, default extensions/apps in Settings/file set).
So it seems even with an argument, it will still be stopped? Is there a way around this is as well? I have modified permissions on the file, but that doesn't seem to work.
You can use a.txt if it is easier.
Thank you all you wonderful community!

Why everything in RStudio workspace vanishes every time I close it?

Every time I close and open the RStudio, everything in the panels including all the data frames, functions, values, etc. vanishes and some very old ones that I have deleted long ago appears. I save workspace when I want to close it, but this happens every time. Importing my large dataset and generating everything again every time takes a lot of time. What can I do?
You can save your workspace and restore it under Tools -> Options -> General.
Please see picture below.
In addition you can also use:
save.image(file='Session.RData')
And load it later:
load('Session.RData')
However, generally speaking, some consider it bad to keep/save your environment/workspace.

I do NOT want my global environment to clear in R on exit

Even if I indicate "NOT" in a Google search, there is literally no result for this. Everybody wants to clear their global environment.
I am just starting with R so I want to keep all my data and variables so I can play around. Every time I exit R it clears the global environment unless I save the image to a work space .RData file.
How can I keep all my environment intact without have to save twice every time?
If you use RStudio, you can just set the option "Global Options" --> "Save workspace as .RData on exit" to "Always", and the environment will be saved automatically and loaded the next time you open the same project.
AFAIK, saving to a RData file is the easiest way to save the "state" of your environment across sessions. Incidentally, if you do not want to save your objects somewhere, how can you expect to be able to retrieve them afterwards ?

Cache items corrupt or mixed up

I have a very strange problem with a website where several objects are cached.
We have a lot of DataTables, strings, booleans and other stuff that are cached for quick fetching in later requests.
Sometimes we get a periodic error where it looks like some of the cache items have been mixed up.
An example of how this shows itself is when a piece of code fetches a DataTable from the cache and then tries to access a certain column of that DataTable.
We then see a yellow screen of death with the exception "Cannot find column [ColumnName]", where "ColumnName" of course is some column name that was supposed to be in the DataTable.
When I inspect the cache item with a little home made tool, I see that a completely different DataTable is in the cache item. It is almost like some of the cache items have been mixed up.
Does anybody have an idea how this happens?
We are not able to reproduce the error. It occurs at apparently random intervals.
Whats the issue
When you add items to the cache, you need to lock the process that you create them and added to the cache.
First lets clarify that the cache is keep a reference to your data, is not clone them, nether knows whats is not that data ! reference: http://msdn.microsoft.com/en-us/library/6hbbsfk6(VS.71).aspx
Second clarify that the default session of a page is lock the pages and is by make most of the request safe because all users lock until a page fully load and send.
When its appear
So the lock issue may appear when you try to make cache by a thread, or by a handler, or by a page that have session off.
How to lock
If you use only one pool, then the simple lock(object){} can work, if you use many pools then you need to use mutex() for lock
You need to lock the full process of making your data if you change them later and still existing on cache, or only the cache reference if you make clone of them.
For example, if you read some data that you have get from the cache, then the time you edit them, if some other read the same cache it will get corrupted data, because the cache is give you a reference to them.
Hope that all this helps.

Resources