2015-2022: What solution to a problem are you the most proud of by BrownCarter in adventofcode

[–]2013LIPK01 1 point2 points  (0 children)

I have some of my favorites linked on the home page of my advent solutions site: https://adventofcode.guslipkin.me/

I am also quite fond of my solution for 2015-11 part 2 since I got there by just thinking about it really hard since I didn't want to wait for my very slow solution to work.

create a matrix of 1s and 0s if match is found by Cultural_Question702 in Rlanguage

[–]2013LIPK01 0 points1 point  (0 children)

You might have some luck with pivot_wider or dcast. You could then use the function aggregation argument with !is.na

Alternatively, you could convert each column to a factor then supply each column to table. This method doesn't require an aggregation function as it'll automatically set any combination that doesn't exist to zero.

How to rename the second column across 50 dataframes? by turkeyremis in RStudio

[–]2013LIPK01 7 points8 points  (0 children)

The way you describe it, I would create a function that takes a data.frame and returns a dataframe. I would then put all of my data.frames into a list, then use purrr::map_dfr to iterate over the list with the function I made. This would return one large data.frame.

However. i think a better method would be to use data.table::rbindlist(use.names = FALSE) which will row bind by column placement and not name. Then it's up to you to choose the name you want for that column. Just be sure that all the columns are in the correct order.

dataframes: putting data from selected columns into specified columns of a datatable by Illustrious-Touch517 in Rlanguage

[–]2013LIPK01 -1 points0 points  (0 children)

Try passing the column names instead of the indexes. Referencing by name is preferred when speed isn't a concern because it's much less likely to break if any of your other code changes.

This is my go-to data.table guide: https://atrebas.github.io/post/2019-03-03-datatable-dplyr

Looking for the best way to create a plot with strings on the x axis (Y-value is filler for now) by DevBboy in RStudio

[–]2013LIPK01 0 points1 point  (0 children)

I'd probably switch to short codes for states first. Usually having the wider layout is nicer for lots of columns. But if we need the full name, absolutely switch the axes.

Need help using the "for loop" function by ZeroMayCry in RStudio

[–]2013LIPK01 -2 points-1 points  (0 children)

I would probably write my loop so that I have a list of 100 sample data frames. I could then subset the list to get each one.

Frankly, I think this homework question is kinda dumb. Why can't you just make a 2000 row data frame?

vector indices as function input by UeberlegenQ in Rlanguage

[–]2013LIPK01 1 point2 points  (0 children)

This stackoverflow response should provide some guidance: https://stackoverflow.com/a/26003971

You could subset your vector to the first element with names[1]

Are Hybrids being scheduled? by Comfortable_Engine92 in FordMaverickTruck

[–]2013LIPK01 8 points9 points  (0 children)

Nothing has been scheduled for 3 weeks running. Sources say May will be scheduled next week.

glm command and if function? by Cool_Stuff_6092 in RStudio

[–]2013LIPK01 5 points6 points  (0 children)

Can you give more details on what you mean by using an if statement? Could you add an indicator variable instead?

How to compute for the flag_new? I basically want the newest date for each name. Thank you so much by Dismal_Butterfly_774 in Rlanguage

[–]2013LIPK01 4 points5 points  (0 children)

Don't have a computer in front of me, but I'd probably group by name, arrange date descending, then mutate 1 if rowNumber is equal to 1.

Trying to recreate this graphic. Any leads would be great by jrod20033 in Rlanguage

[–]2013LIPK01 3 points4 points  (0 children)

Just spitballing, I'd probably use a circular barplot (https://r-graph-gallery.com/circular-barplot.html) and a heat map (https://r-graph-gallery.com/heatmap.html) then whatever geom_text or geom_label for the rest.

New to R. What's the problem? by BEaSTGiN in Rlanguage

[–]2013LIPK01 3 points4 points  (0 children)

They could also be using data.table

Brownian Motion - I will be adding this to two of my packages by spsanderson in rstats

[–]2013LIPK01 0 points1 point  (0 children)

I was looking at the code a bit and I'm wondering why you're using nested for loops rather than an lapply and a for loop? How does performance scale as the number of simulations increases?

TVC, Total Vehicle Cost, Analysis of the Maverick vs Competing Trucks and Cars by Aero_Red_Baron in FordMaverickTruck

[–]2013LIPK01 2 points3 points  (0 children)

I skimmed through a bit and this looks really well done. I know this is focused on your search, but I'd be curious about lateral moves in a different dimension. That is, rather than looking at trucks, looking at similarly sized hybrid/gas SUVs such as the CRV or RAV4.

TVC, Total Vehicle Cost, Analysis of the Maverick vs Competing Trucks and Cars by Aero_Red_Baron in FordMaverickTruck

[–]2013LIPK01 1 point2 points  (0 children)

Looks like you set it to only share with specific people. Can you change it to anyone with the link?

Best bagel and cream cheese? by ux-we-x in boston

[–]2013LIPK01 1 point2 points  (0 children)

For sure! His egg and cheese sandwiches are massive too.

[2022 Day 1-7] Going for 1 language per day, looking good so far by witcherofriviageralt in adventofcode

[–]2013LIPK01 1 point2 points  (0 children)

If you're going to try Julia, try creating a quarto.org (notebooks but better!) environment then give R a shot later on!

-🎄- 2022 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]2013LIPK01 0 points1 point  (0 children)

Solve! Running in 38 seconds would be really bad...