|
Log4j 1.2.9 | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
| Class Summary | |
| JMSAppender | A simple appender that publishes events to a JMS Topic. |
| JMSSink | A simple application that consumes logging events sent by a JMSAppender . |
| SimpleSocketServer | A simple SocketNode based server. |
| SMTPAppender | Send an e-mail when a specific logging event occurs, typically on errors or fatal errors. |
| SocketAppender | Sends LoggingEvent objects to a remote a log server,
usually a SocketNode . |
| SocketHubAppender | Sends LoggingEvent objects to a set of remote log servers,
usually a SocketNodes . |
| SocketNode | Read LoggingEvent objects sent from a remote client using
Sockets (TCP). |
| SocketServer | A SocketNode based server that uses a different hierarchy
for each client. |
| SyslogAppender | Use SyslogAppender to send log messages to a remote syslog daemon. |
| TelnetAppender | The TelnetAppender is a log4j appender that specializes in writing to a read-only socket. |
Package for remote logging.
|
Log4j 1.2.9 | |||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |


List of all div tags from an html doc
this is a div element 1
this is a div element 2
this is a div element 3
this is a paragraph.


I am Shreeya agrawal ,persuing B.tech 3rd year Cse branch from Reva University.My strenghts are i am hardworker,positive thinker.My hobbies are reading books.


Events
We organize 2 yearly events:
- PhD day
- BBQ
PhD day
The PhD day of the de Duve Institute is an event created by the students for the students and more precisely by the de Duve students’ society. The concept is that during one day all the PhD students gather and have the opportunity to present their work to their peers through a poster or a presentation session.
Our objective is that the de Duve Institute becomes a united scientific community in the next years, and this starts with the PhD Day ! Even though the event will finally be online, we hope to provide a nice environment for sharing research projects and connecting with other PhD students as well as to feed the scientific minds with various interesting scientific topics and stimulating discussions.
Recent posts about our events
de Duve PhD day 2021
May 26, 2021
The PhD day of the de Duve Institute is an event created by the
students for the students and more precisely by the de Duve students’
society. The concept ...


Let's Play
Rules:
Ping Pong will count up to your no from 1 with the following exceptions:
- Numbers divisible by 3 become "ping"
- Numbers divisible by 5 become "pong"
- Numbers divisible by 15 become "pingpong"
Ping Pong will count up to your no from 1 with the following exceptions:


EtherCAT is an Ethernet-based fieldbus system. The EtherCAT Slave Controller (ECAT) read the data addressed to them while the telegram passes through the device. An EtherCAT Slave Controller (ESC) takes care of the EtherCAT communication as an interface between the EtherCAT fieldbus and the slave application. EtherCAT uses standard IEEE 802.3 Ethernet frames, thus a standard network controller can be used and no special hardware is required on master side. EtherCAT has a reserved EtherType of 0x88A4 that distinguishes it from other Ethernet frames. Thus, EtherCAT can run in parallel to other Ethernet protocols. EtherCAT does not require the IP protocol, however it can be encapsulated in IP/UDP. The EtherCAT Slave Controller processes the frame in hardware. Thus, communication performance is independent from processor power.
The XMC_ECAT low level driver provides functions to configure and initialize the ECAT hardware peripheral. For EHTERCAT stack integration, the necessary hardware accees layer APIs shall be explicitly implemented depending upon the stack provider. The XMC_ECAT lld layer provides only the hardware initialization functions for start up and basic functionalities.
EtherCAT event enumeration types
| Aufzählungswerte |
|---|
| XMC_ECAT_EVENT_AL_CONTROL |
Application control event mask
|
| XMC_ECAT_EVENT_DC_LATCH |
Distributed Clock latch event mask
|
| XMC_ECAT_EVENT_DC_SYNC0 |
State of distributed clock sync-0 event mask
|
| XMC_ECAT_EVENT_DC_SYNC1 |
State of distributed clock sync-1 event mask
|
| XMC_ECAT_EVENT_SM_ACTIVATION_REGISTER |
SyncManager activation register mask
|
| XMC_ECAT_EVENT_EEPROM |
EEPROM Emulation event mask
|
| XMC_ECAT_EVENT_WATCHDOG |
WATCHDOG process data event mask
|
| XMC_ECAT_EVENT_SM0 |
Sync Manager 0 event mask
|
| XMC_ECAT_EVENT_SM1 |
Sync Manager 1 event mask
|
| XMC_ECAT_EVENT_SM2 |
Sync Manager 2 event mask
|
| XMC_ECAT_EVENT_SM3 |
Sync Manager 3 event mask
|
| XMC_ECAT_EVENT_SM4 |
Sync Manager 4 event mask
|
| XMC_ECAT_EVENT_SM5 |
Sync Manager 5 event mask
|
| XMC_ECAT_EVENT_SM6 |
Sync Manager 6 event mask
|
| XMC_ECAT_EVENT_SM7 |
Sync Manager 7 event mask
|
ECAT status return values
| Aufzählungswerte |
|---|
| XMC_ECAT_STATUS_OK |
Driver accepted application request
|
| XMC_ECAT_STATUS_BUSY |
Driver is busy and cannot handle request
|
| XMC_ECAT_STATUS_ERROR |
Driver could not fulfil application request
|
| void XMC_ECAT_Disable |
( |
void |
| ) |
|
- Parameter
-
- Rückgabe
- None
- Description:
- Disable the EtherCAT peripheral
- The function asserts the peripheral reset.
| void XMC_ECAT_DisableEvent |
( |
uint32_t |
event | ) |
|
- Parameter
-
| event | Single or logically OR'd events specified in the enum type |
- Rückgabe
- None
- Description:
- Disable an ECAT event(s)
- The function can be used to disable ECAT event(s).
| void XMC_ECAT_DisableSyncManChannel |
( |
const uint8_t |
channel | ) |
|
- Parameter
-
| channel | SyncManager channel number. |
- Rückgabe
- None
- Description:
- Disables selected SyncManager channel
- Sets bit 0 of the corresponding 0x807 register.
| void XMC_ECAT_Enable |
( |
void |
| ) |
|
- Parameter
-
- Rückgabe
- None
- Description:
- Enable the EtherCAT peripheral
- The function de-asserts the peripheral reset.
| void XMC_ECAT_EnableEvent |
( |
uint32_t |
event | ) |
|
- Parameter
-
| event | Single or logically OR'd events specified in the enum type |
- Rückgabe
- None
- Description:
- Enable ECAT event(s)
- The function can be used to enable ECAT event(s).
| void XMC_ECAT_EnableSyncManChannel |
( |
const uint8_t |
channel | ) |
|
- Parameter
-
| channel | SyncManager channel number. |
- Rückgabe
- None
- Description:
- Enables selected SyncManager channel
- Resets bit 0 of the corresponding 0x807 register.
| uint16_t XMC_ECAT_GetALEventMask |
( |
void |
| ) |
|
- Parameter
-
- Rückgabe
- uint16_t Content of register 0x220-0x221
- Description:
- Get content of AL event register
- Get the first two bytes of the AL Event register (0x220-0x221).
| uint16_t XMC_ECAT_GetALEventRegister |
( |
void |
| ) |
|
- Parameter
-
- Rückgabe
- uint16_t Content of register 0x220-0x221
- Description:
- Get content of AL event register
- Get the first two bytes of the AL Event register (0x220-0x221).
| uint32_t XMC_ECAT_GetEventStatus |
( |
void |
| ) |
|
- Parameter
-
- Rückgabe
- uint32_t Event status
- Description:
- Get event status
- The function returns the ECAT status and interrupt status as a single word. The user can then check the status of the events by using an appropriate mask.
- Parameter
-
- Rückgabe
- XMC_ECAT_STATUS_t ECAT Initialization status
- Description:
- Initialize the Ethernet MAC peripheral
- The function sets the link speed, applies the duplex mode, sets auto-negotiation and loop-back settings.
| XMC_ECAT_STATUS_t XMC_ECAT_ReadPhy |
( |
uint8_t |
phy_addr, |
|
|
uint8_t |
reg_addr, |
|
|
uint16_t * |
data |
|
) |
| |
- Parameter
-
| phy_addr | PHY address |
| reg_addr | Register address |
| data | The destination to which the read data needs to be copied to. |
- Rückgabe
- XMC_ECAT_STATUS_t EtherCAT Read PHY API return status
- Description:
- Read a PHY register
- The function reads a PHY register. It essentially polls busy bit during max PHY_TIMEOUT time and reads the information into 'data' when not busy.
| void XMC_ECAT_SetALEventMask |
( |
uint16_t |
intMask | ) |
|
- Parameter
-
| intMask | Interrupt mask (disabled interrupt shall be zero) |
- Rückgabe
- None
- Description:
- Sets application event mask register
- Performs a logical OR with the AL Event Mask register (0x0204 : 0x0205).
- Parameter
-
| port_ctrl | Port control configuration |
- Rückgabe
- None
- Description:
- Set port control configuration
- The function sets the port control by writing the configuration into the ECAT CON register.
| XMC_ECAT_STATUS_t XMC_ECAT_WritePhy |
( |
uint8_t |
phy_addr, |
|
|
uint8_t |
reg_addr, |
|
|
uint16_t |
data |
|
) |
| |
- Parameter
-
| phy_addr | PHY address |
| reg_addr | Register address |
| data | The data to write |
- Rückgabe
- XMC_ECAT_STATUS_t EtherCAT Write PHY API return status
- Description:
- Write a PHY register
- The function reads a PHY register. It essentially writes the data and polls the busy bit until it is no longer busy.


