Forum posts for df.exe

R - Create subset data frame using variable

I am trying to create a loop that will perform a series of analyses. I am using geeglm from geepack, which fails if there are any null values. Creating a subset solves this, but do not seem to be able to set the subset dynamically based on a changing variable.

while (j <= y.num) {

strSubset = as.character(df.IV$IV[j]) #Gives column name in quotes = subset(, strSubset>=0)

#subset dataset is not created

# analyses on subset take place

j = j + 1

If I type the variable name in the formula it works, so I assume that I am not creating the variable in a manner that allows it to be evaluated in the subset function. Any help would be greatly appreciated!

Reproducible example:

# dataset

# dataset of columns that will be used for analysis
values<-c('age', 'height')

# Age column has a null (NA) value. The row must be removed for the analysis to run
# explicit creation
df.ex.sub.explicit<-subset(df.ex, age >= 0)
dim(df.ex.sub.explicit) #11 obs of 2 variables

dim(df.ex.sub.explicit) #12 obs of 2 variables

View complete forum thread with replies

Other posts related to df.exe

See Related Forum Messages: Follow the Links Below to View Complete Thread

R - Create subset data frame using variable
Exploding date range as row is R
Is there a better way to find the percent of one column that meets a criteria for each value&hellip;
Error: This name does not have a type, and must have an explicit type
Fortran program errors
Fortran &ldquo;Error: The shapes of the array expressions do not conform.&rdquo;

What is the carbon footprint of your coffee?

Is it low? Is it high? Can this things really kill the planet Earth? Maybe the answer will surprise you. Maybe not.