MATH 2565 W 2007 Section M QandA

From MathWiki

Questions and Answers:

Table of contents


I tried to get a sample of 30 players from the base.pop data frame, but I can't.
I can get a sample of 30 from the numbers 1 to 322:
sample( 1: 322, 30)
 [1] 177  36  28  81 115 278 196 289 297 231 308 222 320  57  16 127  63  31 180
[20] 101 156 137 254  96  97 218 250  91 291 248

But how do I use these sample indices to select from the base.pop data frame.
You need to select rows of 'base.pop' using the row indices generated by 'sample()', i.e.
 base.sample <- base.pop[ sample( 1:322, 30 ), ]

Quiz 1?

> ... I was not able to attend the last class, 
> and I have a couple of question for the upcoming quiz (january 17):
> 1. What material is the quiz based on: the R, or the text book, both?
> 2. Are we writing the quiz on paper or on the computer?
The quiz is based on the material in Chapter 1 of the text and in Chapters 1 and 2 of the hand out. I hinted that I might include a question similar to the question on smoking that is mentioned on the web. There might also be a question on R, perhaps a question on basic sampling.
The quiz might include a combination of replies on paper and replies on the computer with results e-mailed to me. This will vary from quiz to quiz depending on the questions.

Georges Monette 05:53, 16 Jan 2007 (EST)

Guidelines for wiki assignments

1. When you write a solution in a wiki page include the question. Otherwise the solution is not so useful to other students who later visit the page. They would need to have the textbook with them to make sense of the solution.
2. Be sure to add links to your solution in both and in your team page, e.g.
3. When creating solution pages, be sure to use names that will end up being unique. e.g. Math2565M_Solutions_1.16, etc.
4 Have fun.

Georges Monette 10:58, 16 Jan 2007 (EST)

Using a .csv file from the internet

I was wondering how to take an excel document similar to and download to R in order to make charts and histograms.
If the ".csv" spreadsheet happens to be in the right format (variable names on the first row, data from the second row down), all you need to use is the 'read.csv' function that can read a '.csv' file directly from the internet, as follows:
  dd <- read.csv("")
  ... etc.
If the file needs editing before it can be used to create an R data frame, then you could download it first:
  download.file("", "/local.csv")
Then you open 'local.csv' with Excel in your root directory, edit it, save it as a '.csv' file, and then read it into R:
  dd <- read.csv("/local.csv")
  ... etc.

How do I upload a graph to wiki

See R: Q and A#Uploading plots to a wiki page

How do I upload a .csv file to the wiki so others can use it

See R:_Q_and_A#Uploading_a_.csv_data_frame_and_reading_it_in_R