Question

Question 2 If you read in a csv file using read.csv() function into R, what is the resulting datastructure in which R st...

Question 2

If you read in a csv file using read.csv() function into R, what is the resulting datastructure in which R stores the read-in data?
A. numeric

B. matrix   

C. data.frame   

D. vector

  
Question 3

Suppose you have 4 integers, 4 characters, and 4 logical values. Which datastructure can you use to store all 12 values? Choose one or more options.

A. a vector

B. a matrix

C. a list

D. a data frame

Question 4

Suppose you have a vector c(1:20). You make a matrix with it using the matrix() function, with the argument nrow=5. What will be the 4th column of this matrix?  

A. 16 17 18 19 20

B. 4 9 14 19  

C. 3 8 13 18

D. 11 12 13 14 15


Question 5

Suppose you survey students regarding their sexual orientation, and code the results as
1=Hetrosexual, 2=Homosexual, 3=Bisexual, 4=Asexual. Here is the data:
1 2 4 2 4 1 2 1 3 4 2 2 3 1 1 1 3 2 2 1 3 4 1 2 1 3 4 3 4 1 1 1 2 1 1 2 3 3 2

Assume you read in the data as an integer vector S. However, the numbers need to be treated as values of a categorical variable in further analysis. What should you do with S to facilitate this? Choose the most appropriate answer.
      

  A. Convert S to a data frame:
S = as.data.frame(S)

B. Convert S to a character vector

C. Convert S to a vector of factors   

D. Leave it as is, and do no calculations


Question 6

Suppose you survey students regarding their sexual orientation, and code the results as
1=Hetrosexual, 2=Homosexual, 3=Bisexual, 4=Asexual. Here is the data in a csv file, SexualOrientation.csv:

ID,SexualOrient
1,1
2,2
3,4
4,2
5,4
6,1
7,2
8,1
9,3
10,4
If I want to get a vector, v, of factors corresponding to sexual orientation, what would I do?
      

A. so<-read.csv("SexualOrientation.csv")

v<-c(as.factor(so$SexualOrient))

B. so<-read.csv("SexualOrientation.csv")

v=as.vector(as.factor(so$SexualOrient))   

C. so<-read.csv("SexualOrientation.csv")

v<-as.factor(so$SexualOrient)

D. so<-read.csv("SexualOrientation.csv")

v=as.vector(so$SexualOrient)


Question 7

You want to read in the data file T1.csv (on BlackBoard under “Course Documents→ Data” folder) into your R working directory. Which one of the following will read it in correctly? Missing data must be read in as NA, not the character used to represent the missing data in the file. (There may be multiple correct answers).
      

A. T1<- read.table("T1.csv", header=T, comment.char="#",na.strings="-" )   

B. T1=read.csv("T1.csv", comment.char="#",na.strings="-" )  

C. T1 <-read.table("T1.csv", sep=",", header=T, comment.char="#")

D. T1<-read.table("T1.csv", sep=",", header=T, comment.char="#",na.strings="-" )
  

Question 8

Suppose you have a vector, x=c("1") and another y=rbind(c(1,2,3),c(2,3,4)). If you call cbind with x and y as arguments, what will be the type of the resulting matrix? Think "coercion"   

A. matrix

B. columns vector

C. character

D. integer

  
Question 9

Suppose you have data from a survey. The responses consist of a person's sex("Male"/"Female"/"Other"), age (integer), and height(float). What datastructure will you use to hold the survey data?

A. A matrix   

B. A row of vectors

C. a data frame  

D. A matrix of characters and numeric data types.

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

Solution

Question 2

C. data frame

Question 3
C. a list

Question 4
B. 4 9 14 19

Question 5
C. Convert S to a vector of factors

Explanation

List is capable of storing n number of elements

so List is the right choice

---

all the best

