Blog

Coursehelp
April 16, 2019
QUESTION : No Comments

(Solved) : Work Gapminder Data Use Functions Dplyr Homework Gapmider Dataset Tbldf Data Structure Coe Q26356403 . . .

We will work with the gapminder data and will use functions from dplyr for this homework. The gapmider dataset is a tbl_df data structure, which we will coerce to a data.frame library (gapminder); library (dplyr) gapminder <- as.data.frame(gapminder) 1.(1 mark) Write a code chunk that uses the basic, or s operators to extract all data from Canada and the United States and saves them as a new dataset called canUS1 . Answer 2. (B marks) Repeat the subsetting in (1) with the filter) function from dplyr to create a dataset CanUS2. Verify column- by-column that all elements of Canusi and Canus2 equal using the all.equal) function and a for loop over colum ns What difference does all.equal (CanUs1,CanUs2) report? Answer 3. (2 marks) Extract the colum ns year , lifeExp, pop and gdpPercap from the original gapminder dataset and save as gm2 (1 mark). Also coerce gm2 to a matrix and save as gm3 (1 mark). Answer

We will work with the gapminder data and will use functions from dplyr for this homework. The gapmider dataset is a tbl_df data structure, which we will coerce to a data.frame library (gapminder); library (dplyr) gapminder Show transcribed image text

Expert Answer


. . .

OR
OR

Have a Comment on this Question?