Summary
Accomplished software development professional with a rich history of leadership and strategic guidance in the deployment of innovative software applications within Azure and other related environments. Proven ability to drive transformation and enhance workflow efficiencies for industry-leading companies using the latest software technologies.
Skilled in recruiting and assembling talented teams of software engineers capable of achieving results within strict timelines. A strong technical resource with executive presence knowledgeable in all facets of the software development and deployment life cycle.


Current syllabus for CPSC 44000 - Software Engineering
Simple Dice Roller Game
Appliation to test RegEx
Exercise of a Node site
Coming Soon.


Abstract framework for flow-based optimizations.
This package defines abstractions and solvers for finding fixed point of
lattice-based flow functions over arbitrary graphs. It also composes analyses
with transformation as described in "Composing Dataflow Analyses and
Transformations" paper. This paper is highly recommended to read before
diving into framework, since we borrow lots of terminology and algorithms from
there.
The framework can be used for both inter- and intra- procedural analyses such
as:
- constant propagation
- copy propagation
- unreachable code elimination
- liveness analysis
- null analysis
- side effects analysis
- possible exceptions
and many others.
If you are new to the framework, consider starting in the following order:
{@link Graph}, {@link Analysis}, {@link AnalysisFollowedByTransformation},
{@link CombinedIntegratedAnalysis}, {@link AnalysisSolver}.
References
- Flemming Nielson, Hanne Riis Nielson, Chris Hankin. Principles of Program
Analysis
- Steven Muchnick. Advanced Compiler Design and Implementation.
- Sorin Lerner, David Grove, Craig Chamber. Composing Dataflow Analyses and
Transformations.


Current: {{ (currentAudioZone$ | async ).name }}
Track: {{ currentTrack.Track.Name }}
Artist: {{ artist.Name }}
Album: {{ currentTrack.Track.Album.Name }}


{% extends "base.html" %} {% load widget_tweaks %} {% load staticfiles %} {% block title %}
The objective of the Pre-Assessment is to provide guidance to the system owner of a smart grid system to determine if a DPIA is necessary or not. It is therefore proposed to the system owner to perform an initial analysis of the application under consideration and to decide whether to proceed with the next steps of the DPIA or to stop the process.
{% endblock %} {% block content %}| Question | |
|---|---|
| {{ form.answer.label }} |
{{ form.answer|attr:"required"}}
{% if form.answer.errors %}
{{ form.answer.errors|striptags }} {% endif %} |


