<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kiranmai VP on Medium]]></title>
        <description><![CDATA[Stories by Kiranmai VP on Medium]]></description>
        <link>https://medium.com/@kiranmaivp?source=rss-1028bfc42a0b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9lxovo9nNF-H-cS_tDuIzQ@2x.jpeg</url>
            <title>Stories by Kiranmai VP on Medium</title>
            <link>https://medium.com/@kiranmaivp?source=rss-1028bfc42a0b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:40:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kiranmaivp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Analyse data stored in AWS S3 using R]]></title>
            <link>https://medium.com/@kiranmaivp/analyse-data-stored-in-aws-s3-using-r-3cc73e17f563?source=rss-1028bfc42a0b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cc73e17f563</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Kiranmai VP]]></dc:creator>
            <pubDate>Tue, 26 Oct 2021 21:28:04 GMT</pubDate>
            <atom:updated>2021-10-29T23:23:03.531Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Analyze data stored in AWS S3 using R</strong></h3><p>This Medium post walks you through how data stored in an AWS account can be analyzed using R via the IDE: RStudio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*JqBkaV9LgDpZhWnt1CiIEQ.png" /><figcaption>Image from Forbes: Why Too Much Data Is A Problem</figcaption></figure><p>Over the recent years, we have seen a massive influx of data across all sectors of industries. Analyzing and Visualizing this data could help us learn about the underlying patterns in it. This data could be humongous to store on a local machine(PCs), making it impossible or potentially slowing down our local compute environment. And for this very reason, Cloud Service providers come to our rescue. It is significant in dealing with these challenges, it provides a platform to store a large amount of data, enhancing scalability and giving access to only a few users, thereby securing data. Storing data in the cloud also enables collaborating amongst various developers across regions working on a common problem using the same data.</p><p>One such service that empowers us to achieve all the above is the AWS S3. It allows us to store raw input files, results, reports, artifacts, and anything else, along with accessibility over the internet, making sharing resources with collaborators easy. In AWS S3, data is stored in buckets in the form of objects which can be accessed and manipulated based on the permissions given to the user. Also, as workload grows in R, migrating the files from the local compute environment to a fully managed cloud service, like AWS S3 provides a resilient system to handle data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwXQMFuz-zvfbGAZ15sALg.jpeg" /><figcaption>RStudio and Amazon S3</figcaption></figure><p>To analyze the data stored in an S3 bucket, we first have to access it. We use the R programming language as it is popular amongst statisticians, scientists, and data analysts for analyzing data. R has a large user community that developed thousands of freely available packages for data visualization, manipulation, statistical tests, Machine Learning, and Deep Learning. To access the data in the S3 bucket, we use one such package: aws.s3 to help us connect to AWS and its user buckets and work on the data from our local compute environment — RStudio in our local setup.</p><p>A quick review of a user and bucket in AWS and files stored in it is shown here. For demonstrating, I have created a free AWS account that provides access to all the AWS services- S3, EC2, IAM, etc.<br> <br> 1. User: The user “kiranmaivp” was created with “AmazonS3FullAccess” permissions to access all S3 buckets created in the AWS account. While creating the user, make sure to make a note of Access ID and Secret Access Key. These parameters are required to enable R to connect to the user from the RStudio IDE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bjQaYFYCSB6BsbaUh0nMA.png" /><figcaption>User is added in IAM in AWS and granted complete access to S3</figcaption></figure><p>2. Bucket: An S3 bucket- kiranmai-edav-cc created has the following files in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnlLqwWL9EHHpLTYJFOW4g.png" /><figcaption>It has 4 files</figcaption></figure><p>3. Files in a bucket: Each file in the bucket has an “S3 URI” parameter that allows access to the file. This value is unique for every file in that particular bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IELxLtc2t10PgeuqkQp9WA.png" /></figure><p>Now that we have the necessary setup on the AWS side, we shall use the R package: aws.s3 to perform the following on the data from Rstudio IDE console.</p><ol><li>First, we need to install and load the package:</li></ol><pre>&gt;install.packages(&quot;aws.s3&quot;)<br>&gt;library(&quot;aws.s3&quot;)</pre><p>2. Next, we want to connect to the AWS user from our IDE. We need to give three parameters to access the user- Access Key ID, Secret Access Key, and the AWS region where the setup is present.</p><pre>&gt; Sys.setenv(<br>+     &quot;AWS_ACCESS_KEY_ID&quot; = &quot;access-key&quot;,<br>+     &quot;AWS_SECRET_ACCESS_KEY&quot; = &quot;secret-access-key&quot;,<br>+     &quot;AWS_DEFAULT_REGION&quot; = &quot;us-east-2&quot;<br>+ )</pre><p>3. After the connection is established, we can preview all the buckets the user can access:</p><pre>&gt; bucketlist()<br>            Bucket             CreationDate<br>1 kiranmai-edav-cc 2021-10-26T06:45:54.000Z</pre><p>4. We can also check the files present in the bucket using the bucket name:</p><pre>&gt; get_bucket(bucket = &quot;kiranmai-edav-cc&quot;)<br>Bucket: kiranmai-edav-cc</pre><pre>$Contents<br>Key:            123.pdf <br>LastModified:   2021-10-26T07:10:18.000Z <br>ETag:           &quot;eb61ee550c01da04c49e40b5876e6336&quot; <br>Size (B):       515385 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><pre>$Contents<br>Key:            data.csv <br>LastModified:   2021-10-26T06:48:45.000Z <br>ETag:           &quot;59357344b8ebf68e669c9a32d151c76f&quot; <br>Size (B):       9140113 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><pre>$Contents<br>Key:            example.R <br>LastModified:   2021-10-26T07:29:59.000Z <br>ETag:           &quot;64a1e8adefb5788daf0d5ae670845faf&quot; <br>Size (B):       25 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><pre>$Contents<br>Key:            example1.Rmd <br>LastModified:   2021-10-26T07:31:18.000Z <br>ETag:           &quot;e8bd29412f6837c5f86e1c95caae2903&quot; <br>Size (B):       23 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><p>5. We can load the particular file in S3 by specifying its S3 URI in the s3read_using function call. This call loads the file to our IDE — Rstudio in a tabular format.</p><pre>&gt; data_fb &lt;- s3read_using(FUN = data.table::fread, object = &quot;s3://kiranmai-edav-cc/data.csv&quot;)<br>&gt; View(data_fb)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbUAdAe-Y4_CD1sIWIBJiQ.png" /><figcaption>Data read from s3 bucket in Rstudio in a tabular format</figcaption></figure><p>6. Now we can perform various operations on the data. Here, I am just creating a simple scatter plot for the overall rating vs age of various players along with preferred foot for playing. It shows that more players prefer playing with their Right foot.</p><pre>ggplot(data_fb, aes(x=Age, y=Overall, color= data_fb$`Preferred Foot`)) + <br>  geom_point()+xlab(&quot;Age&quot;) +<br>    ylab(&quot;Overall Rating&quot;)+<br>     ggtitle(&quot;Age vs Rating with Preferred Foot&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xjkc9T7xzwrknwkuE4JOAw.png" /></figure><p>7. We can plot many other plots and perform analysis on the data being read from Amazon s3 bucket. In this figure, I have plotted the top 15 nationality players along with their count.</p><pre>data &lt;- data_fb %&gt;% group_by(Nationality) %&gt;% summarise(count=n()) %&gt;% arrange(desc(count))<br></pre><pre>ggplot(data[1:15,], aes(x=fct_inorder(Nationality), y=count)) +<br>   geom_bar(fill = &quot;lightblue&quot;,stat=&quot;identity&quot;)+xlab(&quot;Nationality&quot;)+<br>    ylab(&quot;Number of Players&quot;)+<br>  ggtitle(&quot;Top 15 Maximum number of Players from each Nation&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0MiIcgydTZJo0SS77VkrQ.png" /></figure><p>8. We can also write data into the S3 bucket using the put_object function, which creates the object named: Edav_cc.R in S3 bucket and stores the file “EDAV-cc.R” in it.<br> This command returns a TRUE if successful.</p><pre>&gt; put_object(&quot;EDAV-cc.R&quot;, object = &quot;Edav_cc.R&quot;, bucket = &quot;kiranmai-edav-cc&quot;)<br>[1] TRUE</pre><p>9. Now, we can run the get_bucket function to check if the file upload is successful or check manually via AWS UI.</p><pre>&gt; get_bucket(bucket = &quot;kiranmai-edav-cc&quot;)<br>Bucket: kiranmai-edav-cc</pre><pre>$Contents<br>Key:            123.pdf <br>LastModified:   2021-10-26T07:10:18.000Z <br>ETag:           &quot;eb61ee550c01da04c49e40b5876e6336&quot; <br>Size (B):       515385 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><pre><strong>$Contents<br>Key:            Edav_cc.R <br>LastModified:   2021-10-29T22:56:28.000Z <br>ETag:           &quot;a678b0d00d18ef8c69684cc12461c59f&quot; <br>Size (B):       9 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</strong></pre><pre>$Contents<br>Key:            data.csv <br>LastModified:   2021-10-26T06:48:45.000Z <br>ETag:           &quot;59357344b8ebf68e669c9a32d151c76f&quot; <br>Size (B):       9140113 <br>Owner:          999258db50847e5d20855687a5a487e77e34499d391e57102a399cfb297c399a <br>Storage class:  STANDARD</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PO2OU8pw09ima64IYK87Q.png" /><figcaption>R file added in AWS s3 bucket</figcaption></figure><p>An extension of this could be to read files from Amazon s3 to Amazon Textract and then process these files and tables in R, and then upload these tables into Amazon RDS.</p><p>The aws.s3 package offers numerous functions to allow access to data in S3 and R and work around it, which can be explored <a href="https://cran.r-project.org/web/packages/aws.s3/aws.s3.pdf">here</a>.</p><p>Thank you and happy reading!</p><p>Resources:<a href="https://cran.r-project.org/web/packages/aws.s3/aws.s3.pdf"> Official R package</a> , <a href="https://aws.amazon.com/blogs/opensource/getting-started-with-r-on-amazon-web-services/">AWS page</a>, <a href="https://aws.amazon.com/blogs/opensource/using-r-with-amazon-web-services-for-document-analysis/">Analyse document AWS</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cc73e17f563" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>