Displaying 20 results from an estimated 20000 matches similar to: "Removing replicated rows"
2010 Oct 06
1
replaces a matrix of "NA"s in an array with the previous matrix with numbers
Dear list,
Does anyone know if there is a function that replaces a matrix of "NA"s in
an array with the previous matrix with numbers? For example, I have an
array
ab <- array(dim=c(3,3,15),dimnames=list(rows=1:3,cols=1:3,dim=times)) .
Select out put from the array is:
, , dim = 0.478356969557745
cols
rows 1 2 3
1 0.4921053 0 0.5078947
2 0.0000000 0
2010 Jan 06
2
removing the rows with negative elements
Hello All,
I would like to remove the entire row, if there is any negative element in
that row. What is the best way to do that?
For example,
x<-matrix(c(2,-1,-2,3,5,6,-3,7,4,2,1,0), 4, 3)
the returning matrix should look like
[,1] [,2] [,3]
[1,] 2 5 4
[2,] 3 7 0
Thank you in advance,
FM
[[alternative HTML version deleted]]
2008 Jan 24
2
plot help
Hi,
Suppose I already have two plots on the same screen, and I want to draw
lines in each of them. Is that possible in R? It seems that once you have
two plots on the screen, you can only draw lines in the the last plot, never
the 1st. Here is what I mean:
#some data
y1=rnorm(1:3)
y2=rnorm(1:3)
#draw two plots on the same screen
par(mfrow=c(2,1),oma = c(6, 0, 5, 0))
par(mar=c(0, 5.1, 0, 5.1))
2009 Oct 07
1
Save plot to text file
Dear all:I am sorry if I have missed a solution posted earlier.
My collaborator (sitting in a different time zone and not on R) wants to
re-plot the charts that I have obtained after some complex processing. There
are thirty charts in all, of different types, and some are multi-plots
(plot(new=T)).
Is there a way to 'save' or 'dump just the x-y coordinates to a text/ASCII
file, like
2010 Feb 25
2
Rearranging entries in a matrix
I have a matrix, called data. I used the code below to rearrange the data such that the first column remains the same, but the y value falls under either columns 2, 3 or 4, depending on the value of z. If z=1 for example, then the value of y will fall under column 2, if z=2, the value of y falls under column 3, and so on.
data
x y z
[1,] 50 13 1
[2,] 14 8 2
[3,] 3 7 3
[4,] 4 16 1
[5,] 6
2010 Jan 28
1
question about reshape
Hello everyone,
I have a bit of a problem with reshape function in R.
I have simulated some normal data, which I have saved in 4 vectors.
y.1,y.2,y.3,y.4 which I combined a dataset:
dataset<cbind(y1,y2,y3,y4). I have also generated some subject id number,
and denoted that by subject.
So, my dataset looks like this:
subject y.1 y.2 y.3 y.4
[1,] 1 20.302707
2010 May 25
1
Assigning NA to a rows of a dataframe/datamatrix
Dear R-users, I have a problem, I have the following dataframe:
d<-data.frame(
'y1'=c(1,2,1,2,1,NA,NA),
'y2'=c(1,2,1,1,1,2,1),
'y3'=c(1,NA,1,NA,NA,2,1),
'y4'=c(NA,2,NA,1,1,2,NA),
'a'=c(1,1,1,1,1,1,2)
)
where the last variable counts the number of missing values in a row. Now, i want to set rows where a>1 to NA and arrive at something like the
2018 Jul 20
3
Should there be a confint.mlm ?
It seems that confint.default returns an empty data.frame for objects of
class mlm. For example:
```
nobs <- 20
set.seed(1234)
# some fake data
datf <-
data.frame(x1=rnorm(nobs),x2=runif(nobs),y1=rnorm(nobs),y2=rnorm(nobs))
fitm <- lm(cbind(y1,y2) ~ x1 + x2,data=datf)
confint(fitm)
# returns:
2.5 % 97.5 %
```
I have seen proposed workarounds on stackoverflow and elsewhere, but
2008 Oct 01
1
How to label a "vector"
Hi,
I have an object, Z:
> typeof(Z)
[1] "list"
It looks like:
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 1 1 1
How can it label the Rows and Columns with Text? so that it looks like:
Y1 Y2 Y3
X1 1 1 1
X2 1 1 1
Thanks,
cruz
1998 Nov 09
2
no subject (file transmission)
RNG in R and Splus 3.4
Prof. Ripley asked the details of the example.
We were doing parametric bootstrap, so it is similar to simulation.
Anyway here is the details.
We start with a sample of 19 positive numbers. We know the sample
is from truncated exp(0.3)...only the truncation point, theta, is unknown.
In other words, the sample can be generated from something like
x1 <- rexp(100,
1998 Nov 09
2
no subject (file transmission)
RNG in R and Splus 3.4
Prof. Ripley asked the details of the example.
We were doing parametric bootstrap, so it is similar to simulation.
Anyway here is the details.
We start with a sample of 19 positive numbers. We know the sample
is from truncated exp(0.3)...only the truncation point, theta, is unknown.
In other words, the sample can be generated from something like
x1 <- rexp(100,
2008 Jan 29
3
How to get two y-axises in a bar plot?
Hi,
I have measured two response variables (y1, y2) at each treatment level
(x = 0, 1.5 or 3). Now I would like to show the y1 and y2 against x in a
bar plot. However, y1 and y2 differ in scale so I need two y-axises, one
on the left side and one on the right side (and I dont want to
standardize my responses). This is fairly easy if you want to show
points,lines etc, but gets more complicated
2010 Oct 27
3
ggplot - unwanted sorted X values
Hi,
I have this script:
dat <- data.frame(X = halistat$Date,Y1 = halistat$avg,Y2 = halistat$stdev)
ggplot(data = dat, aes(x = X, y = Y1, ymin = Y1 - Y2, ymax = Y1 + Y2)) +
geom_point() + # points at the means
geom_line() + # if you want lines between pints
geom_errorbar() # error bars, Y1 - Y2 and Y1 + Y2
halistat$Date values:
29/1/10
21/2/10
30/3/10
30/4/10
30/5/10
In the resulted
2011 May 04
1
hurdle, simulated power
Hi all--
We are planning an intervention study for adolescent alcohol use, and I
am planning to use simulations based on a hurdle model (using the
hurdle() function in package pscl) for sample size estimation.
The simulation code and power code are below -- note that at the moment
the "power" code is just returning the coefficients, as something isn't
working quite right.
The
2009 Dec 03
4
Replace values in a vector
Hi all,
I have a vector like this:
x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
I would like to replace the zero values with the first previous non zero value.
my returning vector should look like this:
y<-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)
How can I do this in R without using for loop?
Thank you
2007 May 29
1
rgl.postscript
Hi,
I am having an issue when creating a postscript file from RGL window. It
seems to cut off some of the axis labels. Here is the code I am using.
I created a 3D plot using RGL_0.71 with R 2.5 on Windows XP.
z1<-c(5,4,1,4.5,2,3,2,1,1)
z2<-c(6,8,7,7.5,5,3.5,4,1,1)
z3<-c(3,2,4,7,3,4.5,6,2,3)
x1<-seq(1,9)
x2<-seq(1,9)
x3<-seq(10,18)
y1<-seq(8,0)
y2<--1*y1
2007 Dec 01
2
How to cbind DF:s with differing number of rows?
#Hi R-users,
#Suppose that I have a data.frame like this:
y1 <- rnorm(10) + 6.8
y2 <- rnorm(10) + (1:10*1.7 + 1)
y3 <- rnorm(10) + (1:10*6.7 + 3.7)
y <- c(y1,y2,y3)
x <- rep(1:3,10)
f <- gl(2,15, labels=paste("lev", 1:2, sep=""))
g <- seq(as.Date("2000/1/1"), by="day", length=30)
DF <- data.frame(x=x,y=y, f=f, g=g)
DF$g[DF$x == 1]
2016 Apr 30
4
Removing NAs from dataframe (for use in Vioplot)
Hi
First post and a relative R newbie....
I am using the vioplot library to produce some violin plots. I have an input CSV with columns off irregular length that contain NAs. I want to strip the NAs out and produce a multiple violin plot automatically labelled using the headers. At the moment I do this
Code:?
ds1 = read.csv("http://www.lecturematerials.co.uk/data/spelling.csv")
2007 Dec 19
3
Obtaining replicates numbers of a vector
Dear R-help,
I am trying to have a generic way to assess the replicates in a character
vector.
Say that I have the following vector:
x <- c('A','B','A','C','C','B')
I would like to obtain:
replicates <- c(1,1,2,1,2,2)
each number beeing the time we see the corresponding value in x.
Any clever and generic way to obtain that?
Eric
--
2018 Jul 20
0
Should there be a confint.mlm ?
>>>>> steven pav
>>>>> on Thu, 19 Jul 2018 21:51:07 -0700 writes:
> It seems that confint.default returns an empty data.frame
> for objects of class mlm. For example:
> It seems that confint.default returns an empty data.frame for objects of
> class mlm.
Not quite: Note that 'mlm' objects are also 'lm' objects, and so
it is