DISTURBING BEHAVIOR A film review by Matt Williams
RATING: * * out of * * * *
There's a nugget of a good thriller hidden deep inside Disturbing Behavior, just waiting to get out. Unfortunately, it never gets a chance, and is instead buried in pseudo-thrilling moments mostly borrowed from bad horror films.
Retreating from troublesome family issues, the Clark family moves to the seemingly peaceful town of Cradle Bay.  However, there's something strange going on under the surface.
Even though he doesn't seem to fit in with them, Steve is immediately initiated by the paranoid druggies. His tour guide is Gavin Strick (Nick Stahl), who, along with his albino buddy U.V. (Chad E. Donella), is convinced that the preponderance of "perfect" students in the school is the result of some sort of conspiracy.
You see, the letter-jacket wearing "popular" crowd are all part of a program called the "blue-ribbons". It's a goody-two-shoes study group, in which the members gather at the local yogurt shoppe, listen to a little Wayne Newton, and study for those Straight-As. Oh yes, if that weren't unnatural enough, they are occasionally beset by "toxic jock syndrome", wherein they suddenly fly into an unexpected homicidal rage. The strange thing is, most of the "blue-ribbons" were once perfectly normal misfits, just like Gavin.
Steve isn't quite convinced, nor is token girlfriend Rachel (Katie Holmes), whose role it is to look rebellious, but fall head over heels for Steve anyway. However, to add further suspicions, Steve also has encounters with the overly slick school psychiatrist Dr. Caldicott (Bruce Greenwood) and the delightfully mad janitor Newberry (William Sadler).
Disturbing Behavior is at its best when analyzing the differences between the various archetypical high school social groups, but at its worst when it devolves into an oh-so-typical horror yarn. A more interesting movie would have played up the paranoia inherent between school cliques, and possibly eliminated the homicidal angle altogether. What if we weren't so sure from the first moments of the film that there is a conspiracy at work here? Well, we'll never know, as the film takes the easy way out, by extinguishing intriguing ideas with a douse of nonsensical horror blather.
Many of the "shocks" in the film aren't really shocking at all, when you stop and think about them. However, the film does have a suitably creepy atmosphere going for it. Even if there are no true thrills, it feels as if one may be lurking around the corner. Too bad it never comes.
James Mardsen seems, well, too "blue-ribbon" to fill the role of the outsider. Nick Stahl does a much better job, and should have been given the lead here. Katie Holmes is spunky enough in a punk-goth way, despite the fact she doesn't have much of a character.
Disturbing Behavior isn't as bad as it could have been, but it wastes plenty of potential as well. Creepy, but never scary (unless you count some horrid dialogue snippets), the film just doesn't leave a lasting impression.
Copyright 1998 Matt Williams
- Matt Williams<EMAIL_ADDRESS>Reviewer for Cinematter: http://www.cinematter.com Home of over 500 reviews, and information on over 600 upcoming releases
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


