R language.doc

24
R Connection R is an open source software programming language and a software environment for statistical computing and graphics. In Tabl eau Desktop, you can use a set of four functions to pass R expressions to an Rserve server and obtain a result. The functions are SCRIPT_BOOL SCRIPT_INT SCRIPT_REAL SCRIPT_STR See Ta ble Calculation Functions for details and examples. Before you can use any of the SCRIPT functions, you must establish a connection to an Rserve server, hich is a server that allos applications to access R functionality . See Rserve for details. !nd for more information about usin" R ith Ta bleau, see the blo" post Tableau #.$ and R. Ta bleau has been tested ith R versions %.$ and %.&, and ith Rserver version '.() #. Confi"ure an Rserve Connection To confi"ure an Rserve connection, follo these steps* $. +n th e elp menu in Tableau -e sto p choose ettings and !erformance " #anage R Connection to open the Rserve connection dialo" box* &. /nter o r select a serve r name usin" a domain o r an IP address . The drop)do n list includes localhost  and the server you most recently connected to. %. Specify a port. P ort (%$$ is the defa ult port for Rse rve servers. 0. If the server re1uires creden tials, spe cify a 2sername and Passord. 3. Clic Test Connection. (. Clic $%.

Transcript of R language.doc

Page 1: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 1/24

R ConnectionR is an open source software programming language and a software

environment for statistical computing and graphics. In Tableau Desktop,you can use a set of four functions to pass R expressions to an Rserveserver and obtain a result. The functions are

SCRIPT_BOOL

SCRIPT_INT

SCRIPT_REAL

SCRIPT_STR

See Table Calculation Functions for details and examples.

Before you can use any of the SCRIPT functions, you must establish a connection toan Rserve server, hich is a server that allos applications to access R functionality.See Rserve for details. !nd for more information about usin" R ith Tableau, see theblo" post Tableau #.$ and R.

Tableau has been tested ith R versions %.$ and %.&, and ith Rserver version '.()#.

Confi"ure an Rserve Connection

To confi"ure an Rserve connection, follo these steps*

$. +n the elp menu in Tableau -estop choose ettings and !erformance" #anage R Connection to open the Rserve connection dialo" box*

&. /nter or select a server name usin" a domain or an IP address. The drop)donlist includes localhost and the server you most recently connected to.

