How to browse through the full command history in RStudio - r

Occasionally I had not saved my source script, and its old version opened. I can find the new version which was executed during the previous session, but only like shreds: I search in history and it shows me a piece of code, but not all lines though they were executed simultaneously. Is there any way to access the complete history, which is definitely stored somewhere, but not shown as a whole? Thanks!
I am using R version 3.6.2 and RStudio Version 1.2.5033.

Search for the "history_database" file. It is an ASCII file and it is usually stored in the folder
C:\Users\username\AppData\Local\RStudio-Desktop

Please, take a look at: https://support.rstudio.com/hc/en-us/articles/200526217-Command-History
use shortcut key Ctrl + 4 to put focus on history or Ctrl+Shift+4 to enlarge window of history. Let us know

Related

Creating a file with write.table and file.choose on Mac

I am a PC user and have used the write.table (and write.csv) extensively.
I am teaching students how to use R, but some of them use a Mac.
On a PC, the following code:
write.table(mydata, file.choose(), row.names=F, col.names=T)
opens up a browser window, allowing the user to specify the folder where to save the new file, and specify the file name and extension. (Strangely enough, the user is then prompted to click the button "Open" to create a file.)
On a Mac however, it appears there is no way of specifying the name and extension of the file being created, once the window opens. In other words, there does not seem to be a way to actually create a file.
Am I missing something?
Is the solution simply to replace the "file.choose()"
with the full path to the new file?
LGTM:
Having said that, if your student is using RStudio then you would normally need to go to their github repo and file an issue but I've already done that https://github.com/rstudio/rstudio/issues/3903. They seem to intercept the call and pass it to Qt which is not honoring it (it's not a macOS issue but a Qt issue).

How to access the script/source history in RStudio?

I would like to access the history of what have been typed in the source panel in RStudio.
I'm interested in the way we learn and type code. Three things I would like to analyse are: i) the way a single person type code, ii) how different persons type code, iii) the way a beginner improve typing.
Grabbing the history of commands is quite satisfying as first attempt in this way but I would like to reach a finer granularity and thus access the successive changes, within a single line in a way.
So, to be clear, I'm neither looking for the history of commands or for a diff between different versions of and .R file.
What I would like to access is really the successive alterations to the source panel that are visible when you recursively press Ctrl+Z. I do not know if there is a more accurate word for what I describe, but again what I'm interested in is how bits of code are added/moved/deleted/corrected/improved in the source panel but not necessary passed to the Console and thus absent from the history of command.
This must be somewhere/somehow saved by RStudio as it is accessible by the later. This may be saved in a quite hidden/private/memory/process/... way and I have a very vague idea of how a GUI works. I do not know it if would be easily accessible, then programmaticaly analyzed, typically if we could save a file from it. Timestamps would be the cherry on top but I would be happy without.
Do you have idea how to access this history?
RStudio's source panel is essentially a view to an Ace Editor. As such you'd need to access the editor session's editSession and use getDocument or getWordRange along with the undo of the editSession's undoManager instance.
I don't think you'll be doing that from within RStudio without hacking on the RStudio code unless the RStudio Addin api is made to pass-thru editor events in the future.
It might be easier to write a session recorder as changes are made rather than try to mess with the undo history. I imagine you could write an Addin that calls a javascript to communicate over the existing RStudio port using the Ace Editor's events (ie. onChange).
As #GegznaV said, RStudio saves code history to a ".RHistory" file. It's in the "Documents" folder on my computer. It's probably the same folder if you're using Windows. If you do not know the location, you can find the file by searching.
It also allows saving RStudio history to a file manually. There is a "Save" button in the History panel. So you can also get a timestamp. You can ask different users to save their code history after they have finished writing code. It may be indirectly useful to your research.

Under R,regarding getting the list of the commands previously typed

Under R, is there a way to list all of the commands that have previously been typed?
Yes there is.
history(max.show=Inf)
IDEs for R often support this feature in a panel. RStudio, for instance, has a history tab from which you can send a previous command to the console or to your source file with a click. I believe others are similar functionality as well.

How can I have history completion / filtering when running R in Windows using the up/down arrows (like MATLAB)?

