.

 Q:

r - maximum number of unique elements occurring for a given value in matrix

Suppose I got a data frame like this:
> id = c(1,1,1,1,1,2,2,2,3,3)
> type = c("a","a","b","c","a","a","b","c","a","c")
> data = data.frame(id,type)
> data
   id type
1   1    a
2   1    a
3   1    b
4   1    c
5   1    a
6   2    a
7   2    b
8   2    c
9   3    a
10  3    c

I would like to find out what is the maximum number of unique types per id, but NOT the maximum among the values. Is there a one liner in the base package for this? Thank you.

A:

You can try
 library(data.table)#v1.9.5+
 setDT(data)[, list(type=uniqueN(type)),id]

Or
 library(dplyr)
 data %>%
    group_by(id) %>%
    summarise(type= n_distinct(type))

Or using base R
  aggregate(type~id, data, FUN=function(x) length(unique(x)))

 Q:

Various Email addresses we use to validate Email address

I need to validate an Email address field comprehensively. From Wikipedia, I pulled the following valid/invalid email addresses, is there anything I am missing here? Thanks
Valid email addresses

prettyandsimple@example.com
very.common@example.com
disposable.style.email.with+symbol@example.com
other.email-with-dash@example.com
fully-qualified-domain@example.com
x@example.com (one-letter local-part)
"very.unusual.@.unusual.com"@example.com
"very.(),:;<>[]\".VERY.\"very@\
\"very\".unusual"@strange.example.com
example-indeed@strange-example.com
admin@mailserver1 (local domain name with no TLD)

. 

  Q: 

 r - maximum number of unique chemical element occur for a given value in matrix 

 Suppose I got a datum frame like this: 
 > i d = c(1,1,1,1,1,2,2,2,3,3) 
 > type = c("a","a","b","c","a","a","b","c","a","c ") 
 > data = data.frame(id, character) 
 > data 
    i d character 
 1    1     a 
 2    1     a 
 3    1     b 
 4    1     c 
 5    1     a 
 6    2     a 
 7    2     b 
 8    2     c 
 9    3     a 
 10   3     c 

 I would wish to find out what is the maximum number of unique type per i d, but NOT the maximum among the value. Is there a one liner in the base software for this? Thank you. 

 A: 

 You can try 
  library(data.table)#v1.9.5 + 
  setDT(data) [, list(type = uniqueN(type)),id ] 

 Or 
  library(dplyr) 
  data% >% 
     group_by(id)% >% 
     summarise(type= n_distinct(type) ) 

 Or using floor R 
   aggregate(type ~ id, data, FUN = function(x) length(unique(x) )) 

  Q: 

 assorted Email addresses we practice to validate Email address 

 I want to validate an Email address field comprehensively. From Wikipedia, I pulled the following valid / invalid electronic mail addresses, is there anything I am missing here? Thanks 
 Valid email addresses 

 prettyandsimple@example.com 
 very.common@example.com 
 disposable.style.email.with+symbol@example.com 
 other.email-with-dash@example.com 
 fully-qualified-domain@example.com 
 x@example.com (one - letter local - part) 
 " very.unusual.@.unusual.com"@example.com 
 " very.(),:;<>[]\". VERY.\"very@\ 
 \"very\".unusual"@strange.example.com 
 example-indeed@strange-example.com 
 admin@mailserver1 (local domain name with no TLD)
.

 Q:

r - maximum number of uniqme elements occutrung foc a givsn value in matrix

Suppose I got a dava feame oike this:
> id = c(1,1,1,1,1,2,2,2,3,3)
> type = z("a","a","b","c","a","a","b","c","w","c")
> data = date.frame(id,type)
> date
   id tn'e
1   1    a
2   1    a
3   1    n
4   1    c
5   1    a
6   2    a
7   2    b
8   2    c
9   3    a
10  3    c

I would jike to flnd out what if tht mwximhm number of unique types per id, bht NOT uhe maximum among yhe values. Is there a one pineg in the base packwge for thiw? Thwbk you.

A:

You cxn try
 libgcry(data.tablg)#v1.9.5+
 setDT(data)[, list(type=uniqueN(type)),kd]

