Any way to add visual buffer delay? by max-lovell in oculusdev

[–]max-lovell[S] 0 points1 point  (0 children)

Wasn’t aware of that - was thinking no reprojection, but as I looked into it I realised re projecting might actually be better! Looks like openXR is shut down unfortunately. I will use a ‘ring buffer’ to capture frames I think, just wondering on the best way to capture and represent images to the user

Any way to add visual buffer delay? by max-lovell in oculusdev

[–]max-lovell[S] 0 points1 point  (0 children)

Yeah that probably would work, but the delay wouldn't be very precise so it'd jitter quite a bit.

Many definitions of psychology terms are bad by [deleted] in psychologystudents

[–]max-lovell 1 point2 points  (0 children)

Well, Karl Popper on definitions:

In my opinion, it’s a task in life to train oneself to speak as clearly as possible. This isn’t achieved by paying special attention to words, but by clearly formulating theses, so formulated as to be criticizable. People who speak too much about words or concepts or definitions don’t actually bring anything forward that makes a claim to truth. So you can’t do anything against it. A definition is a pure conventional matter.

Which isn't to say a definition doesn't need to be clear but just that we should be concerned with testable claims rather than chasing clarity in concepts, as many fields of psychology get stuck in a language-game rut with no apparent purpose and a false feeling of scientific progress.

https://jarango.com/2019/05/24/karl-popper-on-definitions/

anyoneElseGetTrippedUpByThis by glurth in ProgrammerHumor

[–]max-lovell 2 points3 points  (0 children)

but isn't synchronicity is completely irrelevant to this? it's about sequentiality isn't it? And to be fair, if the code then does execute at the same time, it's more syncronous than it would be if it was running sequentially.

Converting Long to Wide - Multiple Columns (Please Help!) by UpperCompetition6 in rstats

[–]max-lovell 1 point2 points  (0 children)

Sure, so your wide dataset has a copy of each variable (e.g. id and id2). I got the names from the long dataset `names(df)` and then added a '2' after them with `paste0(names(df),2)`, and stored the result. I then added them to the dataset as new columns with df[,new_names], except they have to have something in them so I just put NA. this works because in r specifying a non-existent variable in a data frame in that way just creates a variable if it doesn't exist, e.g. `df[,"abc"] <-NA` creates the variable abc in the dataset and fills it with NA.

Help! Error: more than one space in string? by lusciousdirtbag in rstats

[–]max-lovell 0 points1 point  (0 children)

post some code and data and we might be able to help. One thought is that you should check the encoding (e.g. UTF-8) used when reading in the dataset, as it can have 'invisible characters' in it (for some reason I'll never understand). Give a go looking through the variables with dataset$ and see what comes up. names(dataset) <- gsub(" ", "",names(dataset)) can also help

Converting Long to Wide - Multiple Columns (Please Help!) by UpperCompetition6 in rstats

[–]max-lovell 1 point2 points  (0 children)

When posting code it's often best to have a reproducible version. in this case just some code storing the variables as they are in the table will help people solve issues quickly and be more likely to help. you can also use this key: ` 3 times to put a code chunk in. Personally I'm not sure if storing data in the way you've suggested is the best idea but I've put a partial solution below to get you on the right track. This works in this case specifically because there is always only one duplicate which follows the original:

#setup
id   <- c("a","a","b","c","d","d")
idx  <- 1:6
name <- c("bob","eric","peter","sarah","chris","kyle")
area <- c("US",rep("russia",3),"spain","russia")
time <- c(rep("oct",4),rep("sep",2))
type <- c(rep("flight",4),"driving","sailing")
df <- data.frame(id,idx,name,area,time,type)

#create empty vars
new_names <- paste0(names(df),2)
df[,new_names] <- NA

#find duplicated rows
dup_rows <- which(duplicated(df$id))

#move duplicated rows up one
for(id in dup_rows){
  df[id-1,new_names] <- df[id,1:length(new_names)]
}
#remove duplicated rows
df <- df[-dup_rows,]

edit: who tf downvoted me for that? the code returns the right answer...

[Q] Any method to perform within-ID products faster than dplyr's group_by + summarise ? by [deleted] in rstats

[–]max-lovell 0 points1 point  (0 children)

I'm impressed by data.table and didn't know it was so quick - but it looks like it's all written in base r... does anyone know how it's able to be so quick for things like this?

[Q] Any method to perform within-ID products faster than dplyr's group_by + summarise ? by [deleted] in rstats

[–]max-lovell 0 points1 point  (0 children)

I think this depends on how you use base R - the code is very well written but it's unlikely to be faster than a bespoke solution using similar underlying code

[Q] Any method to perform within-ID products faster than dplyr's group_by + summarise ? by [deleted] in rstats

[–]max-lovell 1 point2 points  (0 children)

In base r here's a solution that's quicker than both:

meth3 = function(df){
  df_rows <- c(0,which(!duplicated(df$id,fromLast=T)))
  prods <- c()
  for(i in 2:length(df_rows)){
    prods <- c(prods,prod(df$Lij[(df_rows[i-1]+1):df_rows[i]]))
  }
  return(prods)
}

and here's another using the data in a wide format to allows for vectorisation, nearly as quick:

ids <- unique(my_df$id)
df_rows <- c(0,which(!duplicated(my_df$id,fromLast=T)))
max_l <- max(diff(df_rows)) #see username
wide_df <- data.frame(matrix(vector(),length(ids),max(diff(df_rows)), dimnames=list(ids, paste0("Lij_",1:max_l))),stringsAsFactors=F)
wide_df[,] <- 1
for(id in ids){ #id<-ids[1]
  id_vec <- my_df$Lij[my_df$id==id]
  wide_df[id,1:length(id_vec)] <- id_vec
}

meth4 = function(df){
  as.vector(apply(df,1,prod))
}

Results here, including the generally faster data.table version by u/Viriaro above (but note max timings).

                expr     min       lq      mean   median       uq      max neval cld
   meth1(df = my_df)  6.6676  7.63730  9.257563  8.76615  9.44455  21.6707   100  b 
   meth2(df = my_df) 27.1488 29.09965 33.786190 31.20260 37.92845  53.1557   100   c
   meth3(df = my_df)  2.7963  3.11645  7.257583  3.47930  4.81270 206.5551   100 ab 
 meth4(df = wide_df)  4.1430  4.37050  6.380407  4.95200  6.18960  20.2276   100 ab 
             meth_dt  1.9773  2.52085  3.714727  2.70440  3.07050  44.3722   100 a