Skip to content
Prev 43675 / 398506 Next

Various newbie questions

r-help-bounces at stat.math.ethz.ch wrote on 04/02/2004 12:33:15:
a vector is a sequence of data of a certain kind ("of a certain mode").
You can have a vector of numbers
[1] "numeric"

or a vector of character strings
"CRAN")
[1] "character"

or vectors of other kinds (e.g. logical).

a data frame is what you would call 'une matrice de donn?es' in French.
In R a matrix can contain only one type of data (e.g. numerical data or
character strings) whilst a data.frame can contain different data types
in different columns (one per column, though).

These things are explained more clearly in "An Introduction to R",
that you can find on CRAN in the Manuals section.
mydata[i,j] will give you the element of the ith row and jth column
mydata[2,2] will give what you want.


[question on histogram]
R is a very flexible programming language, so you can do
a lot of what you can imagine and more.

If you have the two sets, there is no need to do this,
just concatenate these two sets and calculate the mean.
If you want to make your own function for doing this,
it could be done as follows:

myfun <- function(set1, set2){
  set1and2 <- c(set1, set2)
  overallmean <- mean(set1and2)
  return(overallmean)
}

Then use this new user-defined function with
two vectors of your own, say a and b
[1] 3.5

If you only have the data of the exercise in the
statistics textbook, you can use
the weighted.mean function of R:
[1] 25.36364

which is correct
[1] 25.36364
For this you could use the cut() function
Type ?cut at the R prompt and the help page
on this function will show up.
I know of IQR, but am not sure it is what you want.
Read its help page by typing ?IQR


I hope that this helps,

Tobias