%. Specify a port. Port (%$$ is the default port for Rserve servers.

0. If the server re1uires credentials, specify a 2sername and Passord.

3. Clic Test Connection.

(. Clic $%.

Page 2: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 2/24

If no connection can be established, an error messa"e is displayed. Clic howDetails in the messa"e to see any dia"nostic information returned by the server.

Sharin" a 4orboo That Re1uires an Rserve Connection

5ou may need to send a orboo that contains R functionality to other users, homay be usin" different copies of Tableau -estop on other computers. +r, users maydonload a orboo from Tableau Server that contains R functionality. Beforeusers ill be able to use the R functionality in orboos they have received ordonloaded to Tableau -estop, they must confi"ure Rserve connections on theircomputers.

Publishin" a 4orboo That Re1uires an Rserve Connection

Before you publish a orboo that relies on an Rserve connection to TableauServer, you should confi"ure Tableau Server to have its on Rserve connection. 5oudo this by confi"urin" settin"s ith tabadmin set. The settin"s are e1uivalent to the

values you set in the Rserve Connection dialo" box. They are*

• tabadmin set vizqlserver.rserve.host

• tabadmin set vizqlserver.rserve.ort

• tabadmin set vizqlserver.rserve.!sername

• tabadmin set vizqlserver.rserve.ass"ord

For information on tabadmin set, see tabadmin set options.

Tableau cannot verify that orboos that use R ill render properly on TableauServer. There mi"ht be scenarios here a re1uired statistical library is available on auser6s machine but not on the Rserve instance that Tableau Server is usin".

For vies that cannot be rendered in Tableau Server because of an R script error,

you see a arnin" error hen you publish the orboo*

This orsheet contains R scripts, hich cannot be vieed on the tar"et platformuntil the administrator confi"ures an Rserve connection.

5ou cannot publish a orboo that contains R scriptin" to Tableau +nline.

Because Tableau Server provides an authentication mechanism, it can be moresecure to expose Rserve functionality to users throu"h Tableau Server than inTableau -estop.

Troubleshooting R Connections

This topic describes errors you can receive hen Tableau is connected to an Rserveserver7or attemptin" to connect to an Rserve server. It also lists issues that youmay encounter as you use R ith Tableau.

/rror 8essa"es

+ther Issues

Page 3: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 3/24

&rror #essages

&rror #essage Comments

2nsupported type passed as anar"ument to SCRIPT function.

Tableau can only export the folloin" Tableau data types to R*

• 9umber :-ecimal;

• 9umber :4hole;

• Boolean

• Strin"

• -ate

• -ate<Time

2nexpected number of resultsreturned by SCRIPT function.Function expected =& values> =$values ere returned.

The R script result must be either a scalar or vector of len"th onethat is replicated for all ros, or a vector of len"th e1ual to thenumber of ros in the Tableau result table.

The result returned by the SCRIPTfunction is of an unexpected type.

+ccurs hen an invalid data type is received. Tableau can onlyimport the folloin" data types from R*

• R-ouble

• RInte"er 

• R?o"ical

• RCharacter 

This error is also reported if the result is null or if there as a scriptexecution error for hich Tableau could not collect an explanation

from R.This orsheet contains R scripts,hich are not supported on the tar"etplatform.

This error is reported hen you attempt to publish a orsheetcontainin" an R script to a server that does not allo R scriptsbecause vizqlserver.s#rit.disabled is set to true.

This orsheet contains R scripts,hich cannot be vieed on the tar"etplatform until the administratorconfi"ures an Rserve connection.

This error is reported hen you try to publish a orsheetcontainin" an R script to a server is not currently confi"ured tosupport R scripts. Specifically,the vizqlserver.rserve.host option, and

associatedvizqlserver.rserve parameters, for tabadmin set,

must be confi"ured properly. See tabadmin set options, in theTableau Server online help, for details.

 !n error occurred hilecommunicatin" ith the Rserveservice.

Tableau runs all R scripts inside of the @try@ R function. This errois displayed alon" ith an R "enerated error messa"e hen theAtry function traps an R evaluation error.

This Rserve connection does notsupport authentication. Tryconnectin" ithout specifyin" apassord.

 

 !uthentication failed. Please provide

Page 4: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 4/24

a valid Rserve username andpassord.

 !n unsupported authentication typeis enabled in Rserve.

/ither disable Rserve authentication or chan"e to plaintextpassord authentication.

9o Rserve connection confi"ured.

Specify a server name and try a"ain.

See R Connection.

The calculation =$ contains adisabled R script. Confi"ure anRserve connection to enable customR scripts.

See R Connection.

The orboo you are attemptin" topublish contains custom R scripts.Custom R scripts are not alloed inpublic orboos.

5ou cannot publish orboos containin" R scripts to TableauPublic.

Tableau Public does not supportrunnin" R scripts. To tae advanta"e

of R inte"ration, up"rade to TableauProfessional.

The @Tableau Public@ in this error refers to Tableau -estop Pub

Tableau Reader cannot load customR scripts. To tae advanta"e of Rinte"ration, up"rade to TableauProfessional.

5ou cannot vie orboos containin" R scripts in TableauReader.

Rserve is busy or not respondin".Failed to create socet to Rserve.

Tableau has timed out a read pendin" on connection to Rserve Dthe timeout is &3'ms. !n IPC connection Read of the Rserveprotocol header has thron an exception.

2nreco"niEed Rserve si"nature. The Rserve header si"nature must be @Rsrv@.

2nreco"niEed Rserve version. The Rserve header version must be @'$'%@.2nreco"niEed Rserve protocol. The Rserve header protocol must be @!P$@.

 !uthentication failure henconnectin" to R.

Tableau attempted and failed to authenticate ith Rserve. Gerifythat you entered a valid passord.

Incorrect number of bytes inparameter<body.

 

The len"th of data hich Tableauread does not e1ual the len"thpromised by the header.

 

2nreco"niEed response type. The transport protocol type hen readin" a result as not S/HPas expected.

/xcessively lon" typeJvector.2nreasonably lar"e number measurin" the len"th of data sent toor from Rserve possibly indicatin" a corrupt protocol header.

Invalid Rserve command. Tableau may have improperly implemented the Rserve protocol.

Page 5: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 5/24

Response from server as /rror @ :uint%&Kt;status @. See Rsrv.h fordetails.

Garious error conditions are documented in the comments inRsrv.h.

/xcessively lon" header offset. This may be due to a "arbled header ith an unreasonable offseto response data.

Rserve socet failed. ! lo"in, script evaluation, read pendin" chec, result read, orTableau field to R script ar"ument assi"nment thre a non)standard exception.

$ther Issues

SCRIPT Functions Run Even in Logical Statements That Evaluate as False

 ! function that sends an expression to a runnin" Rserve instance ill be executedeven hen it is ithin a lo"ical statement that ould otherise prevent it from bein"executed. This is true for lo"ical functions such as IF, IIF, and C!S/. For example*I$ %&&' T(EN ))R s#rit #ode**ELSE+% does not eq!al '+EN,

Data Types

Tableau supports strin", date<datetime, number, and boolean data types. These datatypes are automatically handled in the proper fashion. oever, if you createcalculated fields of your on, you need to be aare of ho to use and combine thedifferent data types in formulas. For example, you cannot add a strin" to a number.

 !lso, many functions that are available to you hen you define a calculation onlyor hen they are applied to specific data types. For example,

the ,ATEPART- function can accept only a date<datetime data type as an ar"ument.So, you can rite ,ATEPART-/0ear/12Aril %314''52 and expect a valid result*

&''0. 5ou cannot rite ,ATEPART-/0ear/1+Tom Sa"0er+ and expect a valid result.

In fact, this example returns an error because @Tom Sa"0er@ is a strin", not a

date<datetime.

Page 6: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 6/24

 !lthou"h Tableau ill attempt to fully validate all calculations, some data type errorscannot be found until the 1uery is run a"ainst the database. These issues appear aserror dialo"s at the time of the 1uery rather than in the calculation dialo" box.

The data types supported by Tableau are described belo. Refer to TypeConversion to learn about convertin" from one data type to another.

STRI9L

 ! se1uence of Eero or more characters. For example, @6is#onsin@, @I,7555''@, and

@Tom Sa"0er@ are all strin"s. Strin"s are reco"niEed by sin"le or double 1uotes. The

1uote character itself can be included in a strin" by repeatin" it. For example,M+anrahan6.

-!T/<-!T/TI8/

 ! date or a datetime. For example @8an!ar0 491 %:;4@ or @8an!ar0 491 %:;4

%4<94<'' A=@. If you ould lie a date ritten in lon")hand style to be interpreted as a a

date<datetime, place the N si"n on either side of it. For instance, A8an!ar0 491 %:;4 istreated as a strin" data type but 28an!ar0 491 %:;42 is treated as a date<datetime

data type.

B++?/!9

 ! field that contains the values TR>E or $ALSE. !n unnon value arises hen the result

of a comparison is unnon. For example, the expression ; ? N!ll yields unnon.

2nnon booleans are automatically converted to 9ull

'ormatting (iterals

4hen you are usin" functions you ill sometimes ant to use literal expressions torepresent numbers, strin"s, dates, and more. ! literal expression si"nifies a constantvalue that is represented Aas is. For example, you may have a function here your inputis a date. Rather then Oust type A8ay $, &''3, hich ould be interpreted a a strin", youould type N8ay $, &''3N, hich is e1uivalent to usin" a date function to convert thear"ument from a strin" to a date :refer to -ate Functions;. 5ou can use numeric, strin",date, boolean, and 9ull literals. The ay to format each of these literals is describedbelo.

9umeric ?iterals

 ! numeric literal is ritten exactly lie you usually rite numbers. If you ant to input thenumber one as a numeric literal you ould type $. Subse1uently, if you ant to input the

number %.$0$3 as a numeric literal you ould type %.$0$3.Strin" ?iterals

 ! strin" literal can be ritten either usin" sin"le 1uotations or double 1uotations. If yourstrin" has a sin"le or double 1uotation ithin it, simply type the symbol tice. Forexample, if you anted to input the strin" Acat as a strin" literal you could type Mcat6 orAcat. !dditionally, if you ant to type the strin" AShe6s my friend. as a strin" literal youcould type MShe66s my friend.6 or AShe6s my friend.

Page 7: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 7/24

Date (iterals

-ate literals are si"nified by the pound symbol :N;. If you anted to input the dateA!u"ust &&, &''3 as a literal date you ould type N!u"ust &&, &''3N.

Boolean ?iterals

Boolean literals are ritten as either true or false. If you anted to input Atrue as aboolean literal you ould type true.

9ull ?iterals

9ull literals are ritten simply as 9ull. If you anted to input A9ull as a 9ull literal youould type 9ull.

 9umber Functions

 !BS:number;

Returns the absolute value of the "iven number.

ExamplesABS-7; & ;

ABS-)B!d@et arian#e*

The second example returns the absolute value for all the numbers contained inthe B!d@et arian#e field.

 !C+S:number;

Returns the arc cosine of the "iven number. The result is in radians.

Example

ACOS-7% & 9.%5%3:4393:;:

 !SI9:number;

Returns the arc sine of a "iven number. The result is in radians.

Example

ASIN-% & %.3;';:94;:5:

 !T!9:number;

Returns the arc tan"ent of a "iven number. The result is in radians.

Example

ATAN-%' & %.3345'49:54

 !T!9&:y number, x number;

Returns the arc tan"ent of to "iven numbers :x and y;. The result is in radians.

Example

ATAN4-41 % & %.%';%5;%;;:5':

Page 8: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 8/24

C$)number*

