Philosophy logic Employ The Rule of Conditional Proof where

Philosophy: logic
Employ The Rule of Conditional Proof where available to demonstrate the validity of Arguments 1 & 2. (Do not also employ I.P.) Without Exp. or Trans. W (X Y) X (Y Z) W (X Z) U V ~ U W W X V v X Employ The Rule of Indirect Proof to demonstrate the validity of Arguments 3 & 4 without resorting to C P. A ~ (B C) (D B) C D U V ~ U W W X V v X

Solution

Ans-

# select variables v1, v2, v3
myvars <- c(\"v1\", \"v2\", \"v3\")
newdata <- mydata[myvars]

# another method
myvars <- paste(\"v\", 1:3, sep=\"\")
newdata <- mydata[myvars]

# select 1st and 5th thru 10th variables
newdata <- mydata[c(1,5:10)]

Excluding (DROPPING) Variables

# exclude variables v1, v2, v3
myvars <- names(mydata) %in% c(\"v1\", \"v2\", \"v3\")
newdata <- mydata[!myvars]

# exclude 3rd and 5th variable
newdata <- mydata[c(-3,-5)]

# delete variables v3 and v5
mydata$v3 <- mydata$v5 <- NULL

Selecting Observations

# first 5 observations
newdata <- mydata[1:5,]

# based on variable values
newdata <- mydata[ which(mydata$gender==\'F\'
& mydata$age > 65), ]

# or
attach(newdata)
newdata <- mydata[ which(gender==\'F\' & age > 65),]
detach(newdata)

Selection using the Subset Function

The subset( ) function is the easiest way to select variables and observations. In the following example, we select all rows that have a value of age greater than or equal to 20 or age less then 10. We keep the ID and Weight columns.

# using subset function
newdata <- subset(mydata, age >= 20 | age < 10,
select=c(ID, Weight))

In the next example, we select all men over the age of 25 and we keep variables weight through income (weight, income and all columns between them).

# using subset function (part 2)
newdata <- subset(mydata, sex==\"m\" & age > 25,
select=weight:income)

Philosophy: logic Employ The Rule of Conditional Proof where available to demonstrate the validity of Arguments 1 & 2. (Do not also employ I.P.) Without Exp
Philosophy: logic Employ The Rule of Conditional Proof where available to demonstrate the validity of Arguments 1 & 2. (Do not also employ I.P.) Without Exp

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site