Steves Data and R channel
378 subscribers
640 photos
14 videos
1 file
325 links
Talk mainly about data, R, SQL etc.
Download Telegram
In today's blog post, I'm sharing everything you need to know about rounding numbers in R! πŸ”’ I've been working with data analysis for years, and mastering these rounding functions has been a game-changer for my workflow.

I'll walk you through the five essential rounding functions in R:
round()   # My go-to for basic rounding
signif() # Perfect for scientific notation
ceiling() # When you need to round up
floor() # When you need to round down
trunc() # For cutting off those decimals


Here's a quick example I use all the time:
prices <- c(19.99, 24.49, 5.75)
round(prices, digits = 2)


I've included plenty of practical examples and real-world scenarios, so you can see exactly how these functions work in action. πŸ’‘ The best part? These techniques will help you clean up your data and make your analyses more precise.

Try this simple exercise to get started:
Take any decimal number (like 3.14159) and practice using each function. You'll be surprised how different the results can be!

I'd love to hear about your experiences with these functions! πŸ’¬ Drop a comment below sharing:
- Which function do you use most often?
- What challenges have you faced with rounding in R?
- Any clever tricks you've discovered?

Remember, practice makes perfect! Start with small examples and work your way up to more complex data sets. You've got this! πŸš€

Happy coding!

#RStats #DataScience #Programming #DataAnalysis

Post: https://www.spsanderson.com/steveondata/posts/2024-12-31/
πŸ“Š My 2024 LinkedIn stats (from Cleve.ai):
- 753 posts
- 10.8k total reactions
- 1,128 comments

Here's 10 lessons I learned in 2024:
πŸ“’ Embrace opportunities that allow you to share your knowledge.
🀝 Collaboration with talented co-authors enhances the writing process.
🌐 Hosting webinars can significantly impact your professional network.
πŸ“š Creating engaging content can help others grow their skills.
🎨 Design matters; a good logo can make a strong impression.
πŸŽ‰ Celebrate small wins to maintain motivation in your projects.
❀️ Community support is vital for personal and professional growth.
πŸš€ Sharing your journey inspires others in their own paths.
πŸ’» Continually updating your skills is essential in tech fields.
πŸ”„ Stay curious and open to feedback for continuous improvement.

My 3 favourite personal highlights in 2024:

1️⃣ Launched a new triangular distribution in TidyDensity package!
2️⃣ Received a leadership award, thanks team for the hard work!
3️⃣ Started new role as Author; book on Excel & data analysis launched!

Excited for what lies ahead! 🌟

Get your free LinkedIn unwrapped from cleve.ai/unwrapped.

#LinkedinUnwrapped #CleveAI
Have a wonderful New Year. I wish all of you the absolute best! Thank you for following!
In today's blog post, I'm showing you how to transpose data frames in R - a fascinating way to transform your data's perspective. πŸ”„

I've put together my favorite methods, starting with the classic t() function:

# Here's what I use daily
my_data <- data.frame(
planet = c("Mars", "Venus", "Jupiter"),
distance = c(227.9, 108.2, 778.5),
moons = c(2, 0, 79)
)

# Simple and elegant
transposed <- as.data.frame(t(my_data))


I've found these approaches particularly useful when preparing data for visualization or analysis. Here's another neat trick using tidyr:

# A more flexible approach I love
library(tidyr)
tidy_transform <- my_data %>%
gather(key = "metric", value = "value")


Try this quick experiment on your own:
- Create a small dataset
- Try both transformation methods
- Compare the results

#Rstats #DataScience



Post: https://www.spsanderson.com/steveondata/posts/2025-01-02/
In today's article, I'm sharing my learning journey through Linux archiving and backup – a topic I'm exploring right alongside you! πŸ“š

I break go over tools like tar, gzip, and rsync with practical examples. Here's a simple command I learned that changed everything:
tar czf backup.tar.gz ~/important-files


As a fellow learner, I found that practicing these commands in a test directory helped me understand them better. I encourage you to try the hands-on exercises I've included – they're designed for beginners like us! πŸš€

Remember, we're learning together, and mistakes are part of the process. Happy backing up! πŸ’Ύ

