[R] A little bit on multidimensional arrays and apply()

The command-line can be a little unintuitive when dealing with multidimensional objects since it is a 2D medium. It is therefore hard to envision objects greater than 2-dimensions. They exist however!

An array, in R, is simply a vector (list of objects) where each element has additional “dimension” attributes. In other words, each vector element is given a dimensional position. This is fairly easy to represent 3-dimensionally (see below) but there is no reason why additional dimensional attributes cannot be applied to each vector element, placing them in the 4th, 5th…nth dimensions.

Using array(), I created a 3-dimensional array object (represented by that box with numbers you see below) populated with values 1 to 4. Each of these is given a dimensional attribute, the 1’s located are located at [1,1,1] and [1,2,1]. The 4’s are located at [2,1,2] and [2,2,2], and so on.

Here is the array function:

array(data, dimensions,...)


The first argument of array() is the actual data to be used. The second argument is dimensions which is an integer vector referring to the maximum dimensions of the array; for the example above, this is 2 by 2 by 2.

Using apply(), we can perform functions on elements which are aligned in certain directions, in this case sum(). The array() function takes the following arguments:

apply(X, margins, FUN)

where X is the array over which apply should be…applied, margins is an integer vector telling R which margins (dimensions) to maintain and which to collapse, and FUN is the function to by applied. Basically, the apply() function is taking the sum over all elements in a certain edge of the cube. The margin attributes simply tell R which edges we are summing over. In the examples below, R converts a 3D array object into a 2D object. You can see the effect of changing the margins attribute on the final result of the summed arrays shown below.


USA-France Quirks

Things Americans might find strange in France

I created this list based on things that my other American friends and I noticed in France.

1. Square Pillows

If you go to an IKEA or any sort of bedding store in France, odds are you will only find square pillows for your bed. I’m sorry but this is ridiculous. They have 50% of the capabilities of a rectangular pillow, and are just not as comfortable.


2. Separate Toilets

I don’t mean like in a separate bathroom alcove, no. In both apartments I had in France and many of the ones I visited the toilet (WC) was completely on the opposite side of the apartment from the bathroom. This meant that after going to the bathroom you would have to cross the entire apartment, including kitchen and dining room, just to wash your hands.


3. Sugar Daddy

When you need sugar in France, you need Daddy.


4. Hollywood Gum

Hollywood gum is a very popular brand of gum in France and french people were always a bit shocked that we don’t carry it in the US.


5. Soldiers with Machine Guns

One thing that I did find a little unnerving in France was that there were a significant amount of military patrolling city centers, train stations and trains.


6. Line Etiquette is Nonexistent

There is no such thing as a line. It is a free-for-all full of elbows, dirty glances and money-waving. The worst culprits are the miniscule, ancient French women sporting completely polyester wardrobes who wield their shopping carts like elven-forged swords.


7. Drivers don’t use AC to save gas

As of today (June 6, 2015), gas is $5.54/gallon in France. When the dollar was weaker this number was more like $7/gallon. It’s no wonder that Europeans try to save on gas.


8. Post-Dinner Coffee

Coffee must be taken after dessert. This has however led to the magic that is Cafe Gourmand.


A couple other small things:

  • You’ll get looks if you put milk in your coffee after 9am and aren’t a baby

  • There is a total lack of peanut butter in Europe

  • Strikes or les grèves (they are a way of life in France)

  • You don’t tip in restaurants

  • It seems like every single person in France smokes sometimes

Things French people might find strange in America

These items were curated by real-life french people (Merci Denis et Marjo).

1. Sour Cream

Just sour cream.


2. Pristine Fruits and Veggies

Our fruits and vegetables are all unnaturally perfect. From my experience, the fruits and veggies in France were tastier and smaller than their American counterparts. Except avocados. Avocados in France aren’t great.


3. American pedestrians wait at red lights

I personally think this depends more on the city that you are in but we do seem to follow the rules a bit more about crossing the street.


4. No dessert with every meal

French people might find this shocking but not every meal here ends with something sweet.


5. 24/7 Dining

Restaurants are always open, you can pretty much eat whenever you want.


A couple other small things:

  • Employees say “how are you” as a way of saying “hi”

  • Our restaurants don’t often have price fix menus

  • Carpool lanes do not exist in France

If there are any international quirks that you’ve noticed please let me know in the comments below! :)

Wiki is up!


One of the goals that I’ve had for a long time is to create the wikipedia page for freeze-casting. Even though it’s a relatively “hot” technique, at least in the ceramics world. There wasn’t a single entry for freeze-casting. This meant that when I started the project I actually had to read scientific literature to figure things out. The closest thing to freeze-casting on wikipedia was a topic known as freeze-gelation which is really not freeze-casting. 4+ years after I started my thesis there was still nothing on wikipedia in regards to freeze-casting. I’d already done all the research and spent literally 100s of hours creating figures and getting references for the topic so I figured why shouldn’t I do it. The article isn’t comprehensive as there are many topics to cover but I think it does a good job at explaining the basic concepts required for freeze-casting. Apparently wikipedia however thinks it still has many problems (it was graded as a Class-C article) but it’s been accepted and is available for public viewing.

For reference, a C-Class Wikipedia is defined as follows:

The article is substantial, but is still missing important content or contains much irrelevant material. The article should have some references to reliable sources, but may still have significant problems or require substantial cleanup.

If you’re interested please take a look, make edits if necessary and link to it if desired. Thanks for reading!

Go learn English!


A quick note on customer service and language barriers in London.

I was travelling from St. Pancras station in London to Paris using the Eurostar. While waiting for my train I decided to use my remaining British pounds to purchase a flat white, my drink of choice. I waited in the rather substantial line full of business people and tourists alike and finally got to the front register where I ordered my drink from the haggard, albeit efficient Russian woman at the register.

“One flat white please” I said.

“Ok that will be 3 pounds”

Transaction finished, I stepped aside to wait for my drink and busied myself with my phone seeing as how there was free wifi in the station. A few minutes passed and the woman called to me.

“You got a flat white?” she asked.

“Yes, I got a flat white” was my response.

Then I went back to staring at my phone and waiting. About 5 minutes went by and the Russian woman then yelled out. “What are you doing here!? Get out!”

I looked at her perplexed and said, “I’m waiting for my drink.”

Suddenly furious, the woman looked at me and yelled “You told me you got it!”

Totally bewildered now, I stared around at my fellow coffee drinkers. A kind woman in line then attempted to point out that by me saying I “got” a flat white, I meant I’d “ordered” one. This was unimpressive however to the Russian coffee demon who looked at me and said “You should learn to speak English.”

Ummmmmm what?