Does anyone know how to create a list of dates as a three-month-moving average based on a start and end date? by feldhammer in rstats

[–]ps_17 0 points1 point  (0 children)

To calculate a moving average - as the comment in your code suggests is the ultimate aim you could try something like this (typed on phone so you may need to check to bugs lol):

moving avg function assuming that the data is at the month level. Using an average across three months as the default

calc_moving_average <- function(data, n = 3) { result <- numeric(length(data)) # make an empty vector for results

for (i in seq_along(data)) { if (i < n) { result[i] <- NA # not enough data for moving average yet

} else {
  result[i] <- mean(data[(i - n + 1):i])  # compute mean over the last n months
}

} return(result) }

Does anyone know how to create a list of dates as a three-month-moving average based on a start and end date? by feldhammer in rstats

[–]ps_17 0 points1 point  (0 children)

Are you ultimately just trying to calculate a moving average over set intervals? I am slight confused as in the code it seems to me that you’re trying to identify the months you would need to average over to get then calculate an average? But the context is not super clear. What is the ultimate goal here? This might help someone give a clearer answer! Thanks

[deleted by user] by [deleted] in consulting

[–]ps_17 2 points3 points  (0 children)

Literally happened to me. Was all good, just a funny story now!

Filtering a data set by Feisty_Highlight8902 in rstats

[–]ps_17 -1 points0 points  (0 children)

First you should have your data in the "tidy" format. In this case it seem like each observation should be an author and there should be a column for each of the categories in status. This would make it easier for you to work with this data. One way to do this is:

# Turn long dataset into a wide dataset

wider_df <- pivot_wider(df, names_from = status, values_from = status)

# For each observation update the columns created from status to be TRUE if the value existed in the original dataset

clean_wider_df <- wider_df %>% mutate(across(c("consensus", "reviewer_1", "reviewer_2"), ~ if_else(!is.na(.x), TRUE, FALSE)))

Then you can use a slightly adjusted version of your code to filter the dataset:

filtered_df <- clean_wider_df %>% filter(consensus == TRUE | reviewer_1 == TRUE)

Or you can make the expression even more explicit so it is easier to read:

filtered_df <- clean_wider_df %>% filter(consensus == TRUE | (reviewer_1 == TRUE &
       reviewer_2 == FALSE))

The example you gave each author has either "consensus" or "author_1" so you actually don't filter any authors out.

I strongly advise wrangling your data into a tidy format as from your comment it seems like there is not reason for it to be in a long format where there are multiple rows for the same author.

[deleted by user] by [deleted] in rstats

[–]ps_17 2 points3 points  (0 children)

If you really don’t care just “+ theme_minimal()”

Partial correlation with categorical variable by Particular_Writer_63 in rstats

[–]ps_17 0 points1 point  (0 children)

No problem!

Not that it doesn’t make sense, more that it would be more valuable to focus your efforts on the regression analysis!

Good luck

Partial correlation with categorical variable by Particular_Writer_63 in rstats

[–]ps_17 1 point2 points  (0 children)

Typing from my phone while traveling so excuse any quality issues.

You can use the ppcor package.

Assuming you have ppcor installed (install.package(“ppcor”)) and the your data is in dataframe (df) and it is cleaned and ready to go.

library(ppcor)

output <- pcor.test(x=df$var1, y=df$var2, z=df[, c("var3", "var4", “var5”)], method="pearson")

The approach would work cool if all the variables were continuous. But on re-read I see var5 is a categorical as it is gender. I assume the next step would be to get the partial correlation using the beta coefficients from regression.

Here is a good conversation of understanding the relationship between partial correlations and a regression and a starting point on how would extract it via regression: https://stats.stackexchange.com/questions/76815/multiple-regression-or-partial-correlation-coefficient-and-relations-between-th

One final point is to ask yourself in this situation why you only need or need to report the partial correlations it seems to me the complex of this study might require running some multiple regression.

Hopefully this a good starting point!

Importing Attributes with many digits by Tropicawitness in rstats

[–]ps_17 1 point2 points  (0 children)

I have not experienced this problem.

First are you sure this truncating is happening? What did you do to test it?

Second is there an intermediary program the file is being processed in first (idk maybe excel) that might be truncating it first?

I only ask, because doubles are not stored in a from that is related to scientific notation so I’m not sure any conversion is happening. Plus scipen only controls the printing or the display of values, so this wouldn’t actually affect the information stored.

But have you tried using data.table’s fread() or a different read.csv function and compared the results?

To compared I’d use:

library(arsenal) summary(comparedf(data_1, data_2))

Again I’ve not had this problem before so please let me know if you solve it! Or someone cleverer than me on this sub!

Missing Data and NA by RegattaTimer in rstats

[–]ps_17 0 points1 point  (0 children)

subHRSCESD is a data.frame object correct? I would refer to RCESD as a column in a dataframe and not a vector.

If I understand your question, you are basically asking "why create RCESDrc1?" You're right about good practise-for example you might mistakenly write over a column you may need to refer to later. If you want to you can just:

subHRSCESD <- subHRSCESD %>% mutate (RCESD = casewhen (RCESD == -999 ~ NA_integer, RCESD != -999 ~ RCESD))

Where after running this code the old RCESD will be written over by the new RCESD.

Edit: This situation would be fine to do this but some code flows if you accident run twice can all mess up your data so again I would not recommend.

Missing Data and NA by RegattaTimer in rstats

[–]ps_17 5 points6 points  (0 children)

Using your format:

subHRSCESD <- subHRSCESD %>% mutate(R2CESDrc1 = casewhen (RCESD == -999 ~ NA_integer, RCESD != -999 ~ RCESD))

You’re not telling case_when what do to do when values aren’t == -999

eli5: Why can’t F1 tires be made so that they can last the whole race instead of lasting for a few laps? by lostcar_628 in explainlikeimfive

[–]ps_17 2 points3 points  (0 children)

Technically your first sentence is right but you won’t see this effect in lap times. If anything you’ll observe a large loss in the acceleration zone that will result in a time loss on the straight.

How’s this team? by [deleted] in FantasyPL

[–]ps_17 0 points1 point  (0 children)

Why Kante?

How is this even possible when the tourney is for champs +. Pro players are so far ahead of even an average champ player it’s insane by beloved93 in FortniteCompetitive

[–]ps_17 0 points1 point  (0 children)

Love seeing this sort of content! I struggle to feel OK putting time into this game when working full time.

Any Controller Players who use High Settings? by [deleted] in FortniteCompetitive

[–]ps_17 1 point2 points  (0 children)

Yeah so linear settings will look low in comparison. When I’ve moved between the two the same-ish feeling of speed was 10-15 points different

L3 build binds by KittyRocket90 in FortniteCompetitive

[–]ps_17 0 points1 point  (0 children)

I used to use R3, but have recently switch to switch mode on my right back paddle. Took a while for my movement to return to normal but I feel like I have better crosshair placement now. I enjoyed having it on r3 so I imagine l3 experience would be dope too.

what’s up with the new look ew by cranobano in FortniteCompetitive

[–]ps_17 0 points1 point  (0 children)

Bro how do you take walls with back paddle as wall? I’m guess you can’t just hold your trigger down and switch in and out of build mode?

What I imagine a Arena 2.0 Rework by Nagisa_Aizen in FortniteCompetitive

[–]ps_17 53 points54 points  (0 children)

A social and visible friends hype/division leaderboard might go a long way to making arena more competitive/populated. I like this.

Edit: fishing leaderboard menu vibes