#Linux #DataBackup #TechLearning #LinuxCommunity

Post: https://www.spsanderson.com/steveondata/posts/2025-01-03/
In today's blog post, I'm excited to share with you my complete guide on removing rows containing zeros in R! 🎯

Let me walk you through three powerful approaches I use regularly:

1. Base R (perfect for beginners!) 🌱
# Here's a simple way to remove those pesky zeros
df[rowSums(df == 0) == 0, ]


2. dplyr (my go-to for readable code) πŸ’»
df %>%
filter(across(everything(), ~. != 0))


3. data.table (when speed matters!) ⚑
dt[!apply(dt == 0, 1, any)]


I've found that each method has its sweet spot. For smaller datasets, I stick with base R. When I need clean, maintainable code, dplyr is my best friend. And when I'm dealing with massive datasets, data.table saves the day!

Why not give it a try yourself?:
practice_df <- data.frame(
x = c(1, 0, 3, 4, 5),
y = c(2, 3, 0, 5, 6),
z = c(3, 4, 5, 0, 7)
)

Post: https://www.spsanderson.com/steveondata/posts/2025-01-06/
In today's article, I want to share a super useful R programming technique I use all the time - creating empty data frames! πŸ“Š

Here's my go-to method for creating a simple empty data frame:

my_df <- data.frame()


Here's what I do when I want to set up specific columns and data types:

my_structured_df <- data.frame(
name = character(),
age = numeric(),
score = numeric(),
stringsAsFactors = FALSE
)


πŸ’‘ Quick tip: I always set stringsAsFactors = FALSE when working with text data - it saves me headaches later!

Here's a fun challenge: Create an empty data frame with three columns:
- product_name (character)
- price (numeric)
- in_stock (logical)

#RStats #DataScience #Programming πŸš€

Post: https://www.spsanderson.com/steveondata/posts/2025-01-07/
In today's article, I'm sharing my journey with C programming's character I/O functions! πŸ–₯️

Key points I've learned:
β€’ putchar() outputs single characters
β€’ getchar() reads keyboard input
β€’ Both are simpler than printf/scanf for character operations

Quick example I wrote while learning:
while ((ch = getchar()) != '.') {
putchar(ch);
}


Common gotchas I discovered:
β€’ Store in int, not char (EOF handling)
β€’ Watch out for that sneaky newline character
β€’ Buffer clearing is important

Your turn! Try these:
β€’ Build a character counter
β€’ Create a simple text mirror
β€’ Convert text to uppercase

I'm still learning too, and would love to see what you create! Drop your code in the comments. πŸ’ͺ

#CProgramming #CodingJourney #Programming

Post: https://www.spsanderson.com/steveondata/posts/2025-01-08/
Tomorrow's Post, Matrices.
πŸ“Š In today's article, I showed you how to create empty matrices in R. I walked through several methods, from the basic matrix() function to more advanced techniques.

Here's a quick example of what we covered:
# Simple empty matrix
matrix(NA, nrow = 3, ncol = 3)


I shared best practices, common pitfalls to avoid, and performance tips that will save you time. Remember, pre-allocating your matrices can significantly boost your code's efficiency!

🎯 Now it's your turn! Start with creating a simple 4x4 matrix and experiment with filling it using different patterns. Don't worry if you make mistakes - that's part of learning. The key is to practice and play around with the concepts.

Want to level up? Try combining matrices with other R operations or create a function that generates custom-patterned matrices.

Happy coding!

#RStats #DataScience #Programming

Post: https://www.spsanderson.com/steveondata/posts/2025-01-09/
In today's article, I shared my ongoing journey with Regular Expressions in Linux. As someone who's learning alongside you, I wanted to break down this powerful tool into digestible pieces that we can all understand!

I explored the core concepts of regex, from basic patterns to more advanced matching:

# Start with something simple!
grep 'hello' file.txt # Finding 'hello' anywhere
grep '^hello' file.txt # Finding 'hello' at line start


While writing this guide, I discovered that regex is like a Swiss Army knife for text processing. Pattern matching for phone numbers:

# This pattern helped me organize my contact list
grep -E '^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$' contacts.txt