PDOException 异常类 (PHP 5 >= 5.1.0, PHP 7) 简介 代表一个由 PDO 产生的错误。在自己的代码不应抛出一个 PDOException 异常。关于 PHP 异常的更多信息请参见异常。 类摘要 PDOException extends RuntimeException { /* 属性 */ public array $errorInfo ; protected string $message ; protected string $code ; /* 继承的方法 */ final public string Exception::getMessage ( void ) final public Exception Exception::getPrevious ( void ) final public int Exception::getCode ( void ) final public string Exception::getFile ( void ) final public int Exception::getLine ( void ) final public array Exception::getTrace ( void ) final public string Exception::getTraceAsString ( void ) public string Exception::__toString ( void ) final private void Exception::__clone ( void ) } 属性 errorInfo 相当于PDO::errorInfo() 或 PDOStatement::errorInfo() message 文本错误信息。用 Exception::getMessage() 来访问。 code SQLSTATE 错误码。用Exception::getCode() 来访问。 User Contributed Notes 6 notes =============================================================================== Here is something interesting regarding a PDOException and it involves some of the annoyances that can be associated with PHP's dynamic nature. PDOException extends from RuntimeException, which in return extends from Exception. As such, it has access to the $code Protected Class Variable, which represents the Exception's code as an Integer (duh!) and can be accessed externally using the Exception::getCode Method. Here is the interesting part. PDOException actually redefines $code as a String and not an Integer because for its case, $code actually contains the Exception's SQL State, which is composed of characters and numbers. It is actually documented in the manual that $code is a String and not an Integer but it might not be immedietley clear because it is hidden by the fact that PDOException::getCode is documented to return an Integer and not a String! Some developers like to catch a PDOException and rethrow it as a different Exception if they wrap their database calls in an external library. For example, consider the following code: getMessage( ) , $Exception-> getCode( ) ); } ?> Be careful in that you have to typecast the value returned by PDOException::getCode to an Integer BEFORE you pass it as an Argument to your Exception's Constructor. The following will work: getMessage( ) , (int)$Exception ->getCode( ) ); } ?> Hope this will save some developers some frustrating hours from an otherwise enjoyable job :) Good Luck, =============================================================================== In response to the 15-May-2010 07:45 note from: samuelelliot+php dot net at gmail dot com Since the most base class Exception takes three arguments, and the previous exception is not the first, ... Since inherited classes to not implicitly call the parent constructor, ... I recommend changing his constructor to this: public function __construct(string $message = "", int $code = 0, PDOException $e = null) { // in case they call: new MyException($somePDOException); // instead of following the interface. // if (is_subclass_of($message, PDOException)) { $e = $message; $code = $e->getCode(); $message = $e->getMessage(); } // Let PDOException do its normal thing // parent::__construct($message, $code, $e); // Now to correct the code number. // $state = $this->getMessage(); if(!strstr($state, 'SQLSTATE[')) $state = $this->getCode(); if(strstr($state, 'SQLSTATE[')) { preg_match('/SQLSTATE\[(\w+)\] \[(\w+)\] (.*)/', $state, $matches); $this->code = ($matches[1] == 'HT000' ? $matches[2] : $matches[1]); $this->message = $matches[3]; } } =============================================================================== PDOException has two methods for retrieving information about an error. When interpreting the PDOException I run into a problem, the error code that is provided by getCode() is meaningless. I have come up with a method to make both the error code and message more usable. A bad username or password would normally provide the following: CODE : 0 Message : "SQLSTATE[28000] [1045] Access denied for user<EMAIL_ADDRESS>(using password: YES)" Using my extended exception class provides: CODE: "28000" Message: "Access denied for user<EMAIL_ADDRESS>(using password: YES)" getMessage(), 'SQLSTATE[')) { preg_match('/SQLSTATE\[(\w+)\] \[(\w+)\] (.*)/', $e->getMessage(), $matches); $this->code = ($matches[1] == 'HT000' ? $matches[2] : $matches[1]); $this->message = $matches[3]; } } } ?> To walk threw the method; first the beginning of the message is checked for the SQLSTATE text. If the text is present, message is then parsed to pull the ANSI code, the SQL specific code, and the message. The parsed values are stored in there respective variables. The error code variable stores the ANSI code, unless ANSI is 'HT000' (unmapped error code) then SQL specific code is used. Using this class is easy; when interacting with PDO use a try catch set of blocks, as follows: Now you can use the normal error methods to retrieve the real error code and message. getCode(); // Outputs: "28000" echo $err->getMessage(); // Outputs: "Access denied for user<EMAIL_ADDRESS>(using password: YES)" ?> If you decide to use this code, be aware that the error code is a string (as apposed to PHP standard errors which are integers) as some error codes are alphanumeric. =============================================================================== Since PDOException returns the error code as a string, you need a constructor like the one below if you wish to rethrow the PDOException as a custom exception. This constructor does not call the parent::__construct which will enforce the int type on the error code, but set the message and code as properties directly on the custom exception object. message = $message; $this->code = $code; } } =============================================================================== the sqlstate is an hex integer (as string) if you want to wrap pdoexception, use throw new MyDBException($pdoe->getMessage(), hexdec($pdoe->getCode()), $pdoe); =============================================================================== This is a PDOException Error handler for Using/Debugging in Web Browser.
| ' . strval($a) . '# | args: | ' . $e . ': | ' . $f . ' td> |
| ' . strval($a) . '# | ' . $c . ': | ' . $d . ' | '; } } } $trace .= '


The Visual Resume of Ryan Ingersoll
Full Stack Developer(and much more)
Skills
Professional Experience
Projects
Education
Certifications
Dreams and Goals


| Table 1 |
A brief description of the maturity stages according to [ 15 ... |
| Table 2 |
Size distribution of Sardinella maderensis specimens (n = 77 ... |
| Table 3 |
Growth parameters of Sardinella maderensis, based on the res ... |
| Table 4 |
The proportions of male and female Sardinella maderensis ind ... |
| Table 5 |
Length-weight parameters in West Africa for Sardinella mader ... |
| Table 6 |
Sardinella maderensis sex ratios based on the published lite ... |
| Table 7 |
L 50 for Sardinella maderensis based on the literature for W ... |


Scribblers And Recitors
Help
Logout
Toggle Navigation
Home
Details
Questions & Answers
Books
Rate & Reviews
Terms
Policy
Contact Us
Ask Question :
Login
Submit


“Shall we give Liverpool the league now” – Paul Merson slams VAR decision in Reds’ clash with Palace
by Jaikuran RandhawaAccording to the Evening Standard, Arsenal legend and current Sky Sports Soccer Saturday pundit Paul Merson asked former Liverpool star Phil Thompson ‘Shall we give them the league now’ after Crystal Palace had a goal disallowed by VAR.
The Eagles looked as though they’d taken the lead on the brink of halftime after James Tomkins headed in from Luka Milivojevic’s free-kick.
After the referee consulted VAR, it was deemed that Liverpool defender Dejan Lovren was fouled by Palace forward Jordan Ayew in the build-up to the goal.
Take a look at Ayew’s apparent push on the centre-back here.
Some Liverpool fans definitely won’t be happy with Merson’s little dig. After viewing the replays it’s hard not to agree with the decision to disallow the goal.
Lovren could have cleared the ball if he wasn’t sent to the ground by Ayew, this seems to be one of the instances where VAR has actually been used correctly and in a fair and just manner.


On September 24th, Morristown Beautiful hosted a clean up event at Burnham Park. The MHS Engineering Club was commissioned by a representative of Morristown Beautiful to create a Duck Race as a part of the barbecue that honored the volunteers of the clean up. Each volunteer was assigned a rubber duck with a number that was then put in the race which started in the lake. The winner was awarded a $50 gift certificate to anywhere in Morristown.
Last April, the Community Service Division of the Engineering Club in association with the Morris County Prosecutor's Office, hosted a medicine drive in the parking lot of MHS. Anyone with expired medication was encouraged to drop it off at the drive. Below is an image of all the medication the collected on that day. In total, the Prosecutor’s Office disposed 700lbs of expired medication(there were other drives the same day as ours).


In your terminal, create a new folder called mybulma
, navigate to it, then install the Sass gem:
--- title: With sass-cli layout: documentation doc-tab: customize doc-subtab: sass-cli breadcrumb: - home - documentation - customize - customize-sass-cli --- {% capture gem_install %} gem install sass {% endcapture %} {% capture gem_test %} Sass 3.5.3 (Bleeding Edge) {% endcapture %} {% capture step_1 %}
In your terminal, create a new folder called mybulma
, navigate to it, then install the Sass gem:
To try it out, run sass -v
and you should see the following:
Get the latest version of Bulma:
Unzip it and put the bulma-{{ site.data.meta.version }}
folder inside your mybulma
folder.
In your terminal, type the following command:
Reload the page and it should be styled like this:
To watch for changes, just launch the following command:


We are working across india to protect Educational, cultural and traditional legacies of the land.
It is so encouraging when we receive generous support from society.
It comes as a great help to meet financial needs of various charitable activities carried out by the foundation.


COVID-19
WORLDWIDE DATA
{% csrf_token %}
{% for country in mylist %}
{{country}}
{% endfor %}
{{selectedcountry}}
{{total}}
total
{{recovered}}
recovered
{{active}}
active
{{new}}
new
{{deaths}}
deaths
{{critical}}
critical
Developed by
Gagandeep Kumar


1 write to _runspace
System.Management.Automation (1)
engine\remoting\client\Job.cs (1)
3886
_runspace
= runspace;
2 references to _runspace
System.Management.Automation (2)
engine\remoting\client\Job.cs (2)
4120
if (
_runspace
is not RemoteRunspace) { return null; }
4122
Pipeline runningCmd =
_runspace
.GetCurrentlyRunningPipeline();


Module 9 Objects in R
Learning goals
- How to define variables and work with them in
R
- Learn the various possible classes of data in
R
- Leaern the various structures of data in
R
- How to work with vectors in
R
.
Tutorial video
Variables in R
So far we have strictly been using R
as a calculator, with commands such as:
## [1] 8
Of course, R
can do much, much more than these basic computations. Your first step in uncovering the potential of R
is learning how to use variables.
In R
, a variable is a convenient way of referring to an underlying value. That value can be as simple as a single number (e.g., 6
), or as complex as a spreadsheet that is many Gigabytes in size. It may be useful to think of a variable as a cup; just as cups make it easy to hold your coffee and carry it from the kitchen to the couch, variables make it easy to contain and work with data.
Declaring variables
To assign numbers or other types of data to a variable, you use the <
and -
characters to make the arrow symbol <-
.
As the direction of the <-
arrow suggests, this command stores the result of 3 + 5
into the variable x
.
Unlike before, you did not see 8
printed to the Console. That is because the result was stored into x
.
Calling variables
If you wanted R to tell you what “x” is, just type the variable name into the Console and run that command:
## [1] 8
Want to create a variable but also see its value at the same time? Here’s a handy trick:
## [1] 36
The semicolon simulates hitting Enter
. It says: first run x <- 3*12
, then run x
.
You can also update variables.
## [1] 108
## [1] 324
You can also add variables together.
## [1] 12.5
9.0.1 Naming variables
Variables are case-sensitive! If you misspell a variable name, you will confuse R
and get an error.
For example, ask R
to tell you the value of capital X
. The error message will be Error: object 'X' not found
, which means R
looked in its memory for an object (i.e., a variable) named X
and could not find one.
You can make variable names as complicated or simple as you want.
## [1] 5
Note that periods and underscores can be used in variable names:
However, hyphens cannot be used since that symbol is used for subtraction.
Naming variables is a bit of an art. The trick is using names that are clear but are not so complicated that typing them is tedious or prone to errors.
Some names need to be avoided, since R
uses them for special purposes. For example, data
should be avoided, as should mean
, since both are functions built-in to R
and R
is liable to interpret them as such instead of as a variable containing your data.
Note that R
uses a feature called ‘Tab complete’ to help you type variable names. Begin typing a variable name, such as supercalifragilistic.expialidocious
from the example above, but after the first few letters press the Tab
key. R
will then give you options for auto-completing your word. Press Tab
again, or Enter
, to accept the auto-complete. This is a handy way to avoid typos.
Exercise 1
A. Estimate how many bananas you’ve eaten in your lifetime and store that value in a variable (choose whatever name you wish).
B. Now estimate how many ice cream sandwiches you’ve eaten in your lifetime and store that in a different variable.
C. Now use these variables to calculate your Banana-to-ICS ratio. Store your result in a third variable, then call that variable in the Console to see your ratio.
D. Who in the class has the highest ratio? Who has the lowest?
Types of data in R
So far we have been working exclusively with numeric data. But there are many different data types in R. We call these “types” of data classes:
- Decimal values like 4.5 are called numeric data.
- Natural numbers like 4 are called integers. Integers are also numerics.
- Boolean values (TRUE or FALSE) are called logical data.
- Text (or string) values are called character data.
In order to be combined, data have to be the same class.
R is able to compute the following commands …
## [1] 10
… but not these:
That’s because the quotation marks used in naming y
causes R
to interpret y
as a character
class.
To see how R
is interpreting variables, you can use the class()
function:
## [1] "numeric"
## [1] "character"
## [1] "logical"
Another data type to be aware of is factors, but we will deal with them later.
Types of data structures in R
Data belong to different classes, as explained above, and they can be arranged into various structures.
So far we have been dealing only with variables that contain a single value, but the real value of R
comes from assigning entire sets of data to a variable.
Vectors
The simplest data structure in R
is a vector. A vector is simply a set of values. A vector can contain only a single value, as we have been working with thus far, or it can contain many millions of values.
Declaring and using vectors
To build up a vector in R
, use the function c()
, which is short for “concatenate”.
## [1] 5 6 7 8
You can use the c()
function to concatenate two vectors together:
## [1] 5 6 7 8 9 10 11 12
You can also use c()
to add values to a vector:
## [1] 5 6 7 8 9
When two vectors are of the same length, you can do arithmetic with them:
## [1] 14 16 18 20
## [1] -4 -4 -4 -4
## [1] 45 60 77 96
## [1] 0.5555556 0.6000000 0.6363636 0.6666667
You can also put vectors through logical tests:
## [1] FALSE FALSE FALSE TRUE FALSE
This command is asking R
to tell you whether each element in x
is equal to 4
.
You can create vectors of any data class:
## [1] "Ben" "Joe" "Eric"
## [1] TRUE TRUE FALSE
Note that all values within a vector *must be of the same class (i.e., data type). You can’t combine numerics and characters into the same vector. If you did, R
would try to convert the numbers to characters. For example:
## [1] "4" "6"
<IP_ADDRESS> Useful functions for handling vectors
length()
tells you the number of elements in a vector:
## [1] 2
## [1] 4
The colon symbol :
creates a vector with every integer occurring between a min and max:
## [1] 1 2 3 4 5 6 7 8 9 10
seq()
allows you to build a vector using evenly spaced sequence of values between a min and max:
## [1] 0 10 20 30 40 50 60 70 80 90 100
In this command, you are telling R
to give you a sequence of values from 0
to 100
, and you want the length of that vector to be 11
. R
then figures out the spacing required between each value in order to make that happen.
Alternatively, you can prescribe the interval between values instead of the length:
## [1] 0 7 14 21 28 35 42 49 56 63 70 77 84 91 98
head()
and tail()
can be used to retrieve the first 6 or last 6 elements in a vector, respectively.
## [1] 1 2 3 4 5 6
## [1] 995 996 997<PHONE_NUMBER>
You can also adjust how many elements to return:
## [1] 1 2
## [1] 991 992 993 994 995 996 997<PHONE_NUMBER>
which()
allows you to ask, “For which elements of a vector is the following statement true?”
## [1] 4
If no values within the vector meet the condition, a vector of length zero will be returned:
## integer(0)
%in%
is a handy operator that allows you to ask whether a value occurs within a vector:
## [1] TRUE
## [1] FALSE
Exercise 2
NOTE: UNDER CONSTRUCTION!
Subsetting vectors
Since you will eventually be working with vectors that contain thousands of data points, it will be useful to have some tools for subsetting them – that is, looking at only a few select elements at a time.
You can subset a vector using square brackets [ ]
.
## [1] 59
This command is asking R
to return the 10th element in the vector x
.
## [1] 59 60 61 62 63 64 65 66 67 68 69
This command is asking R
to return elements 10:20
in the vector x
.
9.0.2 Other data structures
A vector is the most basic data structure in R
, and the other structures are built out of vectors.
As a data scientist, the most common data structure you will be working with is a dataframe, which is essentially a spreadsheet: a dataset with rows and columns, in which each column represents is a vector of the same class of data.
We will explore dataframes in detail later, but here is a sneak peak at what they look like:
## x y
## 1 300 600
## 2 301 601
## 3 302 602
## 4 303 603
## 5 304 604
## 6 305 605
## 7 306 606
## 8 307 607
## 9 308 608
## 10 309 609
## 11 310 610
In this command, we used the data.frame()
function to combine two vectors into a dataframe with two columns named x
and y
. R
then saved this result in a new variable named df
. When we call df
, R
shows us the dataframe.
The great thing about dataframes is that they allow you to relate different data types to each other.
## name height.inches
## 1 Ben 75
## 2 Joe 73
## 3 Eric 80
This dataframe has one column of class character
and another of class numeric
.
The two other most common data structures are matrices and lists, but we will wait on learning about thos. For now, focus on becoming comfortable using vectors and dataframes.
Exercise 3
NOTE: UNDER CONSTRUCTION!
Review assignment
NOTE: UNDER CONSTRUCTION!