Question

in R Determine the class of each column in the flights data set from the nycflights13...

in R

Determine the class of each column in the flights data set from the nycflights13 package.

Homework Answers

Answer #1

##to load nycflights13 dataset
library(nycflights13)

## to display
flights

##---------------------------------------------------------------------------------
##way to find out class of particular column 'hour' in dataframe flight

class(flights$hour)
#ans is

> class(flights$hour)
[1] "numeric"


##---------------------------------------------------------------------------------
## one way to find classes of flights dataset
str(flights)

#answer is as follows
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   336776 obs. of 19 variables:
$ year : int 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 ...
$ month : int 1 1 1 1 1 1 1 1 1 1 ...
$ day : int 1 1 1 1 1 1 1 1 1 1 ...
$ dep_time : int 517 533 542 544 554 554 555 557 557 558 ...
$ sched_dep_time: int 515 529 540 545 600 558 600 600 600 600 ...
$ dep_delay : num 2 4 2 -1 -6 -4 -5 -3 -3 -2 ...
$ arr_time : int 830 850 923 1004 812 740 913 709 838 753 ...
$ sched_arr_time: int 819 830 850 1022 837 728 854 723 846 745 ...
$ arr_delay : num 11 20 33 -18 -25 12 19 -14 -8 8 ...
$ carrier : chr "UA" "UA" "AA" "B6" ...
$ flight : int 1545 1714 1141 725 461 1696 507 5708 79 301 ...
$ tailnum : chr "N14228" "N24211" "N619AA" "N804JB" ...
$ origin : chr "EWR" "LGA" "JFK" "JFK" ...
$ dest : chr "IAH" "IAH" "MIA" "BQN" ...
$ air_time : num 227 227 160 183 116 150 158 53 140 138 ...
$ distance : num 1400 1416 1089 1576 762 ...
$ hour : num 5 5 5 5 6 5 6 6 6 6 ...
$ minute : num 15 29 40 45 0 58 0 0 0 0 ...
$ time_hour : POSIXct, format: "2013-01-01 05:00:00" "2013-01-01 05:00:00" "2013-01-01 05:00:00" ...

##---------------------------------------------------------------------------------
##---------------------------------------------------------------------------------
##another way using lapply to apply class function on every column
lapply(flights,class)

## answer
> lapply(flights,class)
$year
[1] "integer"

$month
[1] "integer"

$day
[1] "integer"

$dep_time
[1] "integer"

$sched_dep_time
[1] "integer"

$dep_delay
[1] "numeric"

$arr_time
[1] "integer"

$sched_arr_time
[1] "integer"

$arr_delay
[1] "numeric"

$carrier
[1] "character"

$flight
[1] "integer"

$tailnum
[1] "character"

$origin
[1] "character"

$dest
[1] "character"

$air_time
[1] "numeric"

$distance
[1] "numeric"

$hour
[1] "numeric"

$minute
[1] "numeric"

$time_hour
[1] "POSIXct" "POSIXt"

Know the answer?
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
Similar Questions
given a set of data of just one column. in excel or r please explain how...
given a set of data of just one column. in excel or r please explain how to make this data (only has one column) into a ACF graph with their lags. only one data set was given with only one column. meaning there isnt a potential x and y columns. Please show code (if using R) or format if using Excel.
In the left column below are listed the r-values of various data sets, each of which...
In the left column below are listed the r-values of various data sets, each of which contains 100 points. Descriptions of those data sets are shown in the right column. Match each r-value with the description of the data set with which it is most likely associated. r=0.1 A. Data shows a clear upward trend r=0.6 B. Data points lie quite close to a line with negative slope r=0.9 C. Data shows a very slight upward trend r=−0.6 D. Data...
Describe how to construct a​ stem-and-leaf plot from a set of data. Assume that the data...
Describe how to construct a​ stem-and-leaf plot from a set of data. Assume that the data consist of​ two-digit numerical values. Choose the correct answer below. A. ​First, organize the data into several​ classes, such as​ 40-49, 50-59, and so on.​ Then, tally the number of data items in each​ class, and determine the percentage of the population occupied by each class. Draw a​ circle, and divide the circle into portions representing the percentage for each class. B. The plot...
For my Healthcare Statistics class....Consider two different data sets and then for each data set, propose...
For my Healthcare Statistics class....Consider two different data sets and then for each data set, propose your idea of what graph would best represent the key information. For each, be sure to include the type of graph along with what would be shown on each axis. The key data in the first data set is a list of all the injuries that a clinic saw in a month. The other data set has key data on the number of minutes...
Use data set "Chick Weight" in R Conduct a statistical test to determine if the mean...
Use data set "Chick Weight" in R Conduct a statistical test to determine if the mean weight of chicks is greater than 120. Use α = 0.01.
From the data set of a class, the score of a student taking a test is...
From the data set of a class, the score of a student taking a test is a random variable with mean equal to 75 and variance equals to 25. How many students would have to take the test to ensure - with probability at least 0.9 - that the class average would be within 5 of 75?
How can I use R to enter a data set, along with the probability for each...
How can I use R to enter a data set, along with the probability for each data point, and find the expected values for each?
Construct a scattergram for each data set. Then calculate r and r2for each data set. Interpret...
Construct a scattergram for each data set. Then calculate r and r2for each data set. Interpret their values. Complete parts a through d. a. x−1,0,1,2,3 y−3,0,1,4,5 Calculate r. r=.9853 ​(Round to four decimal places as​ needed.)Calculate r2.=0.9709 ​(Round to four decimal places as​ needed.) Interpret r. Choose the correct answer below. A. There is not enough information to answer this question. B. There is a very strong negative linear relationship between x and y. C.x and y are not related....
Suppose that a student in this class uses their personalized class data set to find the...
Suppose that a student in this class uses their personalized class data set to find the following confidence interval for the proportion of students in this class who travel more than 5 km to school: (.171, .243). Consider the following statements. (i) The proportion of students in that same student's personalized class data set who travel more than 5km to school might not be in the interval (.171, .243). (ii) The true proportion of students in this class who travel...
Suppose that a student in this class uses their personalized class data set to find the...
Suppose that a student in this class uses their personalized class data set to find the following confidence interval for the proportion of students in this class who travel more than 5 km to school: (.171, .243). Consider the following statements. (i) The true proportion of students in this class who travel more than 5km to school must be in the interval (.171, .243). (ii) If that same student used the same data set to produce the following confidence interval...