1
機能を連結する際に改行を追加するために使用するコマンドは何ですか?ここで連結機能に改行を追加しますか?
はスクリプトです:
cat(one("canada"), '\n\n', one("canada"))
Canada has 50 thousand farmsCanada has 50 thousand farms
を、私はそれが次のようになりたい::ここで
canada <- c(50, 50, 50)
korea <- c(70, 70, 70)
brazil <- c(100, 100, 100)
fruit <- rbind(canada, korea, brazil)
colnames(fruit) <- c("apple", "orange", "banana")
one <- function(x){
x <- tolower(x) # assuming all row names are in lower case
myrow <- fruit[x,]
count <- sapply(seq_along(myrow),
function(x, n, i)
{paste0(x[i], "")},
x=myrow[1], n=names(myrow))
count[length(count)] <- paste0(count[length(count)])
count <- paste(count[1])
cat(tools::toTitleCase(x), "has", count, "thousand farms") # General statement
}
は、私が試したものです
Canada has 50 thousand farms
Canada has 50 thousand farms