我有2个向量:
word1 <- "bestelling"
word2 <- "bestelbon"
Run Code Online (Sandbox Code Playgroud)
现在我想找到从beginnig开始的最大公共子字符串,所以这里将是"bestel".
但举个例子是"bestelling"和"stel"这两个词,然后我想回来"".
考虑"artikelnr".我想,以取代"nr"由"nummer",但是当我考虑"inrichting",我不想更换"nr".所以我只想替换它"nr","nummer"如果它在一个单词的末尾.
我有两个向量:
vec1 <- c(1,0,1,1,1)
vec2 <- c(1,1,0,1,1)
Run Code Online (Sandbox Code Playgroud)
向量在位置1,4和5处具有相同的元素.
如何在考虑位置的2个向量中返回重叠的元素数量?所以,我想在这里返回3号.
我有以下矢量:
words <- c("5lang","kasverschil2","b2b")
Run Code Online (Sandbox Code Playgroud)
我想删除"5"in "5lang"和"2"in "kasverschil2".但我并不想删除"2"在"b2b".
我有以下矢量:
codes <- c("3WC8" , "456" , "lev", "1")
Run Code Online (Sandbox Code Playgroud)
我想删除"456"和"1",但我不希望删除的号码"3WC8".
我有不同的矩阵和不同的大小(程序创建了我的矩阵,所以我不知道它们的样子)。现在我想检查一个矩阵是否与零矩阵不同。我怎样才能做到这一点?
我有一个文档TermMatrix,如下所示:
artikel naam product personeel loon verlof
doc 1 1 1 2 1 0 0
doc 2 1 1 1 0 0 0
doc 3 0 0 1 1 2 1
doc 4 0 0 0 1 1 1
Run Code Online (Sandbox Code Playgroud)
在包中tm,可以计算两个文档之间的汉明距离。但现在我想对汉明距离小于 3 的所有文档进行聚类。所以这里我希望聚类 1 是文档 1 和 2,聚类 2 是文档 3 和 4。有可能这样做吗?
r cluster-analysis matrix hamming-distance term-document-matrix
我在R中遇到以下情况:
> wordfreq
filiaalnummer filiaal type omschrijving filiaalnaam
1 3 3 2 1
> names(wordfreq)
[1] "filiaalnummer" "filiaal" "type" "omschrijving"
[5] "filiaalnaam"
> as.numeric(wordfreq)
[1] 1 3 3 2 1
Run Code Online (Sandbox Code Playgroud)
每次数字代表上述单词的频率.我想将矢量的名称粘贴到一个具有正确频率的元素中,所以我想得到以下内容:
filiaalnummer filiaal filiaal filiaal filiaal type type type omschrijving omschrijving filiaalnaam
Run Code Online (Sandbox Code Playgroud) 我有以下结构,保存在 txt.file 中:
" punc "
x nounsg x
" punc "
" punc "
artikel nounsg "
" punc "
Run Code Online (Sandbox Code Playgroud)
我想将这个 txt.file 读入 R,所以我试过这个
read.table("pos.txt",header=F, sep=" ")
Run Code Online (Sandbox Code Playgroud)
但是这个在 R 中的产量:
"tpunc\t"
x\tnounsg\tx
"\tpunc\t
"\tpunc\t
artikel\tnounsg\tartikel
"\tpunc\t"
Run Code Online (Sandbox Code Playgroud)
我想要一个有 3 列和 6 行的矩阵。这怎么可能?
当我添加fill = TRUE并使用时,sep = "\t",我得到:
\tpunc\t x \tpunc\t
\tpunc\t artikel \tpunc\t
Run Code Online (Sandbox Code Playgroud)
所以有一些信息丢失
> readLines("pos.txt")[1:2]
[1] "\"\tpunc\t\"" "artikel\tnounsg\tartikel"
Run Code Online (Sandbox Code Playgroud) 我想在 ksvm 中调整参数 C。现在我想知道这个 C 是如何定义的。C的定义是
违反约束的成本(默认值:1)这是拉格朗日公式中正则化项的“C”常数。
这是否意味着 C 越大,允许的错误分类越多?
我有以下代码:
N <- 3
K <- 100
S0 <- 100
u <- 1.007
d <- 1/u
r <- 0.002
a <- 1/6
ptil <- (1+r-d)/(u-d)
qtil <- 1-ptil
VN <- function(n,s,y){
V <- 1/(1+r)*(ptil*VN(n+1,u*s,a*u*s+y)+qtil*VN(n+1,s*d, a*d*s+y))
if (n < N){
return(V)
}
if (n == N){
return(max(c(0,y-K)))
}
}
Run Code Online (Sandbox Code Playgroud)
当我计算时VN(0,S0, aS0),我得到以下错误:Error: evaluation nested too deeply: infinite recursion / options(expressions=)?.我的代码出了什么问题?
我有一个矢量:
vec <- c(1,-2,9,-7,7,4,5,2,1,-10)
Run Code Online (Sandbox Code Playgroud)
现在我想取vec中负值的总和,以及vec中正值的总和.
neg <- sum of the negative values in vec
pos <- sum of the positive values in vec
Run Code Online (Sandbox Code Playgroud)