Question

Question #1: (25 points) For this question, you will need to create several variables for use in later questions in this exam please use language R
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

 n    <- 2001
> lhs1 <- paste("cocaine", 1:n, sep="")
> lhs2 <- paste("drinkalc", 1:n, sep="")
> lhs3 <- paste("marijuna", 1:n, sep="")
> lhs4 <- paste("smoke", 1:n ,sep="")
> out<-paste("subuse",1:n,sep="")
> rhs <-paste(lhs1,lhs2,lhs3,lhs4,sep="+")
> output<-paste(paste(out,rhs,sep="<-"),collapse=";")

2.

peers_cutclass<-""
> peers_drunk<-""
> peers_drugs<-""
> peers_gang<-""
> bad_peers<-peers_cutclass+peers_drunk+peers_drufd+peers_gang
> output<-paste(peers_cutclass,peers_drugs,peers_drunk,peers_gang, sep="+")
> peers_church<-""
> peers_college<-""
> peers_sports<-""
> peers_vounteer<-""
> good_peers<-peers_church+peers_college+peers_sports+peers_vounteer

3.

 age97 = rnorm(100, mean=0, sd=1)
 arr97 = rnorm(100, mean=0, sd=1)
 crime97 = rnorm(100, mean=0, sd=1)
 varscore97 = rnorm(100, mean=0, sd=1)
newage97_squared<-age97^2
newarr97_squared<-arr97^2
newcrime97_squared<-crime97^2
newvarscore97_squared<-varscore97^2

>

4.
arr1 = rnorm(100,mean=0,sd=1)
> crime01 = rnorm(100,mean=0,sd=1)
> grhhinc97 = rnorm(100,mean=0,sd=1)
> varscore01 = rnorm(100,mean=0,sd=1)
> arr1_logged<-log2(arr1)
Add a comment
Know the answer?
Add Answer to:
please use language R Question #1: (25 points) For this question, you will need to create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a...

    use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 Before the loop set sumx = 0 Then add each term to sumx inside the loop. (You do not need to store the individual values of the sequence; it is sufficient to add each term to the sum.) After the loop, display sumx with either disp()...

  • C++ Please help. 1) Create an array to store 10 Point2D points (the Point2D class from...

    C++ Please help. 1) Create an array to store 10 Point2D points (the Point2D class from A6). Set the coordinates from 0,0 to 9,9. Move all the points left 5 units and up 10 units. Print their new location. 2) Make a new class Point3D which inherits from the Point2D class. The class has one more data member for the z coordinate. There are two constructors, a default one and one with 3 coordinates. Add the new member functions getZ,...

  • please do it in C# language Q. 1 part 1 Create an array named weekly Temp...

    please do it in C# language Q. 1 part 1 Create an array named weekly Temp that will hold values of weekly temperatures in Fahrenheit from Monday through Sunday. Calculate the average temperature for that week and display its average. part 2 Write while loop to display the numbers from 10 through 1 and the squares. The output should display as following: squared 100 81 04 part 3 Define a method that calculates calculateareaOfCircle by passing a value of radius...

  • Create the printout necessary for conducting a SLR analysis of your project data. Use y=price as...

    Create the printout necessary for conducting a SLR analysis of your project data. Use y=price as your dependent variable and x=mileage/size as your independent variable. Copy and paste the printout here: Least Squares Linear Regression of Asking Predictor Variables               Coefficient            Std Error                    T              P Constant                 22790.9               1314.55                17.34     0.0000 Mileage              -0.09109               0.03153                -2.89       0.0051 R²                              0.1026               Mean Square Error (MSE) 1.102E+07 Adjusted R²              0.0903               Standard Deviation             3319.84 AICc                        1220.5 PRESS                   8.47E+08...

  • Create the program in C++ please. The new operator as outlined in 10.9 . Create a...

    Create the program in C++ please. The new operator as outlined in 10.9 . Create a Test class that includes the following Data members • First Name, last name, test1, test2, test3 o Methods • Accessor methods for each of the data members' • Mutator methods for each of the data members . A Default Constructor . A constructor that will accept arguments for each of the 5 data members • A method that will calculate the average of the...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

  • Need help with following assignment written in Java. For this assignment, you’re going to create...

    Need help with following assignment written in Java. For this assignment, you’re going to create a new class named “Fraction” for managing rational numbers (fractions). (You should not submit a main program with the Fraction class; however, you'll definitely want to write one for your own testing purposes.) Details are as follows: CLASS DEFINITION CONSTRUCTORS: Fraction(int num,int denom) num/denom creates a new number whose value is Fraction(int num) METHODS (assume x is a Fraction): creates a new number whose value...

  • C language. A file, display.c handles all display to the LED array. It will need a...

    C language. A file, display.c handles all display to the LED array. It will need a global variable with type *pi_framebuffer_t. (in C, "global" variables are scoped only to the file in which they are defined unless other actions are taken). Should have at least the following functions: void openDisplay(void): allocate the Pi Framebuffer device and store in a "global" variable for later use. This function should only need to be called one time when the program runs. void closeDisplay(void):...

  • PLEASE ONLY ANSWER IF YOU ARE SURE! THE QUESTION DO NOT NEED DATA TO ANSWER THE...

    PLEASE ONLY ANSWER IF YOU ARE SURE! THE QUESTION DO NOT NEED DATA TO ANSWER THE FOLLOWING QUESTION. THANKS! 1. Using only the QQplot, would you consider the variable Pr to be normally distributed? A. Yes B. No 2. Based only on the QQ plot, would you consider the variable Caf normally distributed? A. Yes B. No 3. Create a contingency table using the variables Smk and Aer. How many people smoke and do aerobics? 4. If an observation can...

  • You need to write scripts for all problems. Each script should contain the comments on each...

    You need to write scripts for all problems. Each script should contain the comments on each line. You also need to publish your scripts to pdf files. 1. (Chapter.1) Store a number with a decimal place in a double variable (the default). Convert the variable to type int32 and store the result in a new variable. (10pts) 2. (Chapter.1) Create a variable ftemp to store a temperature in degrees Fahrenheit F). Convert this to degrees Celsius C) and store the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT