Displaying 6 results from an estimated 6 matches for "thisvar".
2009 Nov 11
1
loop through variable names
...t holds the names and using paste(), eval(), and parse() inside the loop.
For instance:
thesevars<-names(environmental)
environmental$ToyOutcome<-rnorm(nrow(environmental))
tableOfResults<-data.frame(var=thesevars)
tableOfResults$Beta<- NA
rownames(tableOfResults)<-thesevars
for( thisvar in thesevars) {
thiscommand<- paste("thislm <- lm( ToyOutcome ~ ", thisvar, ", data=environmental)")
eval(parse(text=thiscommand))
tableOfResults[thisvar, "Beta"] <- coef(thislm)[thisvar]
}
print(tableOfResults)
Note that it's not always as simple...
2002 Sep 09
1
getting variable names into formulas
...xplore updates of some baseline lme fit by including each of some
subset of these variables, one at a time. For various reasons it is
inconvenient to rely on the positions of the numbered columns in the
dataframe. Here is what I want to do:
mod.baseline<-lme(fixed=foo,data=dat,random=bar)
for(thisvar in vars){
<collect stuff from update(mod.baseline, ~ . ~ + thisvar)>
}
I have tried defining "vars" to be a vector of character strings
giving the names of the variables I want to use, and then using
"as.name(thisvar)" in the formula argument to update(). This doesn...
2009 Sep 16
1
re-code missing value
...ctor w/ 9 levels ".","0.4","1",..: 7 8 5 4 9 2 3 6 1 6 ...
$ v3 : Factor w/ 6 levels ".","1","2","4",..: 1 1 3 4 2 4 1 5 4 2 ...
> df1[df1=="."] <- "NA"
Warning messages:
1: In `[<-.factor`(`*tmp*`, thisvar, value = "NA") :
invalid factor level, NAs generated
2: In `[<-.factor`(`*tmp*`, thisvar, value = "NA") :
invalid factor level, NAs generated
3: In `[<-.factor`(`*tmp*`, thisvar, value = "NA") :
invalid factor level, NAs generated
> df1
site v1 v2...
2010 Nov 09
5
Question regarding to replace <NA>
...92 16 <NA>
3 NNNYN N N N Y N 0.0005292 24 <NA>
4 NNNYY N N N Y Y 0.0259308 8 1
....
I want to replace <NA> by 0, when I tried the following command, I get som
error message.
data[is.na(data)]<-0
Warning message:
In `[<-.factor`(`*tmp*`, thisvar, value = 0) :
invalid factor level, NAs generated
Anyone knows how to deal with this?
Thanks,
Kate
[[alternative HTML version deleted]]
2012 Sep 26
3
replace string values with numbers
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3
CG CG GG
-- -- AC
-- AC CC
AC -- AC I tried to replace all the GG with a value 3. Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp*`, thisvar, value = 3) :
invalid factor level, NAs generated Does any know if there is anything wrong with my code? Thanks, Zhengyu
[[alternative HTML version deleted]]
2011 May 27
0
Wine release 1.3.21
...):
winemenubuilder: Extract icons from NE binaries too.
Dan Kegel (4):
cmd: del /a: move parsing of attributes to helper function, use bitmasks.
cmd: del /a: test deleting readonly files, with fix.
cmd: Add simple test for %errorlevel%.
cmd: Don't read past end of thisVar in WCMD_expand_envvar (valgrind).
David Hedberg (15):
comdlg32: Change some trace statements to dump strings.
comdlg32: Fix reference counting when querying services.
comdlg32: Support some events in the item dialog.
comdlg32: Add IOleWindow implementation to the Item Dialo...