Professional Documents
Culture Documents
Data Handling in R - Data Frames and Datasets
Data Handling in R - Data Frames and Datasets
# C. Print the data frame and view the structure of the data frame and print
it.
print(empdetails_df)
print(str(empdetails_df))
# Task 3: Print the first, second and tenth columns of the R build-in dataset
mtcars.
print(mtcars[, c(1, 2,10)])
#Task 5: From mtcars print details of all cars which provide more than 30
mpg.
task5 <- mtcars[mtcars$mpg > 30, ]
print(task5)
#Task 6: From mtcars and find all cars that provide more than 30 mpg, and print
the details of the cars in decreasing order of mileage.
# If there are two rows with same mileage, sort the two rows in decreasing
order of disp.
print(task5[rev(order(task5$mpg)),])