Skip to content
Prev 43682 / 398525 Next

Various newbie questions

Hi,
year <- 1970:1975
	snow.cover <- c(6.5,12,14.9,10,10.7,7.9)
	mydata <- data.frame(cbind(year,snow.cover))

	# retrieving 2nd column:
	mydata[,2]

	# retrieving 3rd row:
	mydata[3,]

	# snow.cover's second data-item:
	mydata[2,2]
	# or:
	mydata$snow.cover[2]
numbers <- c(35,42)
	arithmeans <- c(27,24)

	weighted.mean(arithmeans,numbers)


	Just a general remark: the first thing you should do (as is written
in the R-Posting-Guide) is consulting the available online help of R.
	For example, you could use
	?vector
	?data.frame
	to get an answer for your first question.
	If you don't know actually what you are looking for, you can also
enter a search string and, optionally, the package.
	In the case of question 3, you could have written:
	help.search("mean", package="base")
	and R would have returned several commands - among them also
"weighted.mean"

	Best,
	Roland



+++++
This mail has been sent through the MPI for Demographic Research.  Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked.   If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.