Try these exercises:
1. Create a simple text file
2. Search for specific words
3. Match email patterns
4. Share your results!

#LinuxLearning #RegularExpressions #CodingJourney

Post: https://www.spsanderson.com/steveondata/posts/2025-01-10/
In today's article, I shared essential knowledge about creating empty lists in R programming! πŸš€

I walked through different ways to create and manage empty lists, starting with the basics:

# Simple but powerful
empty_list <- list()

# With pre-allocated size
sized_list <- vector("list", 5)


Lists are fantastic because they can store any type of data - numbers, text, even other lists! I covered everything from memory management to naming conventions, helping you work more efficiently with R lists.

Here's a fun exercise: Create a list to store your daily activities, with nested lists for different times of the day. The flexibility of R lists makes this a great learning opportunity! πŸ’‘

#Rprogramming #coding #datastructures

Post: https://www.spsanderson.com/steveondata/posts/2025-01-13/
πŸ”§ In today's blog post, I shared practical ways to create empty vectors in R - a fundamental skill for data analysis and programming.

I covered several methods to get you started:

# Basic empty vector
vec <- c()

# Type-specific vectors
num_vec <- numeric(0)
char_vec <- character(0)


The main takeaways:
β€’ Multiple ways to initialize empty vectors
β€’ Best practices for memory management
β€’ Performance tips to speed up your code
β€’ Real-world applications

Here's a pro tip I use daily - pre-allocate your vector size when possible:

# Faster approach
efficient_vec <- numeric(1000)

# Slower approach
growing_vec <- numeric(0)
for(i in 1:1000) {
growing_vec <- c(growing_vec, i)
}


🎯 Ready to practice? Try the example in the blog post!

The concepts we covered today will help you write cleaner, more efficient R code.

#Rstats #DataScience #Programming πŸš€

Post: https://www.spsanderson.com/steveondata/posts/2025-01-14/
In today's article, I talk about some C programming string functions! πŸš€ As I continue learning and exploring C, I wanted to share my discoveries about handling text in our programs.

I cover some functions like gets(), puts(), and strcat(), explaining what I've learned about their proper usage. Here's a simple example I'm practicing with:

char greeting[50] = "Hello ";
strcat(greeting, "friends!"); // Combining strings
puts(greeting); // Output with automatic newline


Safety is super important! πŸ›‘οΈ I explain why we should avoid gets() and use fgets() instead. I'm still getting comfortable with these concepts myself, but it's exciting to share what I learn with you.

Give these functions a try in your own code! Start with simple examples and gradually build up.

#CProgramming #CodingJourney #LearningToCode

Post: https://www.spsanderson.com/steveondata/posts/2025-01-15/
In today's post, I walked through different methods for creating empty data frames in R! πŸ’» I'm excited to share these methods that have helped me streamline my data analysis workflow.

Here is a simple example

df <- data.frame(
user_id = integer(),
timestamp = as.POSIXct(character()),
score = numeric(),
stringsAsFactors = FALSE
)


I covered everything from basic base R approaches to more advanced dplyr and data.table methods. Each has its sweet spot, and you'll find your favorite as you practice.

Ready to give it a try? Start by creating your own empty data frame with three columns of different types. Play around with the methods and see which feels most natural to you. Remember, the best way to learn is by doing! πŸš€

I'd love to hear how it goes - which method clicked for you? What will you build with your new skills?

Happy coding! 🎯

#Rstats #DataScience #Programming

Post: https://www.spsanderson.com/steveondata/posts/2025-01-16/
In today's article, I explore some basic Linux text processing commands that every developer should know. 🐧

I'm learning alongside you as I break down powerful tools like cat, sort, uniq, cut, and paste. These commands are your friends for manipulating and analyzing text files efficiently from the command line.

Here's a simple example of what you can do:
cat file.txt | sort | uniq


I encourage you to practice these commands on your own files. Start with basic operations like displaying file contents with cat, then progress to sorting and removing duplicates. Don't worry if it seems complex at first - I'm also growing my skills with each new command I learn.

Try combining different commands using pipes. The possibilities are endless! πŸ’ͺ

#Linux #Programming #TextProcessing

Post: https://www.spsanderson.com/steveondata/posts/2025-01-17/