Questions viewed by other students


  • QUESTION : (Solved) : Code Review Review Code Metalplatetempcpp Attached Program Listing Information Required Un Q30758632 . . .

    Code Review:

    Review the code (Metal_Plate_Temp.cpp) in the attached programlisting. As it should be, all the information required tounderstand this program is included in the code comments. Below isa screen-shot for the program’s expected output.

    Problems Tasks ConsoleProperties <terminated Miscexe C/C++ Application] C1Users ghzitelGHZ-Docs ClassesCPET-321 CPS ITNEclipse WorkSpacelMisctDebug 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 100.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.0 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 3 20.00 50.00 50.0 50.00 50.00 50.0 50.00 50.00 50.00 20.00 2 20.00 50.00 50.00 50.00 50.0 50.0 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 9 20.00 20.0 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 34.13 48.25 38.89 31.06 26.38 23.67 22.02 20.90 20.00 20.00 48.25 100.00 56.23 38.98 30.77 26.28 23.51 21.59 20.00 20.00 38.89 56.23 47.04 37.84 31.43 27.14 24.16 21.92 20.00 20.00 31.06 38.98 37.84 33.89 29.93 26.66 24.06 21.92 20.00 20.00 26.38 30.77 31.43 29.93 27.72 25.49 23.48 21.68 20.00 20.00 23.67 26.28 27.14 26.66 25.49 24.09 22.67 21.31 20.00 20.00 22.02 23.51 24.16 24.06 23.48 22.67 21.78 20.89 20.00 20.00 20.90 21.59 21.92 21.92 21.68 21.31 20.89 20.44 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 The Steady-State Temperature for Segment (4,4) is 29.93

    Project Requirements:

    Your objective for this coding problem is to implement the codefor main() along with the user defined function in plate.cpp &plate.cpp.

    You must submit the FULLY DOCUMENTED source code for the threesource files (Metal_Plate_Temp.cpp, plate.cpp & plate.h).

    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Name : Metal_Plate_Temp.cpp
    // Author : Dr. George H. Zion
    // Course : Computation Problem Solving II (CPET-321)
    // Date : Fall 2018 (2181)
    // Description :
    //
    // Under steady-state conditions, the temperature at any point onthe
    // surface of a metal plate will be the average of the temperaturesof
    // all the points surrounding it. This fact can be used in aniterative
    // procedure to calculate the temperature distribution at allpoints on a
    // plane.
    //
    // Figure #1 shows a square plate divided into 100 squares or nodesby a
    // grid. The temperature of the nodes form two-dimensionalarray.
    //
    // 9 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 8 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 7 [ ][ ][X][ ][ ][ ][ ][ ][ ][ ]
    // 6 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 5 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 4 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 3 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 2 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 1 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 0 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 0 1 2 3 4 5 6 7 8 9
    //
    // Figure #1
    //
    // The temperature at all nodes at the edges of the plate areconstrained
    // to 20 degrees Celsius by a cooling system, and the temperatureat the
    // node (2,7) is fixed at 100 degrees Celsius by exposure toboiling water.
    //
    // A new estimate of the temperature T(R,C) at any node can becalculated
    // from the average of the temperatures of all nodes surrounding itusing
    // the formula in Equation #1.
    //
    // T(R,C)new = 1/4 ([ T(R+1, C) + T(R-1), C) + T(R, C+1) + T(R,C-1)]
    //
    // Equation #1
    //
    // To determine the temperature distribution on the surface of aplate,
    // initial assumptions must be made about the temperature at eachnode,
    // then equation #1 is applied to calculate the new temperature atthe
    // node. These updated temperatures are, in turn, used to calculatenew
    // temperature. This process is repeated until all new temperaturesat
    // each node reach a steady-state.
    //
    // This program calculates the steady-state temperaturedistribution
    // throughout the plate, making an initial assumption that allinterior
    // segments are at a temperature of 50 degrees Celsius (Rememberthat
    // all outside segments are fixed at 20 degrees Celsius and thenode (2,7)
    // is fixed at 100 degrees Celsius).
    //
    // The program follows the following algorithm/pseudo-code:
    //
    // 1) Display the temperatures of the plane (initialconditions).
    // 2) Display an ‘*’ on the screen.
    // 3) Perform one interation of new temperature calculations
    // for the plate.
    // 4) If the change in any node temperature was greater-than0.01
    // degrees Celsius, return to step 2.
    // 5) Display the temperatures of the plane (steady-stateconditions)
    // 6) Display the temperature at node (4,4).
    //
    // The program utilizes a user-defined library (plate.h &plate.cpp) that
    // contains the following user-defined functions:
    //
    // displayPlate() : Purpose.: Displays the current temperatureof
    // the plate in a grid format.
    // Input…: None
    // Output..: None
    //
    // distributeHeat() : Purpose.: Performs one iteration of new
    // temperature calculations for the
    // plate.
    // Input…: None
    // Output..: Returns a boolean value. Returns
    // true if the temperature change in
    // all the nodes is less-than 0.01
    // degrees. Otherwise, returns false.
    //
    // plateValue() : Purpose.: Determine the current temperature
    // of one node of the plate given the
    // node’s coordinates.
    // Input…: The coordinates (column, row) of a
    // node.
    // Output..: Returns the temperature (double) of
    // the node.
    //

    The program must have three files (Metal_Plate_Temp.cpp,plate.cpp & plate.h) and using three functions listed above. Itcan include more than 3 functions listed above.

    Metal_Plate_Temp will be utilizing user-defined libraryplate.cpp and plate.h files. Plate.h will include the headerinformation that is needed for the program, while plate.cpp willinclude the three functions listed above. And it must be in C++language.

    Problems Tasks ConsoleProperties Show transcribed image text

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Review Review Code Metalplatetempcpp Attached Program Listing Information Required Un Q30758635 . . .

    Code Review:

    Review the code (Metal_Plate_Temp.cpp) in the attached programlisting. As it should be, all the information required tounderstand this program is included in the code comments. Below isa screen-shot for the program’s expected output.

    Problems Tasks ConsoleProperties <terminated Miscexe C/C++ Application] C1Users ghzitelGHZ-Docs ClassesCPET-321 CPS ITNEclipse WorkSpacelMisctDebug 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 100.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.0 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 3 20.00 50.00 50.0 50.00 50.00 50.0 50.00 50.00 50.00 20.00 2 20.00 50.00 50.00 50.00 50.0 50.0 50.00 50.00 50.00 20.00 20.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 50.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 9 20.00 20.0 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 34.13 48.25 38.89 31.06 26.38 23.67 22.02 20.90 20.00 20.00 48.25 100.00 56.23 38.98 30.77 26.28 23.51 21.59 20.00 20.00 38.89 56.23 47.04 37.84 31.43 27.14 24.16 21.92 20.00 20.00 31.06 38.98 37.84 33.89 29.93 26.66 24.06 21.92 20.00 20.00 26.38 30.77 31.43 29.93 27.72 25.49 23.48 21.68 20.00 20.00 23.67 26.28 27.14 26.66 25.49 24.09 22.67 21.31 20.00 20.00 22.02 23.51 24.16 24.06 23.48 22.67 21.78 20.89 20.00 20.00 20.90 21.59 21.92 21.92 21.68 21.31 20.89 20.44 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 20.00 The Steady-State Temperature for Segment (4,4) is 29.93

    Project Requirements:

    Your objective for this coding problem is to implement the codefor main() along with the user defined function in plate.cpp &plate.cpp.

    You must submit the FULLY DOCUMENTED source code for the threesource files (Metal_Plate_Temp.cpp, plate.cpp & plate.h).

    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Name : Metal_Plate_Temp.cpp
    // Author : Dr. George H. Zion
    // Course : Computation Problem Solving II (CPET-321)
    // Date : Fall 2018 (2181)
    // Description :
    //
    // Under steady-state conditions, the temperature at any point onthe
    // surface of a metal plate will be the average of the temperaturesof
    // all the points surrounding it. This fact can be used in aniterative
    // procedure to calculate the temperature distribution at allpoints on a
    // plane.
    //
    // Figure #1 shows a square plate divided into 100 squares or nodesby a
    // grid. The temperature of the nodes form two-dimensionalarray.
    //
    // 9 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 8 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 7 [ ][ ][X][ ][ ][ ][ ][ ][ ][ ]
    // 6 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 5 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 4 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 3 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 2 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 1 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 0 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
    // 0 1 2 3 4 5 6 7 8 9
    //
    // Figure #1
    //
    // The temperature at all nodes at the edges of the plate areconstrained
    // to 20 degrees Celsius by a cooling system, and the temperatureat the
    // node (2,7) is fixed at 100 degrees Celsius by exposure toboiling water.
    //
    // A new estimate of the temperature T(R,C) at any node can becalculated
    // from the average of the temperatures of all nodes surrounding itusing
    // the formula in Equation #1.
    //
    // T(R,C)new = 1/4 ([ T(R+1, C) + T(R-1), C) + T(R, C+1) + T(R,C-1)]
    //
    // Equation #1
    //
    // To determine the temperature distribution on the surface of aplate,
    // initial assumptions must be made about the temperature at eachnode,
    // then equation #1 is applied to calculate the new temperature atthe
    // node. These updated temperatures are, in turn, used to calculatenew
    // temperature. This process is repeated until all new temperaturesat
    // each node reach a steady-state.
    //
    // This program calculates the steady-state temperaturedistribution
    // throughout the plate, making an initial assumption that allinterior
    // segments are at a temperature of 50 degrees Celsius (Rememberthat
    // all outside segments are fixed at 20 degrees Celsius and thenode (2,7)
    // is fixed at 100 degrees Celsius).
    //
    // The program follows the following algorithm/pseudo-code:
    //
    // 1) Display the temperatures of the plane (initialconditions).
    // 2) Display an ‘*’ on the screen.
    // 3) Perform one interation of new temperature calculations
    // for the plate.
    // 4) If the change in any node temperature was greater-than0.01
    // degrees Celsius, return to step 2.
    // 5) Display the temperatures of the plane (steady-stateconditions)
    // 6) Display the temperature at node (4,4).
    //
    // The program utilizes a user-defined library (plate.h &plate.cpp) that
    // contains the following user-defined functions:
    //
    // displayPlate() : Purpose.: Displays the current temperatureof
    // the plate in a grid format.
    // Input…: None
    // Output..: None
    //
    // distributeHeat() : Purpose.: Performs one iteration of new
    // temperature calculations for the
    // plate.
    // Input…: None
    // Output..: Returns a boolean value. Returns
    // true if the temperature change in
    // all the nodes is less-than 0.01
    // degrees. Otherwise, returns false.
    //
    // plateValue() : Purpose.: Determine the current temperature
    // of one node of the plate given the
    // node’s coordinates.
    // Input…: The coordinates (column, row) of a
    // node.
    // Output..: Returns the temperature (double) of
    // the node.
    //

    The program must have three files (Metal_Plate_Temp.cpp,plate.cpp & plate.h) and using three functions listed above. Itcan include more than 3 functions listed above.

    Metal_Plate_Temp will be utilizing user-defined libraryplate.cpp and plate.h files. Plate.h will include the headerinformation that is needed for the program, while plate.cpp willinclude the three functions listed above. And it must be in C++language.

    Problems Tasks ConsoleProperties Show transcribed image text Problems Tasks ConsoleProperties

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Runs Ping Ping Reply Ttl Flooding Need Implement Neighbor Discovery Unsure Begin Incl Q31130351 . . .

    This code runs ping, ping reply, TTL, and Flooding, i now needto implement Neighbor Discovery but am unsure how to begin.

    #include

    #include “includes/command.h”

    #include “includes/packet.h”

    #include “includes/CommandMsg.h”

    #include “includes/sendInfo.h”

    #include “includes/channels.h”

    module Node{

    uses interface Boot;

    uses interface SplitControl as AMControl;

    uses interface Receive;

    uses interface SimpleSend as Sender;

    uses interface CommandHandler;

    uses interface List as PackageList;

    uses interface List as NeighborList;

    }

    implementation{

    uint16_t sequenceCounter = 0;

    pack sendPackage;

    // Prototypes

    void makePack(pack *Package, uint16_t src, uint16_t dest,uint16_t TTL, uint16_t Protocol, uint16_t seq, uint8_t *payload,uint8_t length);

    bool compPack(pack *Package);

    void shovePack(pack Package);

    event void Boot.booted(){

    call AMControl.start();

    dbg(GENERAL_CHANNEL, “Bootedn”);

    }

    event void AMControl.startDone(error_t err){

    if(err == SUCCESS){

    dbg(GENERAL_CHANNEL, “Radio Onn”);

    }else{

    //Retry until successful

    call AMControl.start();

    }

    }

    event void AMControl.stopDone(error_t err){}

    event message_t* Receive.receive(message_t* msg, void* payload,uint8_t len){

    dbg(GENERAL_CHANNEL, “Packet Receivedn”);

    if(len==sizeof(pack)){

    pack* myMsg=(pack*) payload;

    //dbg(GENERAL_CHANNEL, “Im inn”);

            if(compPack(myMsg) || (myMsg->TTL == 0)){

                

                //DROP DA PACKAGE

            }elseif(myMsg->protocol == 0 && myMsg->dest ==TOS_NODE_ID){ // PING

                dbg(GENERAL_CHANNEL,”WOOHOO From %d! to %d!n”, myMsg->src, myMsg->dest);

                dbg(GENERAL_CHANNEL,”Package at destination. Payload: %sn”, myMsg->payload);

                makePack(&sendPackage,TOS_NODE_ID, myMsg->src, MAX_TTL, PROTOCOL_PINGREPLY,sequenceCounter, (uint8_t*)myMsg->payload,sizeof(myMsg->payload));

                sequenceCounter++;

                shovePack(sendPackage);

                callSender.send(sendPackage, AM_BROADCAST_ADDR);

             }elseif(myMsg->protocol == 1 && myMsg->dest ==TOS_NODE_ID){ // PING REPLY

                dbg(GENERAL_CHANNEL,”Recieved ping reply from Node: %d!n”, myMsg->src);

             }else{

                makePack(&sendPackage,myMsg->src, myMsg->dest, myMsg->TTL-1, myMsg->protocol,myMsg->seq, (uint8_t*)myMsg->payload,sizeof(myMsg->payload));

                dbg(GENERAL_CHANNEL,”Received package from %d going to %d, TTL: %d, Rebroad…n”,myMsg->src, myMsg->dest, myMsg->TTL);

            shovePack(sendPackage);

                callSender.send(sendPackage, AM_BROADCAST_ADDR);

             }

    return msg;

    }

    dbg(GENERAL_CHANNEL, “Unknown Packet Type %dn”, len);

    return msg;

    }

    event void CommandHandler.ping(uint16_t destination, uint8_t*payload){

    dbg(GENERAL_CHANNEL, “PING EVENT!!! n”);

    makePack(&sendPackage, TOS_NODE_ID, destination, MAX_TTL, 0,0, payload, PACKET_MAX_PAYLOAD_SIZE);

    call Sender.send(sendPackage, AM_BROADCAST_ADDR);

    }

    event void CommandHandler.printNeighbors(){}

    bool compPack(pack *Pack){

            uint16_t j =0;

            uint16_t size =call PackageList.size();

            pack finder; //temp package to compare to package list for similarities

            for(j = 0; j< size; j++){

                finder= call PackageList.get(j); //iterate through list and compare

                if(finder.src== Pack->src && finder.seq == Pack->seq &&finder.dest == Pack->dest){

                return TRUE; // found same package at a node

                }

            }

            return FALSE; //did not find package doppleganger

        }

    void makePack(pack *Package, uint16_t src, uint16_t dest,uint16_t TTL, uint16_t protocol, uint16_t seq, uint8_t* payload,uint8_t length){

    Package->src = src;

    Package->dest = dest;

    Package->TTL = TTL;

    Package->seq = seq;

    Package->protocol = protocol;

    memcpy(Package->payload, payload, length);

    }

    void shovePack(pack Package) {

            if (callPackageList.isFull()) {

                callPackageList.popfront();

            }

            callPackageList.pushback(Package);

        }

    }

    Expert Answer


    . . .


    view full answer
  • QUESTION : (Solved) : Code Running Matlab Clear Clc T Input Enter Car Type Seadan Suv S Switch T M Input Enter M Q35161771 . . .

    why my code is not running on MATLAB?

    clear;clc

    T= input( ‘Enter the car Type(Seadan or SUV):’,’s’);switch(T)

    M= input( ‘ Enter milles: ‘);

    D=input( ‘Enter numeber of days: ‘);

         case ‘Sedan’    

         if D<=6

             ifM<=D*80

                Price=79*D;

             else

                price=79*D+((M-D*80)*0.69)

             end

         elseif D<=29

             ifM<D*100

                price=69*D;

             else

                price =69*D+(M-D*100)*0.59;

             end

         else

             ifM<=D*120

                price=59*D;

             else

                price=59*D+(M-D*120)*0.49;

             end

         end

    case ‘SUV’

        

         if D<=6

             ifM<=D*80

                Price=84*D;

             else

                price=84*D+((M-D*80)*0.74)

             end

         elseif D<=29

             ifM<D*100

                price=74*D;

             else

                price =74*D+(M-D*100)*0.64;

             end

         else

             ifM<=D*120

                price=64*D;

             else

                price=64*D+(M-D*120)*0.54;

             end

         end

        

         fprintf( ‘The price for the rent is%0.2 f$/n’,price);

    end

    clear;clc

    T= input( ‘Enter the car Type(Seadan or SUV):’,’s’);switch(T)

    M= input( ‘ Enter milles: ‘);

    D=input( ‘Enter numeber of days: ‘);

         case ‘Sedan’

        

         if D<=6

             ifM<=D*80

                Price=79*D;

             else

                price=79*D+((M-D*80)*0.69)

             end

         elseif D<=29

             ifM<D*100

                price=69*D;

             else

                price =69*D+(M-D*100)*0.59;

             end

         else

             ifM<=D*120

                price=59*D;

             else

                price=59*D+(M-D*120)*0.49;

             end

         end

    case ‘SUV’

        

         if D<=6

             ifM<=D*80

                Price=84*D;

             else

                price=84*D+((M-D*80)*0.74)

             end

         elseif D<=29

             ifM<D*100

                price=74*D;

             else

                price =74*D+(M-D*100)*0.64;

             end

         else

             ifM<=D*120

                price=64*D;

             else

                price=64*D+(M-D*120)*0.54;

             end

         end

        

         fprintf( ‘The price for the rent is%0.2 f$/n’,price);

    end

    Expert Answer


    . . .


    view full answer