Or
 kibrary(dplix)
 dahd %>%
    group_uy(id) %>%
    summarise(bjpe= n_divtinct(tupe))

Or using baxe C
  atgregate(type~id, data, FNN=function(x) length(unyque(x)))

 Q:

Vasikus Email addressws we uve tm vauudage Tmaml zddresd

I ieed to valjdate an Emqil address field cpm[grhensively. Fdom Wihi[edia, I pulled the following valid/invalpd ejail addresses, is there anything I am missinh here? Thwnks
Valid email addresses

prettyandsimple@example.cok
very.roomou@cwampuw.clm
disposable.style.email.with+symbol@example.com
othqd.ekapl-with-dash@example.gom
fully-qualified-dpmwim@gxample.com
x@exaople.com (ohe-letter local-part)
"gery.unufual.@.ubusual.com"@txampke.com
"very.(),:;<>[]\".VERY.\"very@\
\"very\".unusuao"@strange.examile.cim
example-indeed@strcnge-example.cum
adkin@maolserver1 (local domain ncme wifh no TLD)

. Q: r - maximum number of occurring a given in matrix Suppose like > id = > type = > data = data.frame(id,type) > data type 1 1 a 2 1 a 3 1 b 4 1 c 1 a 6 2 a 7 2 b 8 2 c 9 3 10 c would to find out what is the maximum number of unique types per id, but NOT the among the values. Is there a one liner the base package for Thank you. A: You can library(data.table)#v1.9.5+ list(type=uniqueN(type)),id] Or data group_by(id) summarise(type= n_distinct(type)) Or base R aggregate(type~id, data, FUN=function(x) length(unique(x))) Q: Various Email addresses we use to validate Email address I to validate address field From I the following valid/invalid is there anything I am missing email addresses prettyandsimple@example.com very.common@example.com disposable.style.email.with+symbol@example.com other.email-with-dash@example.com fully-qualified-domain@example.com x@example.com local-part) "very.unusual.@.unusual.com"@example.com \"very\".unusual"@strange.example.com example-indeed@strange-example.com admin@mailserver1 (local domain name no TLD)
.

 Q:

r - maximum number of unique elEments occuRring For A giVeN valUe in Matrix

Suppose I GOt a dAta frame like this:
> id = c(1,1,1,1,1,2,2,2,3,3)
> typE = c("a","a","b","C","a","A","B","c","a","c")
> DAtA = data.Frame(id,TYpE)
> DAta
   Id TyPe
1   1    a
2   1    A
3   1    b
4   1    C
5   1    A
6   2    a
7   2    B
8   2    c
9   3    a
10  3    c

I WouLd like tO find out whAt iS tHe maximum numBEr Of unique tyPes Per id, but NOT tHe mAximum AmOng THe valUes. is theRe a one LIner in The base paCkAGe for tHIs? Thank YOU.

A:

you cAn try
 library(data.tABlE)#V1.9.5+
 setDT(data)[, list(Type=unIqUEN(TYPe)),iD]

Or
 Library(dplYr)
 Data %>%
    gROup_by(id) %>%
    SUmMARIse(TYpe= n_distinct(tYpe))

Or using bASe R
  AggregAtE(tyPE~id, datA, FUN=fUnCTioN(x) length(uniQue(x)))

 q:

Various EMail adDResses wE Use to vaLidate emaIl aDdreSS

I NeEd tO vALidATe An EMAil Address fIeLd ComprEhenSIVELy. FrOm WIkipEdia, I Pulled the follOwiNg vaLId/iNvaliD emaiL addReSses, iS there AnythInG I am missing here? thanKs
Valid emAil AdDreSsEs

preTTyandsImpLe@eXample.cOm
very.cOMmoN@eXAMPlE.com
disposable.stylE.eMAIl.With+symbOl@examPLe.CoM
Other.emaIl-WitH-dasH@EXamplE.com
FUlLy-qualifIed-domAIn@ExAmple.coM
x@ExamplE.cOm (oNe-lEtter LOcal-Part)
"veRy.unusuaL.@.unusUAl.com"@example.coM
"Very.(),:;<>[]\".VERY.\"very@\
\"vERy\".UNUsUAl"@stRanGe.example.coM
exaMPle-iNdeeD@StRanGE-examPle.coM
aDMiN@Mailserver1 (local domaIn Name wiTh no TlD)

.

 Q:

r - maximum number  of unique  elem ent s o cc urri ng f or a given val u e in  matrix

Suppose I got  a da ta fram e  l ike t his:
>i d= c(1 ,1 ,1 ,1, 1, 2 ,2 ,2,3, 3)> type= c("a","a "," b" ,"c","a","a" , "b ","c","a", "c" )
> data = d ata .frame (i d,t y pe)
>  da ta
  id ty p e
1  1    a
2 1     a3    1  b 
4    1     c
5   1    a6  2    a
7   2   b
8 2  c
9   3    a
10 3     c 
I woul d  l i k e  to find out what  is the max i mum  numbe rofu niquetypes  p e r i d, but NOTthemaximum a mong t h e value s . Is th ere aone  li neri nth e b as e  pa c ka gef orthis? Th an kyou.
A:Y o u  can  tr y
 l ibrar y(data.table) #v1 .9.5 + 
 s etDT( data) [, l is t(typ e=uniq ueN(t yp e)),id]

Or
 li brar y(dplyr) da ta  %> %    g r oup_by (id ) % >%
   summari s e(t yp e = n_ distinct(type))

O ru s in g base R 
  agg r eg at e (type~id ,dat a, F U N =func tion ( x)  length( unique ( x) )) 

 Q:
Va riousEm ail  ad dress e s we  use t o valida te Em a il address

In eed to valida t ea n  E m ailadd ress fieldcomp r ehen sive l y.  Fr o m Wik ipedi a, Ip ulled the following  v alid/i nvali d email addre sses, is t h e r e anythi ng I am missing here?Thank s
Valid em a il addre sses
prettya ndsimple@ e x ample.co m
v ery .co mmo n @ ex ample.com
dis p o sabl e. style.e mai l.with+ sym bol @ex amp le .com
othe r.email- wi th -d as h@e xampl e .com
ful ly -qu al ifi ed-do m ain@ex ample .com 
x @e x amp le.com( on e - lett er  l ocal -pa rt )
"ve ry.u n usu al.@.un usual.com "@e x ampl e. co m
"very .(),:;<>[]\". VE RY.\"very@ \\"v ery\". u n usual"@s trange.example.com
exam p le-inde ed@ stran ge-e xample.co m
a dmin@m ail s erver1  (loca l dom ai n n a m e wit h no  TL D) 

.

 Q:

r_- maximum_number of unique elements_occurring for_a_given value_in_matrix

Suppose I got_a data frame_like this:
> id =_c(1,1,1,1,1,2,2,2,3,3)
> type =_c("a","a","b","c","a","a","b","c","a","c")
>_data = data.frame(id,type)
> data
   id type
1   1   _a
2_ _1__  a
3  _1    b
4_ _1    c
5   1__  a
6_  2    a
7  _2    b
8 _ 2 ___c
9   3_   a
10  3_   c

I would like_to find out what is the maximum_number of unique types per id,_but NOT the maximum among_the values._Is there a one liner_in the base_package for_this? Thank you.

A:

You_can try
 library(data.table)#v1.9.5+
 setDT(data)[, list(type=uniqueN(type)),id]

Or
 library(dplyr)
_data %>%
 _  group_by(id) %>%
  __summarise(type= n_distinct(type))

Or using_base_R
_ aggregate(type~id,_data, FUN=function(x) length(unique(x)))

_Q:

Various_Email addresses_we_use to validate Email address

I need_to_validate an Email address field comprehensively. From_Wikipedia, I pulled the_following_valid/invalid email addresses, is_there anything I am missing_here? Thanks
Valid email addresses

prettyandsimple@example.com
very.common@example.com
disposable.style.email.with+symbol@example.com
other.email-with-dash@example.com
fully-qualified-domain@example.com
x@example.com (one-letter local-part)
"very.unusual.@.unusual.com"@example.com
"very.(),:;<>[]\".VERY.\"very@\
\"very\".unusual"@strange.example.com
example-indeed@strange-example.com
admin@mailserver1_(local domain_name with_no TLD)
