由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 大牛指点下面的R Code 怎么用Loop来实现
相关主题
请教一个关于R的问题问个R的问题
【欢迎进来讨论】for loop in R【急】一个基本的R的问题,求助。谢谢!大包子答谢
solvedHow can I loop through a list of strings as variables in a
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNS[合集] %scan problem
R program help[合集] sas problem, thanks a lot
[R]how to sample all possible continuous subset from ordered data知道random process (X+Y) 和 X 的distribution, 如何得到 Y? (转载)
这个R LOOP错在那里了ask for help with one problem
问个R里面avoid for loop的问题(sapply,lapply...)求教: 倒数和solve怎么不一样--关于R
相关话题的讨论汇总
话题: comb话题: code话题: loop话题: list话题: 下面
进入Statistics版参与讨论
1 (共1页)
w*******n
发帖数: 469
1
请问下面的R Code 怎么用Loop来实现?
这里的comb是list.
先谢谢了!
comb$I.1<-as.integer(as.character(comb$I.1))
comb$I.2<-as.integer(as.character(comb$I.2))
comb$I.3<-as.integer(as.character(comb$I.3))
comb$I.4<-as.integer(as.character(comb$I.4))
comb$I.5<-as.integer(as.character(comb$I.5))
b*******x
发帖数: 100
2
我是菜鸟,不过不知道下面是否可以帮你解决
comb <- lapply(comb,function(x){as.integer(as.character(x))})

【在 w*******n 的大作中提到】
: 请问下面的R Code 怎么用Loop来实现?
: 这里的comb是list.
: 先谢谢了!
: comb$I.1<-as.integer(as.character(comb$I.1))
: comb$I.2<-as.integer(as.character(comb$I.2))
: comb$I.3<-as.integer(as.character(comb$I.3))
: comb$I.4<-as.integer(as.character(comb$I.4))
: comb$I.5<-as.integer(as.character(comb$I.5))

w*******n
发帖数: 469
3
looks close to my answer, but I still have trouble to get it.

【在 b*******x 的大作中提到】
: 我是菜鸟,不过不知道下面是否可以帮你解决
: comb <- lapply(comb,function(x){as.integer(as.character(x))})

b*******x
发帖数: 100
4
What kind of trouble?

【在 w*******n 的大作中提到】
: looks close to my answer, but I still have trouble to get it.
s*****n
发帖数: 2174
5
for (i in 1:5){
var.name <- paste("I.", i, sep = "")
comb[, var.name] <- as.integer(as.character(comb[, var.name]))
}

【在 w*******n 的大作中提到】
: 请问下面的R Code 怎么用Loop来实现?
: 这里的comb是list.
: 先谢谢了!
: comb$I.1<-as.integer(as.character(comb$I.1))
: comb$I.2<-as.integer(as.character(comb$I.2))
: comb$I.3<-as.integer(as.character(comb$I.3))
: comb$I.4<-as.integer(as.character(comb$I.4))
: comb$I.5<-as.integer(as.character(comb$I.5))

w*******n
发帖数: 469
6
Great, that solves my problem.
I appreciate your nice help.

【在 s*****n 的大作中提到】
: for (i in 1:5){
: var.name <- paste("I.", i, sep = "")
: comb[, var.name] <- as.integer(as.character(comb[, var.name]))
: }

w*******n
发帖数: 469
7
Maybe I don't describe my problem so clearly, sorry for this.
I just need some columns of the list to do the conversion from factor to
integer. I can take those columns I like to convert to make a new list, then
try your code. It shows no errors, but the conversion didn't work by
checking the output.

【在 b*******x 的大作中提到】
: What kind of trouble?
b*******x
发帖数: 100
8
I am a little confused, I thought you want the conversion for the whole
list, anyway, your problem was solved:)

then

【在 w*******n 的大作中提到】
: Maybe I don't describe my problem so clearly, sorry for this.
: I just need some columns of the list to do the conversion from factor to
: integer. I can take those columns I like to convert to make a new list, then
: try your code. It shows no errors, but the conversion didn't work by
: checking the output.

1 (共1页)
进入Statistics版参与讨论
相关主题
求教: 倒数和solve怎么不一样--关于RR program help
电面准备救助! (转载)[R]how to sample all possible continuous subset from ordered data
a R loop question这个R LOOP错在那里了
Help to solve a problem. Thanks.问个R里面avoid for loop的问题(sapply,lapply...)
请教一个关于R的问题问个R的问题
【欢迎进来讨论】for loop in R【急】一个基本的R的问题,求助。谢谢!大包子答谢
solvedHow can I loop through a list of strings as variables in a
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNS[合集] %scan problem
相关话题的讨论汇总
话题: comb话题: code话题: loop话题: list话题: 下面