Returns the cosine of an an"le. Specify the an"le in radians.

Example

COS-PI- D5 & '.;';%';%%35

C+T:number;

Returns the cotan"ent of an an"le. Specify the an"le in radians.

Example

COT-PI- D5 & %

-/LR//S:number;

Converts a "iven number in radians to de"rees.

Example

,EREES-PI- D5 & 53.'

/HP:number;

Returns e raised to the poer of the "iven number.

Examples

EFP-4 & ;.9:

EFP-7)ro"th Rate*G)Time*

?9:number;

Returns the natural lo"arithm of a number. Returns N!ll if number is less than or e1ual

to '.

($+)number , base-*

Returns the lo"arithm of a number for the "iven base. If the base value is omitted, base$' is used.

#/)number, number*

Returns the maximum of the to ar"uments, hich must be of the same type.Returns N!ll if either ar"ument is N!ll. =AF can also be applied to a sin"le field in an

a""re"ate calculation.

&xamples

=AF-51;

=AF-Sales1ProHit

=AF-)$irst Name*1)Last Name*

Page 9: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 9/24

#I0)number, number*

Returns the minimum of the to ar"uments, hich must be of the same type.Returns N!ll if either ar"ument is N!ll. =IN can also be applied to a sin"le field in an

a""re"ate calculation.