Add a comment
Know the answer?
Add Answer to:
Question 2 If you read in a csv file using read.csv() function into R, what is the resulting datastructure in which R st...
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
  • Suppose you survey students regarding their sexual orientation, and code the results as 1=Hetrosexual, 2=Homosexual, 3=Bisexual,...

    Suppose you survey students regarding their sexual orientation, and code the results as 1=Hetrosexual, 2=Homosexual, 3=Bisexual, 4=Asexual. Here is the data: 1 2 4 2 4 1 2 1 3 4 2 2 3 1 1 1 3 2 2 1 3 4 1 2 1 3 4 3 4 1 1 1 2 1 1 2 3 3 2 Assume you read in the data as an integer vector S. However, the numbers need to be treated as values...

  • 1. What is the difference between heterosexism and homophobia? 2. Can homosexuals change their sexual orientation...

    1. What is the difference between heterosexism and homophobia? 2. Can homosexuals change their sexual orientation if they want to? And if 3. Why do researchers generally recommend using the term "sexual 4. Should discrimination based on sexual orientation be outlawed to the 5. If people believe in a literal interpretation of the Bible, is it prejudiced so, can heterosexuals do the same? orientation" rather than "sexual preference"? same extent as discrimination based on race and sex? for them to......

  • Choose 5 to answer 1) What is the difference between heterosexism and homophobla? 2) Can homosexuals...

    Choose 5 to answer 1) What is the difference between heterosexism and homophobla? 2) Can homosexuals change their sexual orientation if they want to? And if so, can heterosexuals do the same? And does it really matter? 3) Why do researchers generally recommend using the term "sexual orientation rather than "sexual preference"? 4) Should discrimination based on sexual orientation be outlawed to the same extent as discrimination based on race and sex? 5) If people believe in a literal interpretation...

  • According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses...

    According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...

  • Write an open_file() and a function that reads a csv data file and returns a dictionary...

    Write an open_file() and a function that reads a csv data file and returns a dictionary Microsoft Word - project09_final_RJE.docx 1/17 This project focuses on analyzing a publicly available dataset containing information about the spread of nCoV. Since this is an active situation, this dataset is constantly being updated with the latest figures. However, for our purposes, we will use a static version of the dataset provided to you with this project (ncov.csv). This static version was lasted updated on...

  • I am trying to create a function to read 2 csv files that contain 5 columns...

    I am trying to create a function to read 2 csv files that contain 5 columns of data. Columns 1-4 are floats and column 5 is a string. I want to only work on with the floats to perform some calculations such as sum of the first 2 columns of each file and then return the closest numbers then return the string to identify the 2 rows of data. Below is what I have so far. There is a stipulation...

  • Read the R help file for geom_histogram(). Fill in the blanks with the function of each...

    Read the R help file for geom_histogram(). Fill in the blanks with the function of each argument using the information under ‘usage’ and ‘arguments’ to better understand the different parts needed to run geom_histogram(). Options for A, B, C, D are: 1. Aesthetic mapping (which columns to use) 2. Data Frame 3. Name of Row 4.Number of bins 5. Units of Y-axis 6. Vector 7.Aesthetic Mapping (which rows to use) geom histogram(data - mtcars, aesx-mpg), bins 20, stat count"

  • You are required to open a file for input and read the data in that file...

    You are required to open a file for input and read the data in that file into an array (named data). Use the variable size to count how many elements in the file. Create the file yourself in notepad and call it data.txt so that it has the following numbers in order: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Please help with this. In C please

  • I only need the r code. the dataset we have is a .csv file. 3. (10...

    I only need the r code. the dataset we have is a .csv file. 3. (10 points) The data below are called ttable.csv on Bb. Read the data into R as a data frame "tmat" with names as shown. This data shows critical points for the Student t-distribution for degrees of freedom (by rows) 2, 3....10. Print the data frame to the screen as below. Then construct a graph as similar to the one shown below as you can Provide...

  • 1. Suppose you have created a vector x in R using the command x <-c(2, 7,...

    1. Suppose you have created a vector x in R using the command x <-c(2, 7, 3, 1, 9) . Please find the results for the following commands (2) xlc(1,3,5)] (3) x [2:4] (5) length(x) (6) x [2: length(x)1 (7) x[1: length(x)-1] (8) max(x) (9) min(x) 2. Besides the vector x in question 1, suppose you have created another vector y in R using the command y <- c(1, 2, 3, 4, 5). Please find the results for the following...

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