Displaying 20 results from an estimated 40000 matches similar to: "Inserting a blank row to every other row"
2016 Apr 24
0
Inserting a blank row to every other row
Oh, sorry, I just realized that I messed up the indicing. Here is the
correct way:
> z <- data.frame(a=1:3,b = letters[1:3])
> i <- seq_len(nrow(z))
> z<-z[rep(i,e=2),]
> z[2*i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z))
> z
Still doubt that this is a good idea, though.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
2016 Apr 24
2
Inserting a blank row to every other row
Well, something like this would work (there may be slicker solutions):
> z <- data.frame(a=1:3,b = letters[1:3])
> i <- seq_len(nrow(z)) *2
> z <-rbind(z,z)
> z[i, ] <- matrix(NA, nr=nrow(z),nc=ncol(z))
> z
a b
1 1 a
2 NA <NA>
3 3 c
4 NA <NA>
5 2 b
6 NA <NA>
But I agree with you that there is probably a way to handle the
underlying
2016 Apr 24
0
Inserting a blank row to every other row
Hi Saba,
I don't know how to do what you want and I also cannot see why.
If you describe what you hope to achieve there might be a different
solution.
Best wishes
Ulrik
Saba Sehrish via R-help <r-help at r-project.org> schrieb am So., 24. Apr.
2016 14:04:
> Hi
>
> I need to insert a blank row after every row in R data frame. I have
> achieved it through:
>
>
>
2016 Apr 24
2
Inserting a blank row to every other row
Hi
I need to insert a blank row after every row in R data frame. I have achieved it through:
df[rep(1:nrow(df),1,each=2),]
But it inserts a row with name of previous row, while i want a complete blank row without any name/title.
Please guide me
Regards
Saba
2016 Apr 22
1
Finding Highest value in groups
Since the aggregate S3 method for class formula already has got na.action = na.omit,
## S3 method for class 'formula'
aggregate(formula, data, FUN, ...,
subset, na.action = na.omit)
I think that to deal with NA's, it is enough:
aggregate(Value~ID, dta, max)
Moreover, passing na.rm = FALSE/TRUE is "don't care":
aggregate(Value~ID, dta, max, na.rm=FALSE)
2009 Jun 03
1
strsplit for multiple columns
Hi,
I am trying to split multiple columns. One column works just fine, but I
want to do it for multiple columns???
Example
> a
ID V2 V3 V4 V5 V6 V7 V8 V9 V10
1 PBBA0644 -- GG AA -- AA -- AA GG GG
2 PBBA1010 -- GG AA -- AA -- AA GG GG
3 0127ATPR -- GG AA -- AA -- AA GG GG
4 0128EHAB -- GG AA -- AG -- AA AG GG
5 PBBA0829 -- GG AA -- AA -- AA GG AG
2013 Feb 11
2
Inserting rows of interpolated data
Dear help list - I have light data with 5-min time-stamps. I would like to insert four 1-min time-stamps between each row and interpolate the light data on each new row. To do this I have come up with the following code:
lightdata <- read.table("Test_light_data.csv", header = TRUE, sep = ",") # read data file into object "lightdata"
library(chron)
mins <-
2009 Aug 12
1
inserting into data frame gives "invalid factor level, NAs generated"
I am calculating some values that I am inserting into a data frame. From
what I have read, creating the dataframe ahead of time is more efficient,
since rbind (so far the only solution I have found to appending to a data
frame) is not very fast.
What I am doing is the following:
# create data frame
goframe = data.frame(goA = character(10), goB = character(10), value =
numeric(10))
goframe[1,] =
2011 Apr 20
3
Help needed!
Hi everyone,
I have a question. Now I am reading the resource code of the package
"ssfcov". The resource code is as following. I cannot find the resource
code of the function "myss2d" anywhere in the package. Can anyone give
me a hint how to find it in the package. Thanks a lot!!bv
> ssfcov
function (time, x, subject, nbasis = 5, centered = FALSE, noDiag = TRUE)
{
2009 Aug 12
0
Re : paste first row string onto every string in column
Try this , save your data in C:/
and write this
(data <- read.csv2("c:/jill.csv", sep=","))
(C<-data[1,])
A <- numeric(4)
B <- numeric(4)
for (i in 1 :4){
A[i] <- paste(data[1,i],data[2,i])
B[i] <- paste(data[1,i],data[3,i])
}
A
B
(data1 <- rbind(as.character(A),as.character(B)))
(data2 <- rbind(C,data1))
normaly that gives that
> (data <-
2009 Mar 04
0
inserting lines in large data set
Hello,
I need to insert a line after every eigth row (group/suset) which should
contains the following:
<(an incremented ID),0,1,1,1,1>
I have two problems with constructing my code:
1. I am getting NAs in three of the columns and
2) I can not find a way to write the ID (group name) at the beginning of the
inserted line.
Below the # sign I show one of the ways I tried from a variation
2011 Dec 05
0
Rggobi pdf output
Good day everyone. I have a question concerning *ggobi* and
*rggobi*package. I am using R version 2.13.2 and Ubuntu 11.04. I am
new to ggobi
and I'm reading the book *Interactive and Dynamic Graphics for Data Analysis
*. The book was published 2007.
My question is: how can I export a graph for *rggobi* to pdf to include it
in latex. For example: I have lots of variables in ggobi and I need to
2011 Dec 05
1
[rggobi] ggplot like pdf output
Good day everyone. I have a question concerning *ggobi* and
*rggobi*package. I am using R version 2.13.2 and Ubuntu 11.04. I am
new to ggobi
and I'm reading the book *Interactive and Dynamic Graphics for Data Analysis
*. The book was published 2007.
My question is: how can I export a graph for *rggobi* to pdf to include it
in latex. For example: I have lots of variables in ggobi and I need to
2008 Oct 21
2
Inserting a new row in a matrix
Hi guys,
I need to insert a row to a matrix in a for loop. I have matrix named "Avg"
which is a 5x4 matrix of zeros.
I have a file named "A"(4 rows,14 columns) which I make a sample of it 5
times. each time I get the mean for each column and put the result in the
"Avg" matrix. this is my code:
Avg=matrix(0,5,4)
>
> for(i in 1:5){
+ res=(A[sample(nrow(A),
2010 Sep 10
4
Counting occurances of a letter by a factor
I'm trying to find a more elegant way of doing this. What I'm trying to accomplish is to count the frequency of letters (major / minor alleles) in a string grouped by the factor levels in another column of my data frame.
Ex.
> DF<-data.frame(c("CC", "CC", NA, "CG", "GG", "GC"), c("L", "U", "L",
2013 Jan 02
0
How to use geom_line (from ggplot) with aesthetics in a function?
Hello,
I have been struggling with this for a while, tried a few things, but no
clean solution so far. Here is an example from the documentation for
geom_line:
==========================================
# Summarise number of movie ratings by year of movie
mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
nums <- tapply(df$length, df$year, length)
2011 Nov 20
1
Inserting blank records in a barplot
Hi everyone,
I currently do some statistics about my heart rate variability. I've a CSV
file which looks like this:
Date Time ts_mean_RR ts_sdnn_RR ts_mean_HR ts_sdnn_HR ts_rmssd
1 20110905 07:21:50.0 1139.8298 40.3053 52.7393 2.2824 45.7958
2 20110906 07:11:37.0 1182.7333 49.1861 50.8665 2.4983 60.2329
3 20110907 07:21:31.0 1136.6028 49.4682 52.9566
2011 Oct 27
2
Consistant test for NAs in a factor when exclude = NULL?
Dear folks?
Is there a function to correctly find (and count) the NAs in a factor when
exclude=NULL, regardless of whether their origin is in the original data or
by subsequent assignment?
In example number 1 below, where NAs are assigned by is.na()<-, testing the
factor with is.na() finds the correct number of NAs. In example number 2,
where the NAs are from the data, neither is.na(), ==NA,
2006 Aug 31
2
Combine 'overlapping' dataframes, respecting row names
Hi,
I've examined the archives and found quite a few questions on
concatenating dataframes, but none that really addressed my issue,
I'm afraid. I've also examined the cbind and rbind documentation but
nonetheless here I am writing to r-help ;)
This is what I have (the row names are dates used for conversion to
an irregular time series with the its package):
> cvsFrame
2013 May 22
0
calcul of the mean in a period of time
Hi,
I guess you meant this:
dat2<- read.table(text="
patient_id????? t???????? scores
1????????????????????? 0??????????????? 1.6
1????????????????????? 1??????????????? 2.6
1????????????????????? 2???????????????? 2.2
1????????????????????? 3???????????????? 1.8
2????????????????????? 0????????????????? 2.3
2?????????????????????? 2???????????????? 2.5
2?????????????????????