&xamples

=IN-51;

=IN-Sales1ProHit

=IN-)$irst Name*1)Last Name*

!I) *

Returns the numeric constant pi* %.$0$3.

!$1&R)number, power*Raises the number to the specified poer.

Examples

PO6ER-314 & 34 & 43

PO6ER-Temerat!re1 4

5ou can also use the Q symbol*

34 & PO6ER-314 & 43

Radians :number;

Converts the "iven number from de"rees to radians.

&xample

RA,IANS-%' & 9.%5%3:

R$20D)number, decimals-*

Rounds numbers to a specified number of di"its. The de#imals ar"ument specifies ho

many decimal points of precision to include in the final result, and it is not re1uired.If de#imals is omitted, n!mber is rounded to the nearest inte"er.

&xample

TOos example rounds every Sales value to an inte"er*

RO>N,-;.9 & ;RO>N,-7.: & 7;RO>N,-%49.5;1% & %49.3RO>N,-Sales

9ote that some databases such as 8S S? Server, allo specification of ane"ative len@th, here )$ rounds n!mber to $'s, )& rounds to $''s, and so on. This is

Page 10: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 10/24

not true of all databases to hich you can connect. For example, it is not true of /xcel or !ccess.

I+0)number*

Returns the si"n of a number* The possible return values are )$ if the number isne"ative, ' if the number is Eero, or $ if the number is positive.

&xample

If the avera"e of the profit field is ne"ative, then

SIN-A-ProHit & 7%

I0)number*

Returns the sine of an an"le. Specify the an"le in radians.

&xample

SIN-' & %.'SIN-PI- D5 & '.;';%';%%35

3RT)number*

Returns the s1uare root of a number.

&xample

SJRT-43 & 3

32R&)number*

Returns the s1uare of a number.

/xample

SJ>ARE-3 & 43

T0)number*

Returns the tan"ent of an an"le. Specify the an"le in radians..

&xample

TAN-PI - D5 & %.'

40)expression*

Returns the expression if it is not null, otherise returns Eero. 2se this function to useEero values instead of null values.

Page 11: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 11/24

&xample

KN-)ProHit* & )ProHit*

tring 'unctions

CII)string*Return the !SCII code for the first character of strin@.

&xample

ASCII-/A/ & 3

C5R)number*

Returns the character encoded by the !SCII code n!mber.

&xample

C(AR-3 & /A/

Contains)string, substring*

Returns true if the "iven strin" contains the specified substrin".

&xample

CONTAINS-Cal#!lationM1 al#!M & tr!e

&0D1IT5)string, substring*

Returns true if the "iven strin" ends ith the specified substrin". Trailin" hite spacesare i"nored.

&xample

