Data Science 100 Knocks (Structured Data Processing) – R Part4 (Q61 to Q80)

Articles in English
Commentary :

This code performs the following operations:

Compute the total amount spent by each customer in the df_receipt data frame, and store it in df_tmp_1.

Join df_receipt and df_product data frames by product_cd, and filter out only the rows where category_major_cd is equal to "07".

Compute the sum of the amount column for each customer in the filtered data frame, and store it in df_tmp_2.

Join df_tmp_1 and df_tmp_2 data frames by customer_id.

Compute the sales rate of category major code "07" for each customer, and store it in a new column named sales_rate.

Slice the resulting data frame to show the first 10 rows.

The inner_join function is used to merge data frames on a common variable. The mutate function adds a new column to the data frame, which is calculated based on existing columns. The slice function is used to extract a subset of rows from the data frame.
 
 
 
Commentary :

The first line of code creates a new data frame df_product_1 that removes all rows with missing values (NA) from the original data frame df_product, using the na.omit() function.

The second line of code uses the paste() function to print a message indicating the number of rows in df_product before and after the removal of NAs. Specifically, nrow(df_product) returns the number of rows in df_product, and the first paste() call concatenates this number with the string "Before deletion:". Similarly, nrow(df_product_1) returns the number of rows in the new data frame df_product_1, and the second paste() call concatenates this number with the string "After deletion:".

This code provides a quick way to check the effect of removing NAs on the number of observations in the data frame.
 
Data Science 100 Knocks (Structured Data Processing) - R
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - R Part1 (Q1 to Q20)
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - R Part2 (Q21 to Q40)
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - R Part3 (Q41 to Q60)
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - R Part4 (Q61 to Q80)
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - R Part5 (Q81 to Q100)
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice R, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.
Data Science 100 Knocks (Structured Data Processing) - SQL
This is an ipynb file originally created by The Data Scientist Society(データサイエンティスト協会スキル定義委員) and translated from Japanese to English by DeepL. The reason I updated this file is to spread this practice, which is useful for everyone who wants to practice SQL, from beginners to advanced engineers. Since this data is created for Japanese, you may face language problems when practicing. But do not worry, it will not affect much.

 

Comment