Pages

Wednesday, July 31, 2013

Basics of R 1

1.What should you type in the R console to install the "car" package?
install.packages("car")

2.Once you have this package installed, what should you type in the R console to load the ”car” package?
library(car)

3.What should you type in the R console to check what packages you have installed and loaded on your computer?  search()

4.What should you type to get help about the “data.frame” function? 
?data.frame

5.Create two vectors, the first one named "numbers" including all natural numbers from 1 to 10, and the second one named "words" containing the following series:"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten". From these two vectors, create a dataframe "nw" with each vector as a separate column. What should you type to check the attributes of "nw"?
attributes(nw)

6.What command should you type to get R to return the number “8” from the dataframe "nw"?
nw[8,1]
7.What command should you type to get R to return the word “eight” from the dataframe "nw"?
nw[8,2]

8.What should you type to create a matrix “a” comprising all natural numbers from 1 to 10, with 2 rows and 5 columns.
a=matrix(1:10,2,5)

9.Create a vector "x" comprising all natural numbers from 1 to 6 and another vector "y" comprising all natural numbers from 5 to 10. What should you type to combine them in a matrix of 2 rows and 6 columns?
rbind(x,y)

10.Create a vector "x" comprising all natural numbers from 1 to 6 and another vector "y" comprising all natural numbers from 5 to 10. What should you type to combine them in a matrix of 6 rows and 2 columns?
cbind(x,y)



6 comments:

  1. Awesome Dude We are grateful to you for your help

    ReplyDelete
  2. My Friend, You have great skills and big heart. It helped me in completing one imp assignment. Continue this great help!!!!!!!!!

    ReplyDelete
  3. Thanks for your generous help! You are such a great classmate :)
    Hope you have a great day!

    ReplyDelete
  4. Waiting for Statistics One Assignment 5.......

    ReplyDelete
  5. My package(car) is not function. When i call > library(car) return this error

    Error in FUN("logit"[[1L]], ...) : lazy-load database 'P' is corrupt
    In addition: Warning messages:
    1: In FUN("logit"[[1L]], ...) : restarting interrupted promise evaluation
    2: In FUN("logit"[[1L]], ...) : internal error -3 in R_decompress1

    Someone can explain that?
    thanks

    ReplyDelete