Displaying 20 results from an estimated 3000 matches similar to: "Loop with variable index"
2008 Feb 26
4
numeric format
Hi!
I'm an R newbie and this should be a trivial problem, but I can't make it
work and cannot find what I'm doing wrong in the literature.
I entered the the command:
table<-data.frame(x, scientific=F, digits=4)
table
This prints a column of x with 16 useless decimal places after the decimal
point. Also, it prints an unwanted index number (1-20) in the left column.
How do I get rid
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows:
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5))
mns <- c(3.4, 3.6)
sds <- c(0.24, 0.35)
dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd =
sds[dat$claim + 1]))
dat <-
2009 Jul 08
2
Formatting a Table
I've created a short program to print a table of learning curve factors.
However, I cannot figure out how to format the table to:
1) Get rid of the [1]s in the first column and replace it with the values of
N.
2) Line up the first row with the factors (decimal fractions).
Thanks for any help.
The complete program and output is as follows:
> Lc<-seq(0.70,0.95,0.05) #Specify learning
2011 Feb 09
1
add mean and sd to dotplot in each panel using lattice
Hi,
I have a data frame like this:
ScoreDoseSex
2.81Dose1M
1.81Dose1M
1.22Dose1M
0.81Dose1M
0.49Dose1M
0.22Dose1M
0.00Dose1M
-0.19Dose1M
-0.17Dose1F
-0.32Dose1F
-0.46Dose1F
-0.58Dose1F
-0.70Dose1F
-0.81Dose1F
-0.91Dose1F
-1.00Dose1F
-1.77Dose2M
-1.85Dose2M
-1.93Dose2M
-2.00Dose2M
-2.07Dose2M
-2.14Dose2M
-2.20Dose2M
-2.26Dose2M
-2.32Dose2F
-2.38Dose2F
-2.17Dose2F
-2.49Dose2F
-2.54Dose2F
2011 Jun 09
3
Visual Fox Pro 9 with dBase tables
Hi everyone. I have a though one here.
In a friend's company they use n accounting and POS software which was designed by someone that passed away. The problem is that he doesn't have much money right now, thus can't license windows and MSoffice in his office.
I offered him the possibility of using Linux (Mint or Ubuntu) and having him run the software on Wine.
This is the software
2008 Feb 02
1
Plotting 3 vectors on one graph.
I'm an R newbie and am trying to plot 3 vectors, say a,b,c. I have
downloaded 3 R manuals and searched your forum. There are plenty of X vs Y
examples, but cannot find how to plot 3, or more vectors one one graph. I'm
sure I overlooked something.
Thanks for any help.
CHV
--
View this message in context: http://www.nabble.com/Plotting-3-vectors-on-one-graph.-tp15236552p15236552.html
2010 Mar 17
2
How to use "ifelse" to generate random value from a distribution
I need use different parameters of distribution for different case to
generate random value, but I use ifelse, the generated value is fixed
without change.
Here is example
data1
y x
1 1 2
2 2 1
3 3 2
4 4 3
5 5 3
6 6 1
7 7 2
8 8 1
9 9 1
10 10 3
11 11 3
12 12 2
ifelse(data1$x==1,rnorm(1,2,1),ifelse(data1$x==2,rnorm(1,-2,1),rnorm(1,110,1)))
[1] -1.8042172 0.8478681
2011 Oct 22
3
R for loop stops after 4 iterations
I have a data frame called e, dim is 27,3, the first 5 lines look like this:
V1 V2 V3 V4
1 1673 0.36 0.08 Smith
2 167 0.36 0.08 Allen
3 99 0.37 0.06 Allen
4 116 0.38 0.07 Allen
5 95 0.41 0.08 Allen
I am trying to calculate the proportion/percentage of V1 which would have
values >0.42 if V2 was the mean of a normal distribution with V1
2011 Mar 19
2
Output a table formatted with standard deviations below means
Is it in bad form to double post to StackOverflow and R-help? Apologies if
so. Here's my task:
I've got a matrix of means like so
means<-matrix(1:10,nrow=2)
colnames(means)<-c("a","b","c","d","e")
and a matrix of standard deviations like so
sds<-matrix(seq(0.1,1,by=0.1),nrow=2)
2011 Jul 21
2
Latex Table Help on R
Hello everyone,
Peter (see my earlier post) recommended the following script for finding the
means and standard deviations and putting them in table form.
However, I would like the standard deviations under the means in brackets.
Can anyone check this code to see how this can be adjusted?
library(xtable)
dataset1 = matrix( c(1,2,3,4, 5, 6 ), 2 , 3)
dataset2 = matrix( c(4,3,5,10, 1, 0), 2, 3)
2009 May 17
1
One Sample Nonparametric
Hi!
I'm doing one and two sample nonparametric tests for the median using wilcox
test. For a one-sample test I use:
> wilcox.test(x, mu =50 (or whatever), y=NULL,correct=TRUE)
For two-sample test I use:
> wilcox.test(x,y,correct=TRUE)
The problem is when I try to duplicate problems from textbooks, I get
p-values that are much different from the examples from the literature.
They are
2005 Mar 09
4
How to get standard deviation of rows in a matrix
Hi all,
I am trying to find sd of my rows in a matrix and i get column sd inspite of extracting rows.
I tried to do the sqrt(var(x)) but that did'nt work as well,
Here is my data
genes
15 24 63 40
25 42 46 35
23 53 37 45
30 37 50 55
40 51 30 48
x<-sd(genes[1:5,])
y<-sqrt(var(genes[1:5,]))
I get 4 sds for the 4 columns instead of 5 sds for my 5 rows.
Thanks you in advance.
2003 Sep 07
3
bug in crossprod? (PR#4092)
# Your mailer is set to "none" (default on Windows),
# hence we cannot send the bug report directly from R.
# Please copy the bug report (after finishing it) to
# your favorite email program and send it to
#
# r-bugs@r-project.org
#
######################################################
# The last line of following code produces a segmentation fault:
x <- 1:10
f <- gl(5,2)
2009 Jun 18
4
Random number datasets help
Hello:
My problem is that I have a data frame of means, and a data frame of standard deviations which match up to each mean. I have been trying to create 500 random numbers in a given dataset for each mean/sd combination, but I am only able to generate the last value in each data set to create one dataset (there should be 28 in all). Examining my code, what can I change to generate 28 datasets
2012 Feb 13
2
Error in apply(x2, 1, diff) : dim(X) must have a positive length
Anyone knows hat might be the cause of this error? Thanks for any help!
>library(MASS)
> dif.mns = function(x2,tr1=.2,tr2=.3){
+ #generates four different 'means' using
+ #difference scores from x2, an n x 2 matrix
+ #for use w/ bootstrap comparisons
+ diffs = apply(x2,1,diff)
+ mn1=mean(diffs)
+ mn2=mean(diffs,tr=.2)
+ mn3=mean(diffs,tr=.3)
+
2011 Aug 17
3
questions about "metafor" package
Hello,
I would like to do a meta-analysis with the package « metafor ». Ideally I would like to use a mixed model because I’m interested to see the effect of some moderators. But the data set I managed to collect from literature presents two limits.
- Firstly, for each observation, I have means for a treatment and for a control, but I don’t always have corresponding standard
2008 Oct 07
1
column-wise z-scores by group
Hi,
I have a dataset of historical monthly temperature data that is grouped by
weather station. I want to create z-scores of the monthly data using a base
period of a subset of years. I subset the dataset first to include only data
from the years (V2) that make up the base period so I could calculate the
appropriate means and standard deviations
V1 V2 V3 V12 V15 V16 V19
84
2011 Jan 29
1
Problem in weighting standard deviations
Dear all,
I have a problem that has been driving me nuts. I have searched everywhere
but could not find a comprehensive answer. I only get (sometimes
contradictory) bits of information.
I have a series of measurements with associated standard deviations, e.g:
means +/- sd
10 +/- 0.2
13 +/- 0.4
09 +/- 0.3
The number of observations used to estimate any of these means was the same.
Let's say
2005 May 02
1
newbie ifelse matrix question
Hi all,
I have time series data in a matrix format 20 rows x 205 columns and have been trying to replace outliers with NA. My first column contains the outliers threshold (3 Standard deviations) for each row - here's a bit of the first row
sd3 V1 V2 V3 V4 V5 V6 V7 V8 V9
1 13.03267 1797157 75 84 58 -1.958649 0.048775 2.056198 8.063622
2011 Jul 20
1
Latex Table for means and standard deviations in brackets
Hello all,
I am new to xtable. I have several datasets in the form of matrices.
Consider the following two simple datasets which are 2 x 3 matrices. The
rows in both matrices have the same meaning. For example the first row of
both matrices are variable 1 and the second row of both matrices are
variable 2.
dataset1 = matrix( c(1,2,3,4, 5, 6 ), 2 , 3)
dataset2 = matrix( c(4,3,5,10, 1, 0), 2, 3)