EN,S6IT(-Tablea!M1 lea!M & tr!e

'I0D)string, substring, start-*

Returns the index position of s!bstrin@ in strin@, or ' if the s!bstrin@ isnt found. Ifthe optional ar"ument start is added, the function i"nores any instances

of s!bstrin@ that appear before the index position start. The first character in the

strin" is position $.

&xamples

$IN,-+Cal#!lation+1 +al#!+ & 4

Page 12: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 12/24

$IN,-+Cal#!lation+1 +Com!ter+ & '

$IN,-+Cal#!lation+1 +a+1 9 & ;

$IN,-+Cal#!lation+1 +a+1 4 & 4

$IN,-+Cal#!lation+1 +a+1 & '

(&'T)string, number*

Returns the left)most number of characters in the strin".

&xample

LE$T-+=atador+1 5 & +=ata+

(&0)string*

Returns the len"th of the strin".

&xample

LEN-+=atador+ & ;

($1&R)string*

Returns strin@, ith all characters loercase.

&xample

LO6ER-+Prod!#tersion+ & +rod!#tversion+

(TRI#)string*

Returns the strin" ith any leadin" spaces removed.

&xample

LTRI=-+ =atador + & +=atador +

#/)a, b*

Returns the maximum of a and b :hich must be of the same type;. This function isusually used to compare numbers, but also ors on strin"s. 4ith strin"s, =AF finds the

value that is hi"hest in the sort se1uence defined by the database for that column. Itreturns N!ll if either ar"ument is N!ll.

&xample

=AF -+Ale+1+Banana+ & +Banana+

Page 13: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 13/24

#ID)string, start, length-*

Returns the strin" startin" at index position start. The first character in the strin" is

position $. If the optional ar"ument len@th is added, the returned strin" includes only

that number of characters.

&xamples

=I,-+Cal#!lation+1 4 & +al#!lation+

=I,-+Cal#!lation+1 41 3 &+al#!l+

#I0)a, b*

Returns the minimum of a and b :hich must be of the same type;. This function is

usually used to compare numbers, but also ors on strin"s. 4ith strin"s, =IN finds the

value that is loest in the sort se1uence. It returns N!ll if either ar"ument is N!ll.

&xample

=IN -+Ale+1+Banana+ & +Ale+

R&!(C&)string, substring, replacement*

Searches strin@ for s!bstrin@ and replaces it ith rela#ement. If s!bstrin@ is not

found, the strin" is not chan"ed.

&xample

REPLACE-+ersion.3+1 +.3+1 +:.'+ & +ersion:.'+

RI+5T)string, number*

Returns the ri"ht)most number of characters in strin@.

&xample

RI(T-+Cal#!lation+1 5 & +tion+

RTRI#)string*

Returns strin@ ith any trailin" spaces removed.

&xample

RTRI=-+ Cal#!lation + & + Cal#!lation+

!C&)number*

Page 14: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 14/24

Returns a strin" that is composed of the specified n!mber of repeated spaces.

&xample

SPACE-% & + +

TRT1IT5)string, substring*

Returns true if strin@ stars ith s!bstrin@. ?eadin" hite spaces are i"nored.

&xample

STARTS6IT(-8oerM1 8oM & tr!e

TRI#)string*

Returns the strin" ith leadin" and trailin" spaces removed. For example, TRI=-+

Cal#!lation + & +Cal#!lation+

2!!&R)string*

Returns strin", ith all characters uppercase.

&xample

>PPER-+Cal#!lation+ & +CALC>LATION+

ate 'unctions

Tableau provides a variety of date functions. 8any of the examples use the 2 symbol

ith date expressions. See Formattin" ?iterals for an explanation of this symbol. !dditionally, many date functions use date_art, hich is a constant strin"

ar"ument. The valid date_art values that you can use are*

date6part 7alues

/0ear/ Four)di"it year 

/q!arter/ $)0

/month/ $)$& or @anuary@, @February@, and so on

/da0oH0ear/-ay of the year> an $ is $, Feb $ is %&, and so on

/da0/ $)%$

/"eeda0/ $) or @Sunday@, @8onday@, and so on

/"ee/ $)3&

/ho!r/ ')&%

/min!te/ ')3

Page 15: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 15/24

date6part 7alues

/se#ond/ ')('

DT&DD)date6part, increment, date, start6of6week*Returns an in#rement added to date. The type of increment is specified

in date_art.

The start_oH_"ee parameter is optional. If it is omitted, the start of ee is

determined by the data source. See -ate Properties for a -ata Source.

&xample

,ATEA,,-/month/1 91 24''57'57%32 & 4''57';7%3 %4<''<'' A=

This expression adds three months to the date 24''57'57%32.

DT&DI'')date6part, date8, date9, start6of6week*

Returns the difference beteen date% and date4 expressed in units of date_art.

The start_oH_"ee parameter is optional. If it is omitted, the start of ee is

determined by the data source. See -ate Properties for a -ata Source.

&xample

,ATE,I$$-/"ee/1 24'%97':74421 24'%97':74521 /monda0/& %

,ATE,I$$-/"ee/1 24'%97':74421 24'%97':74521 /s!nda0/& '

The first expression returns $ because hen start_oH_"ee is monday, then &&September :a Sunday; and &0 September :a Tuesday; are in different ees. Thesecond expression returns & because hen start_oH_"ee is sunday then &&

