Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用R计算元音频率_R_String_Frequency - Fatal编程技术网

用R计算元音频率

用R计算元音频率,r,string,frequency,R,String,Frequency,你能给我一个提示,用R计算字符串中元音的绝对频率和相对频率的最佳和最简单的方法是什么 我想源代码与我目前在Java论坛上找到的有点不同。设置一些数据: text <- "Can you please give me a hint on what's the best and easiest way to compute the absolute and relative frequencies of vowels in a string using R? I guess the sour

你能给我一个提示,用R计算字符串中元音的绝对频率和相对频率的最佳和最简单的方法是什么

我想源代码与我目前在Java论坛上找到的有点不同。

设置一些数据:

text <- "Can you please give me a hint on what's the best and easiest way to compute the absolute and relative frequencies of vowels in a string using R?

I guess the source code is a bit different from what I've found so far in the forum concerning Java.

Any help is appreciated."
相对频率:

table(x)
x
 a  b  c  d  e  f  g  h  i  j  l  m  n  o  p  q  r  s  t  u  v  w  y 
19  3  8  6 29  8  5  8 17  1  5  4 16 14  5  1 11 16 17  9  5  4  3 
table(x)/length(x)
x
          a           b           c           d           e           f           g           h           i 
0.088785047 0.014018692 0.037383178 0.028037383 0.135514019 0.037383178 0.023364486 0.037383178 0.079439252 
          j           l           m           n           o           p           q           r           s 
0.004672897 0.023364486 0.018691589 0.074766355 0.065420561 0.023364486 0.004672897 0.051401869 0.074766355 
          t           u           v           w           y 
0.079439252 0.042056075 0.023364486 0.018691589 0.014018692 

你能给我一个关于你的数据看起来像什么以及你已经尝试过什么的提示吗。我们有一个句子,我们首先使用substring函数得出字母数:字母=substring(s,seq(1,nchar(s),1),seq(1,nchar(s),1)),现在我们在一个for-each循环中提取字符串中每个元音的频率,比如:for-int i=0;itable(x)/length(x) x a b c d e f g h i 0.088785047 0.014018692 0.037383178 0.028037383 0.135514019 0.037383178 0.023364486 0.037383178 0.079439252 j l m n o p q r s 0.004672897 0.023364486 0.018691589 0.074766355 0.065420561 0.023364486 0.004672897 0.051401869 0.074766355 t u v w y 0.079439252 0.042056075 0.023364486 0.018691589 0.014018692