unclass(as.Date("1971-01-01"))
xvect<-c(1,2,3)
xvect[2] <- "2"
xvect
height(length(height))
height[length(height)]
height[length[height]]
height(5)
sd(rates[, 2])
returns 39. As what does R regard Ellen’s product ratings?Var_A!
\_VarA
.2Var_A
Var2_A
> class( d.pizza[ , "temperature" ] )
> "numeric"
class( d.pizza( , "temperature" ) )
class( d.pizza[ , "temperature" ] )
class( d.pizza$temperature )
class( d.pizza[ , "temperature", drop=F ] )
a <- c(3,3,6.5,8)
b <- c(7,2,5.5,10)
c <- a < b
> y <- 1:9
> dim(y) <- c(3,3)
mydf$y
in this code?mydf <- data.frame(x=1:3, y=c("a","b","c"), stringAsFactors=FALSE)
1 mylist <- list(1,2,"C",4,5)
2 unlist(mylist)
x <- NA
y <- x/1
cor.test(Var1 ~ Var2)
cor.test(mydata$(Var1,Var2))
cor.test(mydata$Var1,mydata$Var2)
cor.test(Var1,Var2, mydata)
library(DescTools)
deliver <- aggregate(count,by=list(area,driver), FUN=mean)
print(deliver)
attach(d.pizza)
summarize(deliver)
mean <- rbind(d.pizza,count)
deliver[!complete.cases(deliver),]
v1<-list(1,2,3)
v2<-list(c(4,5,6))
vbound<-cbind(v1,v2)
v1<-c(1,2,3)
v2<-list(4,5,6))
vbound<-cbind(v1,v2)
v1<-c(1,2,3)
v2<-c(4,5,6))
vbound<-cbind(v1,v2)
Cpeople <- ournames %in% grep("^C", ournames, value=TRUE)
v <- 1:3
names(v) <- c("a", "b", "c")
v[4] <- 4
x <- c(1, 2, 3, 4)
Output: [1] 2 3 4
x<-5:8
names(x)<-letters[5:8]
x
x<-as.Date("2018-10-01")
fact<-factor(c("Rep","Dem","Dem","Rep"))
fact
[1] Rep Dem Dem Rep
Levels: Rep Dem
fact[2]<-"Ind"
StartDate<- as.Date("2020/2/28")
StopDate<- as.Date("2020/3/1")
StopDate-StartDate
mtrx * mtrx
do ?> mtrx <- matrix( c(3,5,8,4), nrow= 2,ncol=2,byrow=TRUE)
> newmat <- mtrx * mtrx
> newmat
[,1] [,2]
[1,] 9 25
[2,] 64 16
# The `%*%` operator gives matrix multiplication
> mtrx %*% mtrx
[,1] [,2]
[1,] 49 35
[2,] 56 56
StDf[, -1]
MyMat[ ,3]
subsetting operation return for this code?MyMat = matrix(c(7, 9, 8, 6, 10, 12),nrow=2,ncol=3, byrow = TRUE)
[ ,3]
[1, ] 8
[2, ] 12
[1] 8 12
[1] 10 12
[ ,3]
[1, ] 10
[2, ] 12
power.anova.test
return?covariate:factor
on the analysis?result <- lm(outcome ~ covariate + factor + covariate:factor, data = testcoef)
# Example call to demonstrate. `Species` is a Factor. Petal.Length, Petal.Width are numeric.
# see `help(formula)` for more details on the formula specification. `:` is "effect modification" or "interaction"
> summary(lm(Petal.Length ~ Petal.Width + Species + Petal.Width:Species, data = iris))
...
Petal.Width:Speciesversicolor 1.3228 0.5552 2.382 0.0185 *
Petal.Width:Speciesvirginica 0.1008 0.5248 0.192 0.8480
...
Rmat
?Rmat[upper.tri(Rmat)]
upper.triangular(Rmat)
upper.tri(Rmat)
upper.diag(Rmat)
x
is a vector of type integer, as shown on line 1 below. What is the type of the result returned by the statement > median(x)?x <- c(12L, 6L, 10L, 8L, 15L, 14L, 19L, 18L, 23L, 59L)
a
is created using the statement below. Which choice returns TRUE?a <- list("10", TRUE, 5.6)
pizza
for which the value of pizza$delivery_min
is greater than or equal to 30?late_delivery <- pizza$delivery_min >= 30
index_late <- index(late_delivery)
index_late
late_delivery <- pizza$delivery_min >= 30
rownum_late <- rownum(late_delivery)
rownum_late
late_delivery <- pizza$delivery_min >= 30
which_late <- which(late_delivery)
which_late
late_delivery <- pizza$delivery_min >= 30
late <- piza$late_delivery
pizza$late
[1] TRUE FALSE TRUE
?indat <- c("Ash Rd","Ash Cir","Ash St")
[ ] grepl(“[Rd | Ave | Dr | St]”, indat) |
[x] grepl(“Rd | Ave | Dr | St”, indat) |
a <- c(1.2, 2, 3.5, 4)
b <- c(1.2, 2.2, 3.5, 4)
csum <-sum(a == b)
a <- list("10", TRUE, 5.6)