September :a Sunday; and &0 September :a Tuesday; are in the same ee.

DT&0#&)date6part, date, start6of6week*

Returns date_art of date as a strin". The start_oH_"ee parameter is optional.

If it is omitted, the start of ee is determined by the data source. See -ateProperties for a -ata Source.

&xamples

,ATENA=E-/0ear/1 24''57'57%32 & +4''5+

,ATENA=E-/month/1 24''57'57%32 & +Aril+

DT&!R&)format, string*

Page 16: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 16/24

Converts a strin" to a datetime in the specified format. Support for some locale)specific formats is determined by the computers system settin"s. ?etters that appear in the data and do not need to be parsed should be surrounded by sin"le 1uotes : ;.For formats that do not have delimiters beteen values :e."., 88ddyy;, verify thatthey are parsed as expected. The format must be a constant strin", not a field value.Returns N!ll if the data does not match the format.

This function is available for non)le"acy 8icrosoft /xcel and text file connections,8yS?, +racle, Post"reS?, and Tableau data extract data sources. Some formatsmay not be available for all data sources.

&xamples

,ATEPARSE -+dd.====.0000+1 +%3.Aril.4''5+ & 2Aril %31 4''52

,ATEPARSE -+h/h/ m/m/ s/s/+1 +%'h 3m 9s+ & 2%'<'3<'92

Refer to the 2nderstandin" the -!T/P!RS/ Function noled"e base article formore examples.

DT&!RT)date6part, date, start6of6week*

Returns date_art of date as an inte"er.

The start_oH_"ee parameter is optional. If it is omitted, the start of ee is

determined by the data source. See -ate Properties for a -ata Source.

4hen the date_art is eeday, the start_oH_"ee parameter is i"nored. This is

because Tableau relies on a fixed eeday orderin" to apply offsets.

&xamples

,ATEPART-/0ear/1 24''57'57%32 & 4''5

,ATEPART-/month/1 24''57'57%32 & 5

DT&TR20C)date6part, date, start6of6week*

Truncates the specified date to the accuracy specified by the dateKpart. This functionreturns a ne date. For example, hen you truncate a date that is in the middle ofthe month at the month level, this function returns the first day of the month.The start_oH_"ee parameter is optional. If it is omitted, the start of ee is

determined by the data source. See -ate Properties for a -ata Source.

&xamples

,ATETR>NC-/q!arter/1 24''57'7%32 & 4''57';7'% %4<''<'' A=

,ATETR>NC-/month/1 24''57'57%32 & 4''57'57'% %4<''<'' A=

Page 17: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 17/24

D:)date*

Returns the day of the "iven date as an inte"er.

&xample

,A-24''57'57%42 & %4

IDT&)string*

Returns true if a "iven strin" is a valid date.

&xample

IS,ATE-+Aril %31 4''5+ & tr!e

#%&DT&TI#&)date, time*

Returns a datetime that combines a date and a time. The date can be a date,datetime, or a strin" type. The time must be a datetime. This function is availableonly for 8yS? connections.

&xamples

=AE,ATETI=E-+%::7%479'+1 2';<3:<''2 & 2%4D9'D%:: ;<3:<'' A=2

=AE,ATETI=E-),ate*1 )Time* & 2%D%D4''% <''<'' A=2

#/)expression* or #/)expr8, expr9*

2sually applied to numbers but also ors on dates. Returns the maximumof a and b :a and b must be of the same type;. Returns N!ll if either ar"ument

is N!ll.

&xamples

=AF-24''57'%7'%2 124''57'97'%2 & 4''57'97'% %4<''<'' A=

=AF-)Shi,ate%*1 )Shi,ate4*

#I0)expression* or #I0)expr8, expr9*

2sually applied to numbers but also ors on dates. Returns the minimumof a and b :a and b must be of the same type;. Returns N!ll if either ar"ument

is N!ll.

&xamples

=IN-24''57'%7'%2 124''57'97'%2 & 4''57'%7'% %4<''<'' A=

=IN-)Shi,ate%*1 )Shi,ate4*

Page 18: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 18/24

#$0T5)date*

Returns the month of the "iven date as an inte"er.

&xample

=ONT(-24''57'57%32 & 5

0$1) *

Returns the current date and time.

&xample

NO6- & 4''57'57%3 %<'<4% P=

T$D:) *

Returns the current date.

&xample

TO,A- & 4''57'57%3

 :&R )date*

Returns the year of the "iven date as an inte"er.

&xampleEAR-24''57%32 & 4''5

Type Conversion

The result of any expression in a calculation can be converted to a specific data type.The conversion functions are STR-, ,ATE-, ,ATETI=E-, INT-, and $LOAT-. For

