Displaying 20 results from an estimated 300 matches similar to: "read.table input array"
2005 Feb 08
5
How to get variable names in a function?
Hello,
applying a function to a list of variables I face the following problem:
Let's say I want to compute tables for several variables. I could write a
command for every single table, like
bravo<-c(1,1,2,3,5,5,5,);charly<-c(7,7,4,4,2,1)
table(bravo); table(charly)
> table(bravo); table(charly)
bravo
1 2 3 5
2 1 1 3
charly
1 2 4 7
1 1 2 2
The results are two tables with the
2010 Feb 18
1
variable substitution
Hi
I would like to write a script that reads a list of variable names. These variable names are some of the column headers in a data.frame. Then I want do a for-loop to execute various operations on the specified variables in the data.frame, but can't figure out how to do the necessary variable substitution. In bash (or C) I would use "$var", but there seems to be no equivalent in
2003 Oct 08
2
Generating automatic plots
Hello,
I have been trying to write a small program to generate automatic plots. What
I want is to draw boxplots for some variables in my data frame, contrasting
with a variable called 'missing' that has value 1 if some variable in a
concrete case has at least one missing value, in order to check if the cases
that don't enter in my analysis are biased.
The first attempt was to
2012 Mar 10
1
Treat Variable as String and a String as variables name
Dear all.
I am having ten variables (let's call the four of them as
Alpha, Beta, Gamma and Delta.....)
For each variable I have to print around 100 (plots). E
So far I was copying paste the code below many times.
pdf(file="DC_Alpha_All.pdf", width=15) # First Variable is treated as string
plot_dc_for_multiple_kapas(Alpha, 4, c(5, 4), coloridx=c(24, 32)) # First Variable is
2007 Oct 22
3
Elasticity in Leslie Matrix
Dear R-users,
I would like to calculate elasticities and sensitivities of each parameters
involved in the following transition matrix:
A <- matrix(c(
sigma*s0*f1, sigma*s0*f2,
s, v
), nrow=2, byrow=TRUE,dimnames=list(stage,stage))
The command "eigen.analysis" avaliable in package "popbio" provides
sensibility matrix and elasticity matrix
2016 Dec 13
2
syntax difference clusterExport in parallel and snow
We got some errors and eventually figured out that
parallel::clusterExport second argument is "varlist" while in
snow::clusterExport it is "list".
The user had loaded parallel first, but did something else which
inadvertently loaded snow, then clusterExport failed because we had
"varlist" and not "list".
Are these different on purpose?
pj
--
Paul E.
2010 Feb 25
3
variable substitution in for loops
Friends
I can't quite find a direct answer to this question from the lists, so here goes:
I have several dataframes, 200+ columns 2000+ rows. I wish to script some operations to perform on some of the variables (columns) in the data frames not knowing what the column number is, hence have to refer by name. I have variable names in a text file "varlist". So, something like this:
2012 Nov 24
1
Bootstrap lmekin model
Hi,I use the 'lmekin' model of the 'kinship' package of R in order to estimate heritability. I want to estimate the confidence interval of the variance coefficient and so I should use a bootstrap simulation. The pedigree file has 1386 subjects so I create a kinship matrix [1386*1386].This is the code of R I use:
kfit2 <- lmekin(IT~1+AGE +(1|ID), dati1,
2009 Oct 11
1
How do you test if a number is in a list of numbers?
Hi,
I want to subset a data frame if one of the variables matches any in a list.
I could of course do something like this:
subset(dataset, var == 1 | var == 2 | var ==3)
but that's tedious.
I tried
varlist = c(1,2,3,4)
subset(dataset, any(var == varlist))
but it doesn't work because 'any' doesn't go row-by-row and hence always
returns TRUE.
Is there any simple way to do this?
2013 Feb 18
3
foreach loop, stata equivalent
Hi! I'm a recent convert from Stata, so forgive my ignorance.
In Stata, I can write foreach loops (example below)
foreach var of varlist p1-p14 {
foreach y of varlist p15-p269 {
reg `var' `y'
}
}
It's looping p1-p15, p1-p16...., p1-p269, p2-p15, p2-p16,... p2-p269,...
variable pairs.
How can I write something similar in R?
I 'tried' understanding the
2011 Apr 15
1
no solution yet, please help: extract p-value from mixed model in kinship package
I am making the question clear. Please help.
> Dear R experts
>
> I was using kinship package to fit mixed model with kinship matrix.
> The package looks like lme4, but I could find a way to extract p-value
> out of it. I need to extract is as I need to analyse large number of
> variables (> 10000).
>
> Please help me:
>
> require(kinship)
>
> #Generating
2010 Nov 11
3
Evaluation puzzle
The survexp function can fail when called from another function. The "why" of
this has me baffled, however.
Here is a simple test case, using a very stripped down version of survexp:
survexp.test <- function(formula, data,
weights, subset, na.action, rmap,
times, cohort=TRUE, conditional=FALSE,
ratetable=survexp.us, scale=1, npoints, se.fit,
2012 Oct 18
1
Getting a table of coefficients from R
Hi,?
I'm trying to obtain a table of coefficients and confidence intervals from a logistic regression analysis in R. My code is as follows:
# read in csv file
datafile<-read.csv("file.csv", row.names=1)
# read in the variable list
varlist<-names(datafile)[66:180]
models<-lapply(varlist, function(x) {glm(substitute(outcome ~ i, list(i=as.name(x))), data=datafile, family =
2010 Oct 12
1
Help with function writing
Hello all
I have what seems like a simple question but have not been able to find an
answer on the forum. I'm trying to define a function which involves
regression models and a large number of covariates.
I would like the function to accept any number of covariates and, ideally, I
would like to be able to enter the covariates in a group (e.g. as a list)
rather than individually. Is there any
2003 Dec 11
2
read.spss question warning compression bias
Hello again
I have a file from SPSS in .sav format.
when I run
library(foreign)
cvar<-as.data.frame(read.spss("c:\\NDRI\\cvar\\data\\cvar2rev3.sav"))
I get a warning
Warning message:
c:\NDRI\cvar\data\cvar2rev3.sav: Compression bias (0) is not the usual
value of 100.
The data appear to be OK, but I am concerned.
(I tried searching the archives and the documenation for data
2005 Aug 15
2
randomForest Error passing string argument
I'm attempting to pass a string argument into the function
randomForest but I get an error:
state <- paste(list("fruit ~", "apples+oranges+blueberries",
"data=fruits.data, mtry=2, do.trace=100, na.action=na.omit,
keep.forest=TRUE"), sep= " ", collapse="")
model.rf <- randomForest(state)
Error in if (n==0) stop ("data(x) has 0
2008 May 19
2
recoding data with loops
# I'm new to R and am trying to get the hang of how it handles
# dataframes & loops. If anyone can help me with some simple tasks,
# I'd be much obliged.
# First, i'd like to generate some random data in a dataframe
# to efficiently illustrate what I'm up to.
# let's say I have six variables as listed below (I really
# have hundreds, but a few will illustrate the point).
#
2007 Aug 04
3
using loops to create multiple images
I have a data.frame with ~100 columns and I need a barplot for each column
produced and saved in some directory.
I am not sure it is possible - so please help me.
this is my loop that does not work...
vars <- list (substitute (G01_01), substitute (G01_02), substitute (G01_03),
substitute (G01_04))
results <- data.frame ('Variable Name'=rep (NA, length (vars)),
2012 Oct 07
1
variances of random effects in coxme
Dear R users,
I'm using the function coxme of the package coxme in order to build Cox
models with complex random effects. Unfortunately, I sometimes get
surprising estimations of the variances of the random effects.
I ran models with different fixed covariates but always with the same 3
random effects defined by the argument
varlist=coxmeMlist(list(mat1,mat2,mat3), rescale = F, pdcheck = F,
2008 Mar 05
1
coxme - fitting random treatment effect nested within centre
Dear all,
I am using "coxme" function in Kinship library to fit random treatment effect nested within centre. I got 3 treatments (0,1,2) and 3 centres. I used following commands, but got an error.
> ugroup=paste(rep(1:3,each=3),rep(0:2,3),sep='/')
> mat1=bdsmatrix(rep(c(1,1,1,1,1,1,1,1,1),3),blocksize=rep(3,3),dimnames=list(ugroup,ugroup))
>