Trying to import data into R in a way that will allow anyone to access it when opening the markdown file/ accessing the html knit - r

I am currently working on a coding project and I am running into trouble with how i Should import the data set. We are supposed to have it read in a way so that our instructor can access our markdown file and be able to import the data and run the code without changing file paths. I know about using relative file paths to make it accessible to anyone, however I don't know how to get around the /users/owner part of the file path. Any help would be greatly appreciated and if you have any further questions feel free to ask.
I've tried changing the working directory to a certain folder that both I and my instructor have named the same thing, however, like I said above, when I use read.csv to import the data frame I am still forced to use the /users/owner filepath which obviously is specific to my computer.

I can understand your supervisor, I request the same from my students. My recommended solution is to put both data and R script (or the .Rmd file) in the same folder. Then one does not need to add a path in the read.csv (or similar) function.
If you use RStudio, move to the folder in the Files pane and then use the gear icon and select "Set as Working Directory".
Then send both files (.R or .Rmd) and the data to the supervisor, ideally as a zip file. The supervisor can then unpack it to an arbitrary folder and just double click to the .R/.Rmd file. The containing folder will then automatically become the working directory.
Other options are:
to use a subfolder for the data or
to put the data to a publicly readable internet location, e.g.
Github and read it directly from there.
The last option requires of course that the data have a free license.

Related

Databricks, Folder Management and SQL. What is happening behind the scenes?

New Databricks user.
Im able to create subfolders in the user directory I am provided.
E.g. I am provided /mnt/DUAXXX/USERID/files
and I can create /mnt/DUAXXX/USERID/files/subfolder.
However, I cannot figure out how to create tables in this subfolder and use the resulting dataset.
I issue the following command, because the source datasets reside in this location:
%python
use DUAXXX
However, I want to create the resulting dataset in the subfolder.
Ive tried something like:
create table test
location 'mnt/DUAXXX/USERID/files/subfolder'
select * from
data
This completes, but when I navigate using the Databricks GUI 'Data' tab, the test dataset appears in the DUAXXX folder.
However, when I issue the following command:
dbutils.fs.ls(f"dbfs:/mnt/DUAXXX/USERID/files/subfolder")
I see numerous sorts of .snappy.parquet files.
I know these files are created by the above code.
Its as though the underlying data is stored where I want them in this .snappy.parquet format, but Databricks is creating a link to all these files in the DUAXXX folder.
I realize a lot of this is likely down to how the administrations implemented Databricks, and I have no access to those people. Does anyone know what is actually going on here?
Ultimately, all I am trying to do is create subfolders to organize my datasets, rather than have everything in a single folder.
Thanks.

How to extract infos in a .db file to create .csv or any viable "bookmark" file?

I am using a quite unknown bookmark manager on Android. I picked this one after trying others because it was possible to import, export, classify by folders, the design was good and it was easy to search in my bookmarks.
After importing all my bookmarks from other browsers and also from files, I started classifying all of them into folders, subfolders, etc..
I spent many days to classify them all as I wanted.
After classifying them, I tried to export them.
The problem is that the only option offered is to export them in a .html file, containing all the bookmarks but without any folder.
The .html file contains all my bookmarks but in complete desorder, and doesnt mention the folders.
In the app there was also a "backup" function, so I tried and it creates a .db file.
I opened this .db file with some SQLiteViewer app and I found written inside, among other things I dont understand, a list of all my bookmarks with a number next to each one of them, and also a list of my folders with next to them the corresponding number.
When I open the .db file, I have a choice between
-SQlite master
-android metadata
-bookmarks
-folders
-sqlite sequence
If I click on "Bookmarks", all my bookmarks are in a kind of spreadsheet with lines and columns. Next to them in another columns, for example for each bookmark related with "Kitchen recipes" it's written the number 1.
And in the "Folders" folder, next to the folder called "Recipes" its also written 1.
So I'm happy because it seems that my classification is stored in this file.
But the fact is I dont know how to extract easily all that data, and create with it a "bookmark" file importable in other bookmark app or browser ( for example .csv or .xbel or .html but with folders)
I guess I need some "script" working like this:
if the first raw in "Folders" got the number 8 next to it
Then take all the bookmarks in the "bookmarks" folder that also got an 8 written next to it, and put it inside this folder.
I'm a complete noob in coding, I dont know what is SQlite, nor anything.
So i know that maybe I am asking for too much informations at the same time.
But if some kind person could put me in the way, by explaining me if
thats possible
what would be the easiest way
if some solution already exist
if someone like me can do it and what do I have to learn if I want some day to be able to do it
Thanks
Here's pictures so you understand easier:
Sqlite
Folders
Bookmarks

Ado Brackets Efficient File Finder

Is there anyway Adobe Brackets Editor find a file as fast as typing a filename and avoid going through the sidebar? Much like finding a text with ctrl-f?
As others have mentioned – use Navigate > Quick Open, which you can also access via the shortcut Ctrl-Shift-O.
Quick Open is very powerful: you can type just an abbreviation or parts of a filename to find it with less typing. For example, typing "fbu" or "fooutil" will find "FooBarUtils.js".
Edit:
to answer the question about scope... Quick Open searches in your entire project. Brackets treats the root folder you have open (the root of the folder tree you see at left) as your project. To choose a folder, choose File > Open Folder.
There's no way to restrict Quick Open to just a subfolder within that project, but you can type part of a folder name and Quick Open will factor that into the search results. For example, typing "foo/bar" or even "fbar" will list "foo/bar.js" or "foo/xyz/bar.js" higher in the results. This is useful if you have many files with similar names within your project.

Change Working Directory (pwd) to Script Location in Stata 12

I have a lot of scripts (.do files) in different folders, which are frequently moved around. I would like to have Stata detect where the script is, and use that as a pwd (working directory). I know people that have this functionality seemingly by default (the pwd is changed to the script location when the script is run), but we cannot figure out why I am not so lucky. It is a bit tedious always having a "cd" line at the top of my scripts, and having to change this line to reflect the current directory. I'm using Stata 12 with Windows 7 Professional.
It looks to me like something similar is answered in this question:
Paths to do-file in Stata
What it seems like you could do is keep an MS Excel file that somehow tracks the location of all your scripts, and then use that to generate a simple high-level do-file that calls all your programs (although this may not be how your scripts work). If your folder locations are changing I am not sure how you can completely avoid updating at least some lines of code when something gets moved around. This would at least centralize the necessary updates into one place.
You can use Sublime text.
https://sublime.wbond.net/packages/Stata%20Enhanced
When you build the do file (or a selection) using sublime text, the filepath of the do file automatically becomes the current directory.

Extract zip file in flex

Is there any method to extract zip files and maintain the same folder structure in the output folder.I am able to extract the zip file and its inner files but not able to extract folder from a zip file and thus fail to maintain folder structure also.
Yes.
There is an AS3 component that allows you to read and write data from zip files, and the demo also shows that it is possible to see the folder structure.
http://www.nochump.com/blog/?p=15
I have not used this component myself, but if I am correct in assuming that you are making an AIR application then this component may automatically generate folders, otherwise you can use the file system api to create the correct folders yourself.
Good Luck!
You may also want to check out fzip:
http://codeazur.com.br/lab/fzip/

Resources