# [R] Various newbie questions

Felix Eschenburg Atropin75 at t-online.de
Wed Feb 4 15:05:23 CET 2004

```Am Mittwoch, 4. Februar 2004 12:33 schrieb Philippe de Rochambeau:
> Hello,
>
> 1) What is the difference between a "data frame" (J H Maindonald, Using
> R, p. 12) and a "vector"?

a vector looks like this: 1 2 3 4 5 ...
a data.frame has two dimensions, the rows and the coloumns

>
> In Using R, the author asks the reader to enter the following data in a
> data frame, which I will call "mydata":
>
> year snow.cover
> 1970 6.5
> 1971 12.0
> 1972 14.9
> 1973 10.0
> 1974 10.7
> 1975 7.9
> ...
>
> mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))
>
> 2) How to you retrieve say, snow.cover's second data item? mydata
> does not work, neither does mydata[1,2].
mydata[2,1] should do the trick: to get a specific cell out of a data.frame
you use this: name.of.frame[row,coloumn]
try help(apply), this should make the logic behind that a little more clearer

> hist(mydata[1,2]) does not work. How would you create a histogram with
> the above data?
a histogram gives, as far as i kinow, the frequency of the values of one
variable, so you might try hist(mydata\$snow) to get the histogram for snow

>
> In a French statistics book, the author provides the following data:
>
> Group A	Number: 35	Mean:27
> Group B  Number: 42  Mean:24
>
> and asks: "what is the mean of the group constituted by the reunion of
> the two groups?"
>
> The answer is of course (27 x 35) + (24 x 42) / 77
>
> 3) Is there a way to compute this mean in R (apart from doing the above
> operation, of course) if you have two sets of data?

lets say you have two vectory called A and B with your given options, you
would get their mean by
mean(c(A,B))

> 4) How do you set class limits in R, for instance
>
> 10-20
> 21-31
> etc.
try help(cut)

> 5) How do you determine quartiles in R? Is there a way to determine the
> "semi-inter-quartile deviation" ("écart semi-inter-quartile" in
> French)?
this question i did not understand

for getting a start in R i recommend "R for Beginners" by Emmanuel Paradis,
which can be found after following the link "contributed" on
www.r-project.org

Felix Eschenburg

```