To celebrate the first working day of Harrioson, I generate a small litle section for you!!
##section1 #section1.1
Mostly we use R as a calculator and statistcs program. However, sometimes we use it to define some piggy.
Firstly we need to create a farm for pigs we can use matrix
farm=matrix(c("sheep","sheep","cow","harrison","goat","antelope","lamb","ramb","mie~"),nrow=3,ncol=3)
print(farm)
## [,1] [,2] [,3]
## [1,] "sheep" "harrison" "lamb"
## [2,] "sheep" "goat" "ramb"
## [3,] "cow" "antelope" "mie~"
then find the hiding piggy in the matrix
real_farm=matrix(nrow=3,ncol=3)
for (i in 1:nrow(farm)) {
for (j in 1:ncol(farm)) {
if (farm[i, j] == "harrison") {
real_farm[i,j]="piggy"
print(paste("Found piggy!piggy hide in:(",i,",",j,")"))
} else {
real_farm[i,j]=farm[i,j]
}
}
}
## [1] "Found piggy!piggy hide in:( 1 , 2 )"
Now we would like ti reveal a real farm,we can use print()
print(real_farm)
## [,1] [,2] [,3]
## [1,] "sheep" "piggy" "lamb"
## [2,] "sheep" "goat" "ramb"
## [3,] "cow" "antelope" "mie~"
Then it is a littel game for finding piggy.
Good luck for piggy first working day!!!!!!! love you~~~~