[R] NA command in a 'for' loop

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Tue Apr 21 23:47:18 CEST 2020


Hi Helen,
>From you last post, I think the best strategy is to make sure that the
operations you are performing are giving you the results you want. If so,
then we can tackle the multiple input files. As I don't have the library
you are using, I cannot access the function "get_tbls", so please replace:

# load whatever library you are using here
with
library(xxxx)
where xxxx is the name of the library

Then run the following script and tell us if you get your expected output

d<-read.table(
text="2.90546E+11,threat,1,2,1,2,1,death,stove,NA,NA,205,0,394
2.90546E+11,threat,2,2,2,1,1,emaciated,shortened,NA,NA,205,0,502
2.90546E+11,threat,3,1,1,1,2,mutilate,consider,NA,NA,205,1,468
2.90546E+11,threat,6,1,2,2,1,weep,shop,NA,NA,203,1,345
2.90546E+11,threat,9,2,1,2,2,tormented,easygoing,NA,NA,205,1,373
2.90546E+11,threat,10,1,2,2,2,snake,table,NA,NA,205,1,343
2.90546E+11,threat,11,2,2,1,1,crisis,faucet,NA,NA,203,1,437
2.90546E+11,threat,12,1,1,1,1,victim,utensil,NA,NA,203,1,343
2.90546E+11,threat,14,1,2,2,1,depressed,repentant,NA,NA,203,1,441
2.90546E+11,threat,15,2,2,1,2,scum,shoe,NA,NA,205,1,475",
header=FALSE,sep=",",stringsAsFactors=FALSE)
# look at at d, is it what you expect?
d
# let d2 be the rows of d where V13 is non-zero
d2<-d[d$V13!=0,]
# look at at d2, is it what you expect?
d2
congruent <-(d2$V4 == 1)
# look at at congruent, is it what you expect?
congruent
# load whatever library you are using here
x<-get_tlbs(d2$V14,congruent,prior_weights=NULL,method="weighted",
 fill_gaps = FALSE)
# look at at x, is it what you expect?
x
write.table(x,file="test_output.txt",quote=FALSE,row.names=FALSE)}
# open "test_output.txt" in a text editor. Is it what you want?

Jim

On Wed, Apr 22, 2020 at 3:11 AM Helen Sawaya <helensawaya using hotmail.com>
wrote:

> Thank you for your patience.
>
> You're welcome.

	[[alternative HTML version deleted]]



More information about the R-help mailing list