Where are files written to in R? - r

If I use the write method, where will these files be written? Example:
write(results, file="myFile.csv", ncolumns=1)
I don't specify a full path so I assume it's writing to some default directory. I checked program files, but it's not there. Suggestions on where to look?

If you type from within your R session:
getwd()
You should be able to retrieve your current working directory, that's the place where the files should be saved to.

You can also choose to set your workspace to a location of your desire:
setwd('C:/Users/.../Documents/R/Scripts')
Files you save will automatically be written to this new location.

Related

Enable tab completion to find file in Julia outside working directory

How can I enable tab completion in Julia with a function I wrote that loads a file outside of the working directory? Tab completion is super nice, but it only seems to work for files in my working directory. e.g. I store all of my files in a directory foo and I wrote a function to conveniently read these files.
const WHEREMUHFILES = "foo/"
function read_foo_file(filename::String)
readlines(WHEREMUHFILES * filename)
end
However, when I try read_foo_file("ba and hit Tab, tab completion doesn't work, in that it doesn't search the directory WHEREMUHFILES for bar.txt. Is there a way to enable this?
In reality, I have many different types of files organized in different directories, and the read_foo_file populates complex data structures after reading in the files, so a simple work around such as "put your files in your working directory!" is not what I'm looking for.

changing file names, how to?

I've created some forms following this approach:
iron g:template cars/create_car
and the following files were created:
create_car.css
create_car.html
create_car.js
Easy question - if I want to change the name of the files where else do I have to update to keep my changes in sync with the rest of the application?
Thank you!
Mark
You won't be out of sync by changing file's name.
The only things which would change is the file load order, according to the documentation:
HTML template files are always loaded before everything else.
Files beginning with main. are loaded last
Files inside any lib/ directory are loaded next
Files with deeper paths are loaded next
Files are then loaded in alphabetical order of the entire path
On your case It's wouldn't probably cause any issue, feel free to test.

Flex : Create new folder in zip file

I am using Flex, Flash Builder 4.5 and Extension Builder 2.0.0 and I use the "nochump ziplib" library to generate a ZIP file. I want to create a new folder in created ZIP file, but I can't find such function function in the "nochump" library.
Can anyone please tell me if there is any function to add new folder in a ZIP file or a library which can help me do this?
The directories are not first-class citizens in the ZIP format.
The archive is built from "entries" - plain files with their relative locations to the "central directory" (the "root" of the archive). This means that the ZIP file is composed from entries like "pictures/1.jpg", "doc/old/1.txt" etc. You don't have separate entries for the "pictures", "doc" or "doc/old" directories.
You can't create a new directory directly. Instead of creating a new directory first (such as "newDir") you may want to create a file (entry) inside instead (such as "newDir/1.txt") and "newDir" will appear as directory when you open the resulting ZIP file.
If you insist on having an empty directory in the archive, you may try the hacky way - adding entries like "newDir/." with zero length. But this may not work with your library.
The Wikipedia article for the ZIP format has all the theory explained pretty well.

Drools 5 load drl rule file from file system

I devloped a custom rule editor able to create drl file and save them in file system under a given directory. (e.g. c:\savedRules\rule.drl).
The problem is that once the rule is saved I need to run it with drools engine.
In my class I try to load rule in this way:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("c:\savedRules\rule.drl"), ResourceType.DRL);
but its doesn't work. the exception is "rule.drl cannot be opened because it does not exist" but it actually exists....
What am I doing wrong? Is there another way to load rules directly from file system?
Try using,
FileInputStream fis = new FileInputStream(drlFile);
kbuilder.add(ResourceFactory.newInputStreamResource(fis), ResourceType.DRL);
Thanks.
kbuilder.add(ResourceFactory.newClassPathResource("LoopConditionRules.drl"),ResourceType.DRL);
Just add this line and copy your drl file in resource folder of the project, when you will run it will automatically find the file from the project there is no need to give specific path for your file.
Try this way, may be you can get your required result.
Try the below code, this will work.
kbuilder.add(ResourceFactory.newFileResource(drlFileName), ResourceType.DRL);

System::IO::Directory::GetFiles in c++

I am having trouble in storing the files in a string array from a directory in c++, using System::IO::Directory::GetFiles in c++
Also would like to know if we could copy an entire folder to a new destination/ in c++ like given in http://www.codeproject.com/KB/files/xdirectorycopy.aspx for c#
You can store the file names from a directory in a managed array like this:
System::String ^path = "c:\\";
cli::array<System::String ^>^ a = System::IO::Directory::GetFiles(path);
Console::WriteLine(a[0]);
Console::ReadKey();
As for how would you copy an entire folder... Simply recurse from a given root directory creating each directory and copying the files to the new location. If you are asking for code for this, then please say so, but at least try to figure it out for yourself first (i.e. show me what you have so far).
Check out the file listing program in Boost::FileSystem: http://www.boost.org/doc/libs/1_41_0/libs/filesystem/example/simple_ls.cpp. They iterate over all files, printing the paths, but it's trivial to store them instead.
Assuming you're on Win32, you're looking for the FindFirstFile and FindNextFile APIs.
C/C++ does not define a standard way to do this, though Boost::Filesystem provides a method if you need cross platform support.

Resources