Question

--Rstudio-- The goal of the final question in this assignment is to read in the CSV...

--Rstudio--

  1. The goal of the final question in this assignment is to read in the CSV file SalesJan2009.csv. Then you will filter it into a dataframe for only rows that have United States in the Country column. Once you have that new dataframe, you will filter it again for only results that have a Payment_Type of Visa. That will give you your final dataframe. Now you will write that dataframe to a new CSV file called "VisaUS.csv".

I've attached the csv file:

https://docs.google.com/spreadsheets/d/1PIfnfve_VdW_4THbLh6vKEsTmstYu9EonNV6t8USGZ0/edit?usp=sharing

0 0
Add a comment Improve this question Transcribed image text
Answer #1

library(dplyr)
library(xlsx)
# make the directory having your data as your working directory

#dataframe=read.csv("SalesJan2009.csv",sep=";")
dataframe=read.xlsx("SalesJan2009.xlsx",1)
#this gives a general idea of our data
head(dataframe)

#first filter by rows where country is united states
dataframe1 = filter(dataframe, Country=="United States")

head(dataframe1)

#second filter by payment type
dataframe2 = filter(dataframe1,Payment_Type=="Visa")

#storing result in csv file
write.csv(file="VisaUS.csv",dataframe2)

Your file was not opening in csv file format so I have written the code for loading csv file in comment at line number 5

you can see in the image and I had used the xlsx file for storing the data content in a dataframe

The screenshot of VisaUS.csv file is also attached here for your better understanding

Add a comment
Know the answer?
Add Answer to:
--Rstudio-- The goal of the final question in this assignment is to read in the CSV...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • --------__--------__Python--------__--------__ You will be reading in the data from the file SalesJan2009.csv. When you do, you...

    --------__--------__Python--------__--------__ You will be reading in the data from the file SalesJan2009.csv. When you do, you need to save all the items from the PRICE field into a list called amtCollected. After you get them all in that list, you will need to create a variable called total that holds the sum of all the numbers in the list. Then create a variable called avg that holds the average of the numbers in the list. Now, print the following strings:...

  • I need help Structuring data into certain dictionaries in Python to help answer a few questions....

    I need help Structuring data into certain dictionaries in Python to help answer a few questions. I have a CSV file and i need help looping thru the data to get an output similar to this. where the keys are the region (for data_by_region) or country (for data_by_country) and the values are dictionaries where the years are the keys. Based on this information i need a few dictionaries one being called data_by_region and another called data_by_country. Her is a link...

  • question 2, and 3 please. I want the code command on Rstudio it is Rstudio Question...

    question 2, and 3 please. I want the code command on Rstudio it is Rstudio Question 2 1. Define the following function in R: 810) = { Answer 1 2. Plot f(x) for all integers between 10 and 10. # Answer 2 Question 3 1. Extract all the info related to call option contracts written on Facebook (FB), expiring on 01/17/2020, from Yahoo Finance. In order to do this, you need to go to Yahool Finance, search for Facebook click...

  • A random sample of 303 individuals collected the following information: sex, marital status, age,...

    A random sample of 303 individuals collected the following information: sex, marital status, age, country, size, and type. The variables marital status and type (which refers to type of automobile—either family, sporty, or work) are of interest to us. We would like to know if there is a relationship between the two qualitative variables marital status and type. We will test our hypothesis at the α = 0.01 level of significance. The data is in the Excel file Car Poll.xlsx....

  • Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data...

    Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...

  • Hello! I have this python Homework due tonight that I don't know how to do. Here...

    Hello! I have this python Homework due tonight that I don't know how to do. Here is a document with the data in the csv file, as I didn't know how to share it https://docs.google.com/document/d/1bDJVR2MqWKInvw5u0r3fOG3-CBmu3BEiPZwlaq_CShQ/edit?usp=sharing Activity #3: On the class website is a CSV file containing weather data from Coulter Field (in Bryan) for 3 years (1 day is missing for some reason!); the data was taken from Weather Underground (wunderground.com). There are different versions of the file for Windows...

  • Need help with the code for this assignment. Python Assignment: List and Tuples We will do...

    Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...

  • Using Rstudio please provide your code as well as a screenshot of your code ## File:...

    Using Rstudio please provide your code as well as a screenshot of your code ## File: lab5 ## Author: A. Breitzman ## Description: Manipulating and summarizing a data set ## ------------------------------------------------------------------------ ## Instructions: This worksheet is worth 5 points ## Exercises are worth 2.5 point each. If you cannot get the code to work in the line limits specified, the maximum that you can earn per exercise would be 1.5 points. ## First we need to load a library library(MASS)...

  • Python coding exercise: please include comments Goal #1: import financial data given into your pr...

    Python coding exercise: please include comments Goal #1: import financial data given into your program provided to you as a CSV formatted text file Use the following data for testing (the following is only a sample of the data; there are over 4000 rows of data): *Note: The data you will read in is linear by date (but, non-contiguous due to holidays and weekends,) reflecting a timeline of stock performance in chronological order; however your program should run through the...

  • mixed unknown. the goal of this assignment is to identity each organism. so this attachement or...

    mixed unknown. the goal of this assignment is to identity each organism. so this attachement or picture has both organism seperated by gram stanin and result of each on macConkeys Agar and Columbia CNA. so in order to identify the genus and specise both organsims, i have to order 2 additional test per. MY questions to you is what kinds of test do have to requesd or do in oder to identity  the organism ? N (No Title) Gram + Gram...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT