RPubs will retire in June 2027. Your existing documents will stay accessible through December 31, 2031
and Connect Cloud is the recommended home for new publishing. Read the blog post

Recently Published

Numeric classes and storage modes
I explored the numeric class in R, focusing on the distinction between doubles and integers, their types, and how they are handled in arithmetic operations. I began by defining two variables: a, a double with a decimal, and b, an integer denoted by the L suffix. Using typeof(), I confirmed that a is stored as a double and b as an integer. Both were verified as numeric using is.numeric(). I also examined the conversion of logical values to numeric, observing that as.numeric(FALSE) correctly returns 0, but remains a double rather than an integer. To further understand data type precision, I used is.double() to check the precision of different numeric inputs. Lastly, I performed a benchmarking exercise using the microbenchmark package to compare the performance of arithmetic operations on integers and doubles. This highlighted subtle differences in execution times, demonstrating the impact of choosing the appropriate numeric type in computational tasks. This exercise deepened my understanding of numeric classes and their significance in optimizing R code for performance and memory efficiency.
Plot
Document
Code along 9 DA
The Character Class
In this entry, I explored the basics of the character class in R, focusing on coercion and type verification. I began by defining a character string, "Avery analyzes data efficiently and effectively", and confirmed its type using the class() and is.character() functions. These checks ensured that the variable was correctly recognized as a character string. Next, I experimented with coercion. I converted a numeric string "42" into a numeric value using as.numeric(), which successfully returned 42. However, when I attempted to coerce the word "analyzes" into a numeric value, R returned NA and issued a warning about coercion. This exercise highlighted the importance of understanding data types and the limitations of coercion in R. Through these steps, I reinforced my understanding of handling character data and the significance of proper type management in R. This foundational knowledge is crucial for ensuring accurate data transformations and avoiding errors in data analysis workflows.
Document
t-test lab
Syllabus
Project_3_Data_607
HTML
PS2
Date-time classes (POSIXct and POSIXlt)
I worked with date-time objects in R using the POSIXct class. I formatted and printed various components of a date-time object, such as seconds, minutes, hours, and time zone details. I performed date-time arithmetic by adding seconds and combining hours, minutes, and seconds using both direct calculations and as.difftime. Additionally, I calculated the difference between two date-time objects using difftime(). Lastly, I parsed strings into date-time objects, handling different time formats and time zones effectively. This exercise focused on practical manipulation and formatting of date-time data for precise analysis.