stevensanderson, to programming
@stevensanderson@mstdn.social avatar

🔍 How to Extract Last Row in Data Frame in R

Base R
Use nrow(my_df) to get the total rows.
Extract the last row with indexing: my_df[nrow(my_df), ].

dplyr
Use tail(my_df, 1) to get the last row.

data.table
Convert to data.table: my_dt <- as.data.table(my_df).
Get last row using .N: my_dt[.N].

Now you know three ways to extract the last row. Try it yourself! 📊

#RProgramming #DataFrames #CodingTips #R #RStats #Programming #Coding #Data #datatable #dplyr #baseR

Post: https://www.spsanderson.com/steveondata/posts/2024-04-18/

symfonystation, (edited ) to random
@symfonystation@newsletter.mobileatom.net avatar

Reblog via Arnaud Langlande

🚀 Are you still leveraging heavy inheritance in your Object-Oriented Programming (OOP) projects?

🤔 It may be time to reconsider your strategy!

I explain 🧵 👇 [1/3]

🖼️ Image: https://unsplash.com/@gabrielsanchez

https://files.mastodon.social/media_attachments/files/111/935/091/021/418/678/original/09e7f7de3dca423a.jpghttps://newsletter.mobileatom.net/8146-2/

StewartLynch, to random
@StewartLynch@iosdev.space avatar

Do you understand Swift subscripts! Learn basics for arrays & dictionaries, then craft custom subscripts for safer, more generic code. Plus, bonus: extensions for String & Arrays! Watch now: https://youtu.be/-QDOsDoWXLY #SwiftLang #iOSDev #CodingTips

https://youtu.be/-QDOsDoWXLY/

shaedrich, to Laravel
@shaedrich@mastodon.online avatar

TIL To easily enter multi-line code into #tinker without trailing slashes at every line, you can enter the string "enter" into your terminal window and then press ENTER. This will open an editor (e.g. nano), where you can edit your code just like normal. When you are ready, you can simply save and exit. Thereafter, tinker executes the entered code ✨ 🚀
🤯
#laravel #amProgramming #codingTips #webdevelopment

stevensanderson, to technology
@stevensanderson@mstdn.social avatar

🚀 Master Repetition with R's replicate() Function!

Example 1: Simulate Dice Rolls
die_rolls <- replicate(20, sample(1:6, 1, replace = TRUE))

Example 2: Generate Random Data
random_samples <- replicate(10, rnorm(5))

Example 3: Evaluate Expressions
sum_of_squares <- replicate(5, sum((1:5)^2))

#RProgramming #CodingTips #ProductivityBoost #r #rstats #technology #innovation #opensource #opensourcesoftware #opensourcecommunity

https://www.spsanderson.com/steveondata/posts/2023-07-31/

smach, to rstats
@smach@masto.machlis.com avatar

If you use RStudio to write R code but aren’t using code snippets, you may want to check them out. They can be a big timesaver!
I did a tutorial article & video a few years ago: https://www.infoworld.com/article/3396616/how-to-use-rstudio-code-snippets.html

@rstats

frankhaenel,

@smach @rstats 📢 Exciting read! 💻 "Code snippets" are like productivity boosters for developers! They are indeed time-savers and make coding a breeze. 📊

stevensanderson, to random
@stevensanderson@mstdn.social avatar

The rep() function allows you to efficiently repeat elements of a vector or a specified value. Its syntax is straightforward: rep(x, times, each). The x parameter represents the element to be repeated, times determines the number of repetitions, and each (optional) specifies how many times each element should be repeated before moving to the next.

#RProgramming #Repetition #CodingTips #DataManipulation

Jeehut, to random German
@Jeehut@iosdev.space avatar

Another #ProductivityHack:

When taking a break or wrapping up the day, do you struggle to pick up where you left off? 😫

Write a quick reminder before stepping away from work! 📝🔒

I add "// TODO: continue here" to my code, sometimes with details. It helps! #CodingTips #iOSDev

Jeehut, to random German
@Jeehut@iosdev.space avatar

🚀 Boost your #Xcode productivity!

Save precious time by disabling "Debug executable" for your scheme when breakpoints aren't needed.⏱️

Console output will still work (for print-debugging), but no more "blank screens" during app start!

Spread the word! 📣 #iOSDev #ProductivityHacks #CodingTips

image/png
image/png

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • mdbf
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • provamag3
  • ethstaker
  • osvaldo12
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • tacticalgear
  • cisconetworking
  • normalnudes
  • anitta
  • Leos
  • megavids
  • lostlight
  • All magazines