<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/data-manipulation-with-data-table-part-1/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.r-exercises.com/2017/06/15/data-manipulation-with-data-table-part-1/?utm_source=rss&utm_medium=rss&utm_campaign=data-manipulation-with-data-table-part-1"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2016/11/Occasional-Table-Group.jpg" target="_blank"><img sizes="(max-width: 300px) 100vw, 300px" src="https://i1.wp.com/www.r-exercises.com/wp-content/uploads/2016/11/Occasional-Table-Group-300x168.jpg?resize=300%2C168" alt="" class="wp-image-3037" data-recalc-dims="1"></a><br>
In the exercises below we cover the some useful features of data.table ,data.table is a library in R for fast manipulation of large data frame .Please see the data.table vignette before trying the solution .This first set is intended for the begineers of data.table package and does not cover set keywords, joins of data.table which will be covered in the next set . Load the data.table library in your r session before starting the exercise<br>
Answers to the exercises are available <a rel="nofollow" href="http://www.r-exercises.com/2017/06/15/data-manipulation-with-data-table-part-1-solutions/" target="_blank">here</a>.</p>
<p>If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.</p>
<p><strong>Exercise 1</strong><br>
Load the iris dataset ,make it a data.table and name it iris_dt ,Print mean of Petal.Length, grouping by first letter of Species from iris_dt . </p>
<p><strong>Exercise 2</strong><br>
Load the diamonds dataset from ggplot2 package as dt (a data.table) ,Find mean price for each group of cut and color .<br>
<strong>Exercise 3</strong><br>
Load the diamonds dataset from ggplot2 package as dt . Now group the dataset by price per carat and print top 5 in terms of count per group . Dont use head ,use chaining in data.table to achieve this</p>
<p><strong>Exercise 4</strong><br>
Use the already loaded diamonds dataset and print the last two carat value of each cut .</p>
<p><strong>Exercise 5</strong><br>
In the same data set , find median of the columns x,y,z per cut . Use data.table’s methods to achieve this .</p>
<p><strong>Exercise 6</strong><br>
Load the airquality dataset as data.table, Now I want to find Logarithm of wind rate for each month and for days greater than 15<br>
<strong>Exercise 7</strong><br>
In the same data set , for all the odd rows ,update Temp column by adding 10 . </p>
<p><strong>Exercise 8</strong><br>
data.table comes with a powerful feature of updating column by reference as you have seen in the last exercise,Its even possible to update /create multiple columns .Now to test that in the airquality data.table that you have created previously,add 10 to Solar.R ,Wind . </p>
<p><strong>Exercise 9</strong><br>
Now you have a fairly good idea of how easy its to create multiple column ,Its even possible to use delete multiple column using the same idea. In this exercise , use the same airquality data.table that you have created previously from airquality and delete Solar.R,Wind,Temp using a single expression<br>
<strong>Exercise 10</strong><br>
Load the airquality dataset as data.table again , I want to create two columns a,b which indicates temp in Celcius and Kelvin scale . Write a expression to achieve same.<br>
Celcius = (Temp-32)*5/9<br>
Kelvin = Celcius+273.15</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="http://www.r-exercises.com/2017/04/26/shiny-application-layout-exercises-part-2/" title="Shiny Application Layouts Exercises (Part-2)" target="_blank">Shiny Application Layouts Exercises (Part-2) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2016/12/11/descriptive-analytics-part-5-data-visualisation-categorical-variables/" title="Descriptive Analytics-Part 5: Data Visualisation (Categorical variables)" target="_blank">Descriptive Analytics-Part 5: Data Visualisation (Categorical variables) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/2016/06/16/summary-statistics-with-aggregate/" title="Summary Statistics With Aggregate()" target="_blank">Summary Statistics With Aggregate() </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.r-exercises.com/2017/06/15/data-manipulation-with-data-table-part-1/?utm_source=rss&utm_medium=rss&utm_campaign=data-manipulation-with-data-table-part-1"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/6TrliFTyxbY" height="1"></a></div>