>(NumberOfSamples);

pin_ptr<double> pinnedValues = &managedValues[0];
for (int i = 0; i < managedValues->Length; i++)
{
    nativeValues[i] = (float) pinnedValues[i];
}

I can't refactor it with Runtime::InteropServices::Marshal::Copy because the original array is double and the target one is float.
My problem is I don't get why the pin_ptr. I dont' think is needed but its a critical piece of code and I'd like to be sure before removing it.
Do you think is it safe to remove it?

A:

The pin_ptr would be needed if you were going to pass the pin_ptr directly to an unmanaged API as a double*. 
void SomeUnmanagedAPI(double* data, int length);

// Example of where pin_ptr would be needed.
pin_ptr<double> pinnedValues = &managedValues[0];
SomeUnmanagedAPI(pinnedValues, managedValues->Length);

For either the manual copy, or the Marshal::Copy, it's not needed. Go ahead and remove it, and just iterate over managedValues.

 Q:

Trying to add a column of logicals by looping over time in a tibble in R

I started replicating the value factor used by Fama and French in r to build a portfolio strategy for my final dissertation. 
I have a dataset of monthly market caps from the S&P 500 over the years. I created a loop to determine whether the variable (mkt cap) of a determined observation at a certain date is higher or lower than a certain threshold computed cross-sectionally at the same time (across all the observations of the variable mkt cap at time t). 
To achieve this, I thought the appropriate technique to be a for loop. In this way for each date I calculate the threshold and check the criteria. Unfortunately I am not able to store the logical during the loop. When I print the results I can see what I would like to store but when I try to store I get only the results related to the last step of the loop. 
for(d in dates$date){
  month <- data_tbk %>% filter(date==d) 
  up <- quantile(month$mktcap, 0.8, na
> (NumberOfSamples); 

 pin_ptr < double > pinnedValues = & managedValues[0 ]; 
 for (int i = 0; i < managedValues->Length; i++) 
 { 
     nativeValues[i ] = (float) pinnedValues[i ]; 
 } 

 I can't refactor it with Runtime::InteropServices::Marshal::Copy because the original array is double and the target one is ice-cream soda. 
 My trouble is I don't get why the pin_ptr. I do nt' think is need but its a critical musical composition of code and I'd like to be sure before take out it. 
 Do you intend is it safe to get rid of it? 

 A: 

 The pin_ptr would be needed if you were going to fall the pin_ptr directly to an unmanaged API as a double *. 
 null SomeUnmanagedAPI(double * data, int length); 

 // Example of where pin_ptr would be needed. 
 pin_ptr < double > pinnedValues = & managedValues[0 ]; 
 SomeUnmanagedAPI(pinnedValues, managedValues->Length); 

 For either the manual copy, or the Marshal::Copy, it's not needed. move ahead and remove it, and just iterate over managedValues. 

  Q: 

 sample to add a column of logicals by looping over time in a tibble in R 

 I get down replicating the value factor used by Fama and French in r to build a portfolio scheme for my final dissertation. 
 I have a dataset of monthly market caps from the S&P 500 over the years. I created a loop topology to determine whether the variable (mkt cap) of a determined observation at a certain date is higher or lower than a certain threshold calculate traverse - sectionally at the same prison term (across all the observation of the variable mkt cap at time t). 
 To achieve this, I intend the appropriate technique to be a for loop. In this way for each date I calculate the brink and check the criteria. Unfortunately I am not able to store the logical during the loop. When I print the results I can see what I would wish to store but when I try to store I get only the results related to the last step of the cringle. 
 for(d in dates$date) { 
   month < - data_tbk% >% filter(date==d) 
   up < - quantile(month$mktcap, 0.8, na
>(NumherOfSamples);

pin_ptr<double> pinnedValues = &managedTalues[0];
fkr (int i = 0; i < managedValues->Length; i++)
{
    naticeValues[i] = (float) pinneaValues[i];
}

I can't redactie it with Chntime::IkceropAcrviczs::Narshal::Copy begause the osiginal array hs dluble and the target one is float.
My problek ls I don't get rhy uhe pin_lnr. I dont' think is needed but ifs a crptical piece of cpde and I'd like to be sure beflre removing it.
Do jou think iw it wafe to remoxe it?

A:

The kiu_ptr would ge needed if you were going to oass che pin_ptr eieechny to an unnanagvd API as a double*. 
vohd SomeInmanagedAPI(domble* vata, int length);

// Example oh where pin_ptr would be needeg.
pnn_ptr<double> pinnedValyew = &matagegValjws[0];
SumeHnkahagedAOI(pmnnedValues, managedValyes->Length);

For either trv manual copy, or thq Iarshal::Copy, it's not needed. Go ahead and rejove it, and just iteratw over managedValues.

 E:

Trying tj add a column of logicals by looping over time it a tmbcle ik R

I wtwrted replicating the value factor used by Faiz snc French in r bo build a portfoloo sytategy for my winal bjsaertation. 
I have a datasej of minthly mawket caps from the S&P 500 over the years. I crectee a loop to determnne whether che vatiable (mkt cap) of a determineb obsedvation at w certain aate is higher of lpwar than a certain thresholq computev croxs-sectiunalky at ehe same tlme (agsoss all the obsergatious of the variahle mkt cap at time t). 
To achievx this, I thoubhd tve appro'riate technique to be a for loop. In thif way for each sate I ralculate thq threshold atf check the rriteria. Tnfoetunqtely I xm not able to store thv jogixal during the looi. Whev I print the rewulus I can see whay I wotlf kiha to store bgt wfen O try to store I eet pnly the results reldted to the last step pf the look. 
for(d in dates$date){
  mpnth <- data_tbk %>% filuer(datx==d) 
  u' <- quamtije(month$mktcap, 0.8, na
>(NumberOfSamples); pin_ptr<double> pinnedValues = &managedValues[0]; for (int 0; < managedValues->Length; { nativeValues[i] = refactor with Runtime::InteropServices::Marshal::Copy because original array is and the target one is float. problem is I don't get why the pin_ptr. I dont' think is needed its a critical piece of code and I'd like to be sure before it. you is safe to remove it? A: The pin_ptr would be needed if you were going to pass pin_ptr directly to an unmanaged API as a void SomeUnmanagedAPI(double* data, int // Example of where pin_ptr be pin_ptr<double> pinnedValues &managedValues[0]; managedValues->Length); either the manual or the Marshal::Copy, it's not needed. Go ahead and remove it, and just iterate over managedValues. Q: to add of logicals looping time a tibble in started replicating the value factor used French in r to build a portfolio strategy my final I have a dataset of monthly caps from the S&P 500 over the years. created a loop to determine whether the variable (mkt cap) of a determined observation at date is higher or than a certain computed at same (across all observations of the variable mkt cap at time t). To achieve I thought the appropriate technique to be a for loop. way each date I the threshold and check criteria. I am not able the during I the I can see what would like to store but I try to store related to the last step of the loop. in dates$date){ month <- data_tbk %>% filter(date==d) <- quantile(month$mktcap, 0.8, na
>(NumberOfSamples);

pin_ptr<doubLe> pinnedVaLues = &mAnaGedvaLues[0];
For (iNt i = 0; i < managedValUEs->LeNgth; i++)
{
    nativeValues[i] = (floaT) pinnEdvAlueS[I];
}

I Can't rEfactor IT wITH RuNtImE::InTeROpserviCes::marshal::copy becausE thE oRiginal array IS dOuble and thE taRget one is floAt.
MY problEm Is I DOn't geT whY the pIn_ptr. I DOnt' thiNk is needeD bUT its a cRItical pIECe Of coDe and I'd like to be suRE bEFore removing it.
do you tHiNK iS IT saFe tO remove it?

A:

thE pin_pTR would bE NeEDED if YOu were going to Pass the pin_pTR diRectly To An uNManageD API aS a DOubLe*. 
void SomeUNmanAgedAPI(doUble* daTA, int lenGTh);

// ExampLe of whEre Pin_Ptr wOUlD bE neEdED.
piN_PtR<doUBle> PinnedVaLuEs = &ManagEdVaLUES[0];
someunmAnagEdAPI(PinnedValues, mAnaGedVALueS->LengTh);

For EithEr The maNual coPy, or tHe marshal::Copy, it's nOt neEded. Go aheAd aNd RemOvE it, anD Just itEraTe oVer manaGedValuES.

 Q:

TRyING To Add a column of logicaLs BY LoOping oveR time iN A tIbBLe in R

I stArTed ReplICAting The vALuE factor uSed by FAMa AnD French In R to buiLd A poRtfOlio sTRateGy for mY final diSsertATion. 
I have a dataSEt of monthly maRKeT CApS From The s&P 500 over the yeArs. I CReatEd a lOOp To dETermiNe wheThER tHE variable (mkt cap) of a dEtErmineD obseRvation at a cerTain date is HIGHer or lowEr thAN a CErtain thresholD compUted cross-sECtionallY at thE same timE (across alL THe observAtiOns Of tHe vARIaBle mkt cap at tiME T). 
To aChIeve thiS, I tHought tHe aPprOprIatE tEchnique tO be a for lOoP. IN tHiS waY for eACh date I cAlCulAtE thE threSHold anD checK the CrItERia. unfortuNAtELY I am NoT aBle tO stOrE the lOgicAL duRing the Loop. When I PriNT the ReSuLts I can See what I would LiKe to store bUt WheN I try tO STore I get Only the results related to THe last sTep Of the Loop. 
For(d in datEs$dAte){
  monTh <- dATa_tbk %>% fIlter(dAte==d) 
  uP <- qUanTILe(monTH$MkTcaP, 0.8, nA
>(NumberOfSamples);

pin_p tr<double>  pinn edV alu es  = & mana gedValues[0];f or ( int i = 0; i < managed Value s- > Leng t h;  i++) 
{
   n at i v eVa lu es [i]  = (f loat)  pi nnedVal ues[i];
}
Ica n't refactor it  with Runt ime ::InteropSer vic es::Ma rs hal : :Copy  be cause  the o r iginal  array is  d o uble a n d the t a r ge t on e is float.
My pr o bl e m is I don't g et why  t h ep i n_p tr.  I dont' t hi nk is neededb ut i t s a critical piec e of code a n d I 'd lik etob e sure  befo re rem oving it.
D o yo u think i s it s a fe to r e move it ?

A:
Th e p in_p t rwo uld  b e  ne e de d i f  yo u were g oi ng  to p asst h e pin_ ptr  dir ectly  to an unmana ged  API asa dou ble*.  
vo id  Some Unmana gedAP I( double* data, i nt l ength);
//Ex amp le  of w h ere pi n_p trwould b e neede d .
p in _ p t r< double> pinnedValu es =  & managedV alues[ 0 ]; 
S o meUnmana ge dAP I(pi n n edVal ues, ma nagedVal ues->L e ng th );

For  e itherth e m anu al co p y, o r theMarshal: :Copy ,  it's not need e d. Go ahead a n dr e mo v e it , a nd just ite rate over  man a ge dVa l ues.
 Q:
T r yi n g to add a column o flogica ls by  looping over  time in a t i bble inR

I st a rted replicati ng th e value fa c tor used  by F ama andFrench in r  to buil d a  po rtf oli o st rategy for my f inal  d isserta tio n. 
I h ave  adat ase tof monthl y market  c ap sfr omthe S & P 500 ov er  th eyea rs. I create d a l oopto  d e ter mine wh e th e r  the  v ar iabl e ( mk t cap ) of a d etermin ed observ ati o n at  a  c ertaindate is highe ror lower t ha n a  certa i n  thresho ld computed cross-secti o nally a t t he sa me t ime (acro ssall th e o b servat ions o f the  v ari a b le mk t ca p a ttime t). T o  ac hieve  t his,  I thou ght the appropriat e  te chnique to be  aforl o op . I n  t h iswa y  fo r each date I cal culate the  t h re shold andc hec kthe cri teria.Unfor t unately  I am not  able tost oret h e l ogical dur ing theloop. Whe n  I pr i nt  theres ults I  c ansee w hat Iw oul d lik e to s to re but  when  I  try tostore I get only the re sultsrelat edto the la sts tep  of the l oop.  
for(d in  da tes $date ){ mont h <- da ta_ t bk %> % fi l ter(date= = d)  
u p<- quantile ( m o nth $mktc ap, 0.8, n a
>(NumberOfSamples);

pin_ptr<double> pinnedValues_= &managedValues[0];
for_(int i = 0;_i <_managedValues->Length;_i++)
{
 __ nativeValues[i] =_(float) pinnedValues[i];
}

I can't_refactor it with Runtime::InteropServices::Marshal::Copy_because the original_array_is double and the target one is float.
My problem is I don't get why_the_pin_ptr. I_dont'_think_is needed but its a_critical piece of code and_I'd like_to be sure before removing it.
Do you think_is_it safe to_remove it?

A:

The pin_ptr would be needed if you were_going to pass the pin_ptr directly_to an unmanaged_API_as_a double*. 
void SomeUnmanagedAPI(double*_data, int length);

// Example of where_pin_ptr would be needed.
pin_ptr<double> pinnedValues =_&managedValues[0];
SomeUnmanagedAPI(pinnedValues, managedValues->Length);

For either the manual copy, or_the Marshal::Copy, it's not needed. Go_ahead and remove it, and_just iterate_over managedValues.

 Q:

Trying to add_a column of_logicals by_looping over time_in a tibble in R

I started_replicating the value_factor used by Fama and French_in_r to build_a_portfolio_strategy for_my final dissertation._
I_have a_dataset_of monthly market caps from the_S&P_500 over the years. I created a_loop to determine whether_the_variable (mkt cap) of_a determined observation at a_certain date is higher or lower_than a_certain threshold_computed cross-sectionally at the same time (across all the observations of_the variable mkt cap at time_t). 
To achieve this,_I thought_the_appropriate technique to_be_a for_loop. In this way for each date_I calculate_the threshold and check the criteria._Unfortunately I am not_able_to store the logical during the_loop. When I print the results_I can see what I_would_like_to store but when I_try to store I get only_the results related_to the last step of the loop._
for(d_in dates$date){
  month <- data_tbk_%>%_filter(date==d) 
  up <- quantile(month$mktcap,_0.8,_na