小编Car*_*rlo的帖子

如何知道一个向量是否由相同的元素组成?

如何检查向量是否具有所有相同的元素?

例如,假设我有:

vec1 = rep(10,20)
vec2 = seq(1:20)
Run Code Online (Sandbox Code Playgroud)

我怎样才能证明它vec1具有所有相同的元素?

r vector unique

12
推荐指数
2
解决办法
228
查看次数

如何摆脱这个 Do-While 循环?

我有这个基本的 Arduino 代码,我想要 2 个选项来退出这个 Do-While 循环。我简化了我的原始代码以突出真正的问题:Do-While无法识别 OR || 退出循环的条件

在这段代码中,我从两个等于 0 的整数变量开始,一旦它们进入 Do-While,它们就会被设置为等于 2,这样它们就可以在第一个中立即退出 Do-While迭代。

这是我的代码:

int fin = 0;
int ending = 0;
int counter = 0;


void setup() {

  Serial.begin(9600);

}; //void setup



void loop ()  {

  do  {

      Serial.println("We are IN Do-While #1");
      ending = 2;
      //fin = 2;

  } while ((ending < 1) || (fin < 1)); //I have just one condition for exit the Do-While ending = 1


Serial.println("We are OUT Do-While …
Run Code Online (Sandbox Code Playgroud)

c++ arduino do-while

3
推荐指数
1
解决办法
193
查看次数

如何命名列表中的数据框

我创建了一个基本列表,在这个名为lista 的列表中(我知道不是大幻想)有 10 个小数据框。每个数据帧都称为"numberone","numbertwo",...,"numberten"

当我加入这份名单时,我看不到他们的名字。但是我在工作区(Rstudio)中可以看到的输出是这样的

在此处输入图片说明

下面是代码和我的尝试:

#creating multiple dataframes and a list and then give a title to this dataframes inside the list.

lista = list()
names = c("numberone","numbertwo","numberthree","numberfour","numberfive","numbersix","numberseven","numbereight","numbernine","numberten")

for (i in 1:10) {
  x = rnorm(10)
  df = data.frame(x)
  assign(names[i],df)
  lista[[i]] = df
}


#trying to change manually the names of the dataframes inside the "lista"  list

names(lista[1]) = "number one"
print(names(lista[1]))  #this gives no results

#trying using dput
output = dput(lista[1])

##trying put manually …
Run Code Online (Sandbox Code Playgroud)

r list dataframe

2
推荐指数
1
解决办法
3230
查看次数

标签 统计

r ×2

arduino ×1

c++ ×1

dataframe ×1

do-while ×1

list ×1

unique ×1

vector ×1