Functional Programming in R 4 - Second Edition Thomas Mailund download
Functional Programming in R 4 - Second Edition Thomas Mailund download
https://ebookmeta.com/product/functional-programming-
in-r-4-second-edition-thomas-mailund/
https://ebookmeta.com/product/functional-programming-
in-r-4-advanced-statistical-programming-for-data-science-
analysis-and-finance-second-edition-thomas-mailund/
https://ebookmeta.com/product/functional-data-structures-
in-r-1st-edition-thomas-mailund/
https://ebookmeta.com/product/functional-programming-in-c-second-
edition-enrico-buonanno/
https://ebookmeta.com/product/deep-generative-modeling-jakub-m-
tomczak/
CLEP Introductory Business Law Book Online 2nd Ed 2nd
Edition Lisa M. Fairfax
https://ebookmeta.com/product/clep-introductory-business-law-
book-online-2nd-ed-2nd-edition-lisa-m-fairfax/
https://ebookmeta.com/product/execution-giordano-bruno-6-1st-
edition-s-j-parris/
https://ebookmeta.com/product/love-that-journey-for-me-the-queer-
revolution-of-schitt-s-creek-1st-edition-emily-garside/
https://ebookmeta.com/product/violence-against-women-and-
criminal-justice-in-africa-volume-ii-sexual-violence-and-
vulnerability-1st-edition-ashwanee-budoo-scholtz/
https://ebookmeta.com/product/a-practitioners-guide-to-account-
based-marketing-accelerating-growth-in-strategic-accounts-2nd-
edition-dave-munn/
Taken by the Russian Boss 1st Edition Bella King
https://ebookmeta.com/product/taken-by-the-russian-boss-1st-
edition-bella-king/
Thomas Mailund
Functional Programming in R 4
Advanced Statistical Programming for Data Science,
Analysis, and Finance
2nd ed.
Thomas Mailund
Aarhus N, Denmark
Apress Standard
The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, express or implied, with respect to the material
contained herein or for any errors or omissions that may have been
made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
1. Introduction
Thomas Mailund1
(1) Aarhus N, Denmark
2. Functions in R
Thomas Mailund1
(1) Aarhus N, Denmark
Writing Functions in R
You create an R function using the function keyword or, since R 4.1,
the \() syntax. For example, we can write a function that squares
numbers like this:
or like this:
## [1] 1 4 9 16 25
The shorter syntax, \(x) x**2, is intended for so-called “lambda
expressions,” and the backslash notation is supposed to look like the
Greek letter lambda, λ. Lambda expressions are useful when we need to
provide short functions as arguments to other functions, which is
something we return to in later chapters. Usually, we use the
function() syntax when defining reusable functions, and I will stick
to this notation in every case where we define and name a function the
way we did for square earlier.
The function we have written takes one argument, x, and returns
the result x**2. The return value of a function is always the last
expression evaluated in it. If you write a function with a single
expression, you can write it as earlier, but for more complex functions,
you will typically need several statements in it. If you do, you can put
the function’s body in curly brackets like this:
The following function needs the curly brackets since it needs three
separate statements to compute its return value, one for computing the
mean of its input, one for getting the standard deviation, and a final
expression that returns the input scaled to be centered on the mean
and having one standard deviation.
The first two statements are just there to define some variables we
can use in the final expression. This is typical for writing short
functions.
Variables you assign to inside a function will only be visible from
inside the function. When the function completes its execution, the
variables cease to exist. From inside a function, you can see the so-
called local variables—the function arguments and the variables you
assign to in the function body—and you can see the so-called global
variables—those assigned to outside of the function. Outside of the
function, however, you can only see the global variables. At least that is
a good way to think about which variables you can see at any point in a
program until we get to the gritty details in Chapter 4. For now, think in
terms of global variables and local variables, where anything you write
outside a function is in the first category and can be seen by anyone,
and where function parameters and variables assigned to inside
functions are in the second category; see Figure 2-1. If you have the
same name for both a global and a local variable, as in the figure where
we have a global variable x and a function parameter x, then the name
always refers to the local variable.
(x <- 1:5)
## [1] 1 2 3 4 5
You can also go the other way and make a value invisible. When you
evaluate an expression, R will print it:
x**2
## [1] 1 4 9 16 25
invisible(x**2)
If you evaluate a loop, you get the value NULL (and not the last
expression in its body):
## NULL
Another Random Scribd Document
with Unrelated Content
“I declared at that time before thousands of fellow Germans,
each bullet which leaves the barrel of a police pistol now is
my bullet. If one calls this murder, then I have murdered; I
ordered all this, I back it up. I assume the responsibility, and I
am not afraid to do so.” (2324-PS; 3252-PS.)
After the elimination of the forces of the opposition, the Nazis felt
it necessary to dispose of nonconformists within their own ranks.
During the Roehm purge of 30 June 1934, many people were
murdered who had nothing to do with the internal SA revolt but
were just “not liked very well” (2950-PS). Goering’s role in this
bloody affair was related less than two weeks later by Hitler in a
speech to the Reichstag:
When asked the reasons why the Four-Year Plan lost importance in
1942, Goering explained that his preoccupation with the Air Force
did not allow him the necessary concentration on the affairs of the
Four-Year Plan, and stated:
“The main task of the Four-Year Plan had been accomplished.
This task was to get Germany ready.”
“If Germany wins the war, she will be the greatest power in
the world, dominating the world market, and Germany will be
a rich nation. For this goal, risks must be taken. The only
thing that matters is increased output regarding quantity and
quality. Even if the manufacturers know that their present
policies may mean their bankruptcy within three years, they
will have to do it all the same * * * I want you to be perfectly
resolved, today already, how you will run your business when
war comes. The earlier the manufacturers make their
preparations for mobilization today, the less danger there will
be of work being held up. It must be determined for every
worker whether he is essential for production upon outbreak
of war, and measures must be taken to secure his deferment
in case of mobilization. (3441-PS). An executive will be put in
charge to work on nothing but the complete preparation of
each plant for mobilization day.” (R-140)
A few weeks after the Munich agreement, on 14 October 1938,
another conference was held in Goering’s office. He began with the
statement that Hitler had instructed him to organize a gigantic
armament program which would make insignificant all previous
achievements. He indicated that he had been ordered to build as
rapidly as possible an air force five times as large, to increase the
speed of Army and Navy armament, and to concentrate on offensive
weapons, principally heavy artillery and heavy tanks. He then
proposed a specific program designed to accomplish these ends.
(1301-PS)
(e) Military Mobilization for War. In his dual role as Reich Air
Minister and Commander-in-Chief of the German Air Force, it was
Goering’s function to develop the Luftwaffe to practical war strength.
As early as March 1935 Goering frankly announced to the world that
he was in the process of building a true military air force:
Goering was also a moving force in the later crimes against the
peace. As the successor designate to Hitler, as Chief of the Air
Forces, and as economic czar of Greater Germany, he was a party to
all the planning for military operations of the Nazi forces in the East
and the West. In the Polish affair, for example, it was Goering who in
1935 gave assurances to the Polish government that “there should
be not the slightest fear in Poland that on the German side it (the
German-Polish alliance) would not be continued in the future.” Yet,
four years later, Goering helped formulate plans for the invasion of
Polish territory.
With regard to the attack upon the Soviet Union, plans for the
ruthless exploitation of Russian territory were made months in
advance of the opening of hostilities. Goering was placed in charge
of this army of spoliation, whose mission was that of “seizing raw
materials and taking over all important concerns.” (1317-PS; 1157-
PS.)
These specific instances cover only a small part of Goering’s
activities in the field of aggressive war. There follows a partial list of
additional documents which demonstrate Goering’s knowledge of
and continued participation in the Nazi war program. They deal
either with conferences on the highest war-planning levels which he
attended, or with secret orders communicated to him outlining in
advance the official plans for the execution of the successive acts of
aggression.
Meetings and Conferences Attended:
Conference in Reichskanzlei, 5 November 1937, to outline the
necessity for expanding German foreign policy; plans discussed for
the acquisition of Austria and Czechoslovakia. (386-PS)
Entry in Jodl diary, 10 March 1938, referring to meeting attended
by Goering and others at which the preparation of “Case Otto” and
the mobilization of the army and the air force were ordered. (1780-
PS)
Top secret conference with Hitler on 23 May 1939, the subject of
which was indoctrination on the political situation and foreign aims.
(L-79)
Meeting with Hitler, 22 August 1939, attended by commanders of
the armed forces at which immediate plans for Polish invasion were
discussed. (L-3; 798-PS; 1014-PS)
Hitler’s speech to all military commanders on 23 November 1939,
regarding the invasion of the low countries. (789-PS)
Meetings of 8 February 1941 and 27 March 1941, at which Hitler
outlined the prospective operations against Yugoslavia and Greece.
(1746-PS)
Orders and Other Directives Received:
Directive of Blomberg to the armed forces containing plans for
military operations in the event that sanctions were applied against
German withdrawal from League of Nations. (C-140)
Top secret directive of Blomberg of 2 May 1935, with plans for
operation “Schulung” (the reoccupation of the Rhineland). (C-139)
Top secret letter from Blomberg dated 24 June 1935, enclosing
copy of secret Reich Defense Law of 21 May 1935 and decision of
Reich Cabinet of the same date. (2261-PS)
Order of Blomberg of 2 March 1936, giving the operational basis
for the Rhineland occupation. (C-159)
Directives from Hitler and Keitel April to August 1939 on
preparation and invasion of Poland. (C-120)
Operational file, “Fall Weiss,” the code name for the Polish
operation. (C-126)
Directive from GAF, dated 25 August 1938, regarding the
acquisition of bases in the low countries. (375-PS)
Directive No. 6 for the conduct of the war, dated 9 October 1939,
signed by Hitler, and orders of Keitel, dated 15 November 1939, on
the plans for “Fall Gelb”, (operation in the West). (C-62)
Orders of the Supreme Command from 7 November 1939 to 9
May 1940, regarding the opening of the invasion in the West. (C-72)
Order of Hitler No. 8, 20 November 1939, for the execution of
“Fall Gelb”. (440-PS)
Operational plans signed by Keitel on 28 November 1939, on
action near the French-Belgium borders. (C-10)
Entries in Jodl diaries from 1 February to 26 May 1940 confirming
plans for invasion of the West. (1809-PS)
OKW orders, 27 January 1940, signed by Keitel on preparation
for “Fall Weseruebung” (Invasion of Norway and Denmark). (C-63)
Fuehrer order of 1 March 1940 for the execution of “Fall
Weseruebung.” (C-174)
Most secret order from Hitler’s headquarters, dated 19 February
1941, on plans for the invasion of Greece. (C-59)
Top secret operational order on “Case Barbarossa” (invasion of
the Soviet Union), dated 13 March 1941, signed by Keitel. (447-PS)
Time table for “Case Barbarossa,” signed by Keitel. (C-39)
Top secret memorandum of 29 October 1940, signed by
Falkenstein, Luftwaffe liaison officer with OKW, discussing need for
the seizure of air bases in the event of future war with the United
States. (376-PS)
Basic order No. 24, dated 5 March 1941, signed by Keitel,
regarding German collaboration with Japan. (C-75)
B. WAR CRIMES.
(1) Forced Labor, Deportation, and Enslavement of Residents of
Occupied Territories.
The slave labor program of the Nazi conspirators had two
criminal purposes. The first was to satisfy the labor requirements of
the Nazi war machine by forcing residents of occupied countries to
work in Germany, often directly in the German armament industry,
and the second was to destroy or weaken the peoples of the
occupied territories. Millions of foreign workers were taken to
Germany, for the most part under pressure and generally by physical
force. These workers were forced to labor under conditions of
undescribable brutality and degredation, and often they were used
in factories and industries devoted exclusively to the production of
munitions of war. (See Chapter X on The Slave Labor Program.)
Goering was at all times implicated in the slave labor program.
Recruitment and allocation of manpower and determination of
working conditions were included in his jurisdiction as
Plenipotentiary for the Four-Year Plan, and from its beginning a part
of the Four-Year Plan Office was devoted to such work. (1862-PS;
2827-PS.)
The defendant Goering was present at a meeting in Hitler’s study
on 23 May 1939 at which Hitler, after declaring his intention to
attack Poland at the first suitable opportunity, said:
“If fate brings us into conflict with the West, the possession
of extensive areas in the East will be advantageous. * * * The
population of non-German areas will perform no military
service and will be available as a source of labor.” (L-79)
Goering was also responsible for the harsh treatment given these
workers when they reached Germany. On 8 March 1940, as
Plenipotentiary of the Four-Year Plan and as Chairman of the Cabinet
Counsel for the Defense of the Reich, he issued a directive to the
Supreme Reich authorities, entitled: “Treatment of male and female
civilian workers of Polish Nationality in the Reich.” In this directive
Goering provided in part:
“I. The stronger labor reserves in the zone of the interior are
also decisive for the war.
“The Russian workers have proved their productive capacity
during the development of the huge Russian industry.
Therefore it must be made available to the Reich from now
on. Objections against this order of the Fuehrer are of the
secondary nature. The disadvantages which can be created
by the Arbeitseinsatz have to be reduced to a minimum: the
task especially of counter-intelligence and security police.
“II. The Russian in the zone of operations.
“He is to be employed particularly in building roads and
railroads, in clearing work, clearing of mines and in building
airports. The German construction battalions have to be
dissolved to a great extent (Example: Air Forces!); the
German skilled workers belong to the war industry; it is not
their task to shovel and to break stones, the Russian is there
for that.”
* * * * * *
“IV. The Russian in the Reich territory including the
Protectorate.
“The number of the employed depends on the requirement.
By determining the requirement, it is to be considered that
workers of other states who produce little and eat much are
to be shipped out of the Reich and that in the future the
German woman should come less into the foreground in the
labor process. Beside the Russian prisoners of war, free
Russian workers should also be used.
“A. The Russian Prisoner of War.
“1. The selection has to take place already in the collecting
camps, beyond the Reich border. The profession and physical
condition are decisive. At the same time screening as to
nationality and according to the requirements of the security
police and counter-intelligence must take place.
“2. The transportation has to be organized just as the
selection and not improvised. The prisoners are to be
forwarded rapidly. Their feeding should be orderly and their
guarding unconditionally secured.
“3. Officers are to be excluded from the work as much as
possible, commissars as a matter of principle.
“4. The Russian belongs in first line to the following work
places (in order of priorities):
Mining.
Railroad maintenance (including repair shops and
construction of vehicles).
War industry (tanks, artillery pieces, airplane parts).
Agriculture.
Building industry.
Large scale workshops (shoe shops!)
Special units for urgent, occasional and emergency work.
* * * * * *
“B. The Free Russian Worker.
Employment and treatment, will not be handled in practice
differently than for Russian prisoners of war. In both
categories, particularly good production can be acknowledged
by a limited distribution of luxury items. Sufficient, adequate
nourishment is also the main thing for the free workers.”
(1193-PS)
In a set of top secret notes on what was apparently the same
conference, the following appears:
“NOTES
On outlines layed down by the Reichsmarschall in the meeting
of 7 November 1941 in the Reich Ministry for Air (RLM)
“SUBJECT: Employment of laborers in war industries.
“The Fuehrer’s point of view as to employment of prisoners of
war in war industries has changed basically. So far a total of 5
million prisoners of war—employed so far 2 million.
“Directives for employment:
“Frenchmen: Individual employment, transposition into
armament industry (Rue-wirtschaft)
“Serbs: Preferably agriculture.
“Poles: If feasible no individual employment
achievement of Russian armament industry
surpasses the German one. Assembly linework,
a great many mechanical devices with
relatively few skilled workers.
“Readiness of Russians in the operational area to work is
strong. In the Ukraine and other areas discharged prisoners
of war already work as free labor. In Krivoy Rog, large
numbers of workers are available due to the destruction of
the factories. * * *
“Some points as to general Arbeitseinsatz
“Rather employ PW’s than unsuitable foreign workers. Seize
Poles, Dutchmen, etc. if necessary as PW’s and employ them
as such, if work through free contract cannot be obtained.
Strong action.” (1206-PS)
“In conveying the measures taken until now, for the securing
of Jewish art property by the Chief of the Military
Administration Paris and the special service staff Rosenberg
(the Chief of the Supreme Command of the Armed Forces 2 f
28.14. W.Z.Nr 3812/40 g), the art objects brought to the
Louvre will be disposed of in the following way:
“1. Those art objects about which the Fuehrer has reserved
for himself the decision as to their use.
“2. Those art objects which serve to the completion of the
Reich Marshal’s collection.
“3. Those art objects and library stocks the use of which
seem useful to the establishing of the higher institutes of
learning and which come within the jurisdiction of Reichsleiter
Rosenberg.
“4. Those art objects that are suited to be sent to German
museums, of all these art objects a systematic inventory will
be made by the special purpose staff Rosenberg; they will
then be packed and shipped to Germany with the assistance
of the Luftwaffe.” (141-PS)