I'm used to using R in Linux, which is wonderful. However, I really need to be using Windows. I've been using Rgui.exe that comes with the R installation and the history completion feature is missing. By this, I mean that I can start to type a command and then press the up-arrow to browse through the history for commands that start with what is typed (similar to the way MATLAB handles the history).
The closest thing I've found is to use RStudio, which allows this functionality with "Ctrl+Up Arrow" (which is a livable solution). It would be nice to be able to do this with just the arrow keys and to do it in Rgui.exe or other minimal R interface. Any suggestions?
If you run R from Cygwin, you can use reverse-i-search to cycle through commands that match the given pattern and which have been executed during the current R session.
Hit CTRL-r to initiate the reverse search, then as you type the pattern to be matched against the history, the most recently executed match will dynamically appear. Keep pressing CTRL-r to cycle through the matching items.
In the example depicted below, I've initiated a reverse search for 'LET'.
Use RTerm.exe, as this includes tab completion (its very strange that RGUI on Windows doesn't, especially as the Mac GUI does).

Where can one find source archives of old SQLite versions?

The downloads page on www.sqlite.org appears to only have links to the current version, and I would like to get a previous version. I cannot see any obvious links to historical versions on the site and (unless I'm missing something obvious) there does not appear to be a sourceforge project.
Can someone point me at an archive of old SQLite source releases if such a thing exists?
Nigel.
I found this in their old message list archives. Hopefully this helps:
Older version of SQLite are aviable
from the website, but there are no
direct links on the web pages. You
need to manually edit the links to
get the file you need.
The 2.1 version of the database file
implies that it was created with a
2.X.Y version of SQLite. You should get the latest version which is
2.8.17 (I believe).
If you go the download page
http://www.sqlite.org/download.html
and the right click on the link to
download the latest Windows binary
file, then
select Copy Link Location (at least
using Firefox, in IE the command is
Copy Shortcut). Now open a new tab or
window and paste the link into the
address bar. You can edit the link and
replace the version number with the
version you want to download. In your
case you need to change
http://www.sqlite.org/sqlitedll-3_5_6.zip
to
http://www.sqlite.org/sqlitedll-2_8_17.zip
and then press enter to start
I know this question is kind of old but there's an easier way to get the URL to the older zip files.
Using a combination of answers here, you can calculate the download URL of the zip file for the specific version you want.
Determine the version number you want to get (we'll use 3.8.7.4 as an example)
Look on the timeline (http://www.sqlite.org/src/timeline?t=release) to figure out the year in which your desired version was released (3.8.7.4 was released in 2014)
Normalize the version number into exactly 7 digits. Expand each piece into 2 digits with leading zeroes except for the initial 3 which should remain 1 digit. For example 3.8.7.4 becomes 3080704. 3.13.0 becomes 3130000. (If there is no 4th period delimited piece, use 00)
Using your normalized version number, plug it into one of these formats, depending on what you're looking for (Replace the text '7DIGITS' in the urls below with your normalized version number, replace the text YEAR with the year in which the version was released
Source: http://www.sqlite.org/YEAR/sqlite-src-7DIGITS.zip
Amalgamated: http://www.sqlite.org/YEAR/sqlite-amalgamation-7DIGITS.zip
So our example versions become
http://www.sqlite.org/2014/sqlite-src-3080704.zip and http://www.sqlite.org/2014/sqlite-amalgamation-3080704.zip
I haven't tried this for every version but my 3 test versions worked. I would imagine the other download types (like precompiled binaries, documentation, etc) work as well.
Direct Access To The Sources
Also, if you want to compile yourself. Access to all SQLite source code is maintained in a CVS repository that is available for read-only access by anyone. You can interactively view the repository contents and download individual files by visiting this link
Also
www.sqlite.org/src/timeline?t=release will show when every sqlite version was released.
Checkout from cvs from the date you want and compile. Instruction how to checkout from cvs are here
Note: Use the -D option to checkout by date
The idea from TomWitt2 is fantastic (I had spent hours to find solution) but now the links seems to be have modified so follow below steps to get your archived version:
Get the latest version link from the download page here http://www.sqlite.org/download.html
Get your normalized 7 digit number as mentioned in answer by TomWitt2
Just replace the number in the link and you are ready to go
I've tried a few solutions on this page and elsewhere, all that I've seen seem outdated and no longer work. I've done the steps below as of 5/4/2016 with success.
Go to http://system.data.sqlite.org/index.html/finfo?name=www/downloads.wiki to view the history of the SQLite downloads wiki.
Search (ctrl+f) for the version you want (ex. 1.0.91.0)
Select the commit ID and it will open that old version of the page complete with download links to source code as well as precompiled binaries and setups.
You won't always find the version in a search (ex. 1.0.98.0), but it should be reasonably easy to find the correct page by the surrounding versions/commits.
You can also check archive.org for the downloads page:
http://web.archive.org/web/20150101000000*/http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
Find the date that your desired version was released on from the SQLite news page (you may need to pick the next archive date after that). Select your desired link (sometimes the download page was archived, more ofter it seems like it was not). If the download page was not archived, edit the address bar to remove the archive.org-related info and you should be able to navigate directly to the SQLite download page for that version.
Follow this link to the official website and under "3.0 Obtaining Code Directly From the Version Control System" you can read further directions:
get the list of release check-ins (this link)
choose the required check-in
download source code archive
The oldest release available now is from
2007-08-13.
You are correct to point out that https://www.sqlite.org/download.html only links to the most recent release, but a page always linking the current release combined with Wayback Machine preserving every (well, hopefully) version of said page, is all you need to download your favorite release:
http://web.archive.org/web/*/https://www.sqlite.org/download.html
Given that the binaries themselves have not been removed, of course, but fortunately they seem intact to me.
In fact, I just downloaded SQLite 3.9.2 through this page:
http://web.archive.org/web/20151231190003/https://www.sqlite.org/download.html
You can get all release of SQLite from https://www.sqlite.org/chronology.html, this page contains the history of SQLite releases

Resources