example, if you ant to cast a floatin" point number lie %.$0 as an inte"er, you couldrite INT-9.%5. The result ould be 9, hich is an inte"er. The castin" functions are

described belo.

 ! boolean can be cast to an inte"er, float, or strin", It cannot be cast to a date. Tr!e is $,

$.', or A$, hile False is ', '.' or A'.>nno"n

 maps toN!ll

.

DT&)expression*

Returns a date "iven a number, strin", or date expression.

Page 19: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 19/24

&xamples

,ATE-)Emlo0ee Start ,ate*

,ATE-+Aril %31 4''5+ & 2Aril %31 4''52

,ATE-+5D%3D4''5+

,ATE-24''7'7%3 %5<342 & 24''7'7%32uotation mars are re1uired in the second and third examples.

DT&TI#&)expression*

Returns a datetime "iven a number, strin", or date expression.

&xample

,ATETI=E-Aril %31 4''3 ';<3:<''M & Aril %31 4''3 ';<3:<''

'($T)expression*

Casts its ar"ument as a floatin" point number.

&xamples

$LOAT-9  9.'''

$LOAT-)A@e* converts every value in the A@e field to a floatin" point number.

I0T)expression*

Casts its ar"ument as an inte"er. For expressions, this function truncates results to theclosest inte"er toard Eero.

&xamples

INT-.'D9.'  4

INT-5.'D%.3  4

INT-'.3'D%.'  '

INT-7:.;  7:

4hen a strin" is converted to an inte"er it is first converted to a float and then rounded.

TR)expression*

Casts its ar"ument as a strin".

Page 20: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 20/24

&xample

STR-)A@e* taes all of the values in the measure called A@e and converts them to

strin"s.

 

'iles and 'olders5ou can save your or usin" several different Tableau specific file types*orboos, boomars, paca"ed data files, data extracts, and data connection files./ach of these file types are described belo.

• 1orkbooks ).twb* D Tableau orboo files have the .tb file extension.

4orboos hold one or more orsheets, plus Eero or more dashboards andstories.

• ;ookmarks ).tbm* D Tableau boomar files have the .tbm file extension.

Boomars contain a sin"le orsheet and are an easy ay to 1uicly shareyour or. See Boomars.

!ackaged 1orkbooks ).twbx* D Tableau paca"ed orboos have the .tbxfile extension. ! paca"ed orboo is a sin"le Eip file that contains a orbooalon" ith any supportin" local file data sources and bac"round ima"es. Thisformat is the best ay to paca"e your or for sharin" ith others ho don6thave access to the data. See Paca"ed 4orboos.

• Data &xtract ).tde* D Tableau data extract files have the .tde file extension.

/xtract files are a local copy of a subset or entire data source that you can use toshare data, or offline, and improve database performance.

• Data ource ).tds* D Tableau data source files have the .tds file extension. -ata

source files are shortcuts for 1uicly connectin" to data sources that you useoften. -ata source files do not contain the actual data but rather the information

necessary to connect to the data source as ell as modifications youve made inthe -ata indo such as default properties, calculated fields, "roups, and so on.See /xportin" -ata Sources.

• !ackaged Data ource ).tdsx* D Tableau paca"ed data source files have the

.tdsx file extension. ! paca"ed data source is a Eip file that contains the datasource file :.tds; described above as ell as any local file data sources such as/xtract files :.tde;, text files, /xcel files, !ccess files, and local cube files. 2sethis format to create a sin"le file that you can then share ith others ho may nothave access to the ori"inal data stored locally on your computer. See /xportin"-ata Sources.

These files can be saved in the associated folders in the 8y Tableau Repository

directory, hich is automatically created in your 8y -ocuments folder hen youinstall Tableau. 5our or files can also be saved in other locations, such as yourdestop or a netor directory.

Changing the Repository (ocation

5ou can specify a ne location for the Tableau repository if you are not usin" thedefault location in your -ocuments folder. For instance, if you are re1uired to have

Page 21: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 21/24

your data on a netor server instead of on your local machine, you can pointTableau at the remote repository.

$. Select 'ile " Repository (ocation.

&. Select a ne folder that ill act as the ne repository location in the Select aRepository dialo" box.

%. Restart Tableau so that it uses the ne repository.

Chan"in" the repository location does not move the files contained in the ori"inalrepository. Instead, Tableau creates a ne repository here you can store your files.

%eyboard hortcuts

+eneral %eyboard hortcuts

Tableau eyboard shortcuts are listed belo.

Keyboard Shortcut Description

indo!s "ac

Ctrl#$   $ Select all data

Ctrl#% 

% Smaller cell size

Ctrl#Shi&t #%   % Bigger cell size

Ctrl#C   C Copy selected data

Ctrl#$lt#C 

C Place selected field on Columns shelf 

Ctrl#D   D Connect to data source

Ctrl#E   E Describe sheet

Ctrl#F 

F Makes the find command in the Data window actie

Ctrl#$lt#F 

F Place selected field on !ilters shelf 

  ' F Enter"Exit !ull Screen

F( # Ctrl#) 

Enter Switch in and out of Presentation Mode

Ctrl#$lt#I   I Place selected field on Size

Ctrl#L   !lip orientation of column labels at bottom of iew

Ctrl#$lt#L   L Place selected field on Detail

Ctrl#" 

T  $ew worksheet

Page 22: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 22/24

Ctrl#* 

*  $ew workbook 

Ctrl#+   + %pen file

Ctrl#$lt#+   + Place selected field on Color 

Ctrl#P 

P Print

Ctrl#$lt#P   P Place selected field on Pages shelf 

Ctrl#$lt#R    R  Place selected field on &ows shelf 

Ctrl#S 

S Sae file

Ctrl#$lt#S   S Place selected field on Shape

Ctrl#$lt#T   T Place selected field on 'ext"(abel

Ctrl#, 

, Paste clipboard

Ctrl# ' 

Swap rows and columns

Ctrl#-   - Cut text selection )e*g*# in captions# titles# formulas#

etc*+

Ctrl#$lt#-   - Place selected field on &ows shelf 

Ctrl#.   . &edo

Ctrl#$lt#. 

. Place selected field on Columns shelf 

Ctrl#/   / ,ndo

Ctrl#$lt#%ac0space   delete Clear the current worksheet

Ctrl#1le&t arro!2 ' 

Make rows narrower 

Ctrl#1right arro!2 ' 

Make rows wider 

Ctrl#1do!n arro!2 '  Make columns shorter 

Ctrl#1up arro!2 '  Make columns taller 

Ctrl#3 # Ctrl#Shi&t#3 # Ctrl#4 

3 Show Me-

Enter Return .dd the selected field to the sheet* %nly works witha single field

F3   5 %pens the /elp

Ctrl#F6   Deletes the selected sheet )on a dashboard+

$lt#F6   Closes the current workbook 

Page 23: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 23/24

F6   Starts and stops forward playback on the pages shelf 

Shi&t#F6   Starts and stops backward playback on the pages

shelf 

F7 

R  &efreshes the data source

Ctrl#8   8 Skip forward one page

Ctrl#9   9 Skip backward one page

Ctrl#Tab 9 Ctrl##F: 

; Cycle forward through open worksheets

Ctrl#Shi&t#Tab # Ctrl#Shi&t#F:  < Cycle backward through open worksheets

F=   > &un update

F3> 

> 'oggles .utomatic ,pdates on and off 

F3? 

E &eerts workbook to last saed state

Esc Esc Clears the selection )Desktop and &eader only+

0avigation and election hortcuts

In addition to the standard eyboard shortcuts there are several ey combinations thatcan mae navi"atin" and selectin" mars fast and easy.

Keyboard@"ouse $ction Description

indo!s "ac

Clic0 Clic0   Selects the mark 

Drag Drag Selects a group of marks

Ctrl#Clic0  

Clic0  .dds indiidual marks to the selection

Ctrl#Drag 

Drag .dds a group of marks to the selection

Shi&t#Drag # Clic0 and

)old#Drag

 Drag # Clic0 and

)old#Drag

Pans around the iew

DoubleAclic0  # Ctrl#Shi&t#Cli

c0 

DoubleAclic0  # Clic0  0ooms into a point in the iew

)re1uires zoom mode if not map+

Ctrl#Shi&t#$lt#Clic0  

Clic0  0ooms out from a point on a map

)re1uires zoom mode if not map+

Shi&t#DoubleAclic0  

DoubleAclic0  0ooms out

Page 24: R language.doc

7/17/2019 R language.doc

http://slidepdf.com/reader/full/r-languagedoc 24/24

Ctrl#Shi&t#Drag 

Drag 0ooms into an area in the iew

)re1uires zoom mode if not map+

Ctrl#Scroll 

Scroll 0ooms in and out on a map )Desktop

and &eader only+

Clic0#Drag to bottom o&

pane#)old

Clic0#Scroll# )old Drags a row and scrolls through a longlist simultaneously

'ield election hortcuts

There are several ey and mouse combinations that can mae creatin" a vie andselectin" fields fast and easy.

Keyboard@"ouse $ction Description

indo!s "ac

RightAclic0#Drag to

shel& 

 Drag to shel&  %pens the Drop !ield menu

Ctrl#Drag   Drag Copies a field in the iew to be placed on another shelf

or card

DoubleAclic0 DoubleAclic0  .dds a field to the iew