Thank you Jim and Don.
On Monday, November 21, 2016 4:54 PM, Jim Lemon
wrote:
Hi Olu,
If you always have only one non-NA value in the first three columns:
veg_df<-data.frame(col1=c(NA,"cassava","yam",NA,NA,NA,"maize"),
col2=c("pumpkin",NA,NA,"cherry",NA,NA,NA),
col3=c(NA,NA,NA,NA,"pe
Something along the lines of
tmpfun <- function(chvec) chvec[!is.na(chvec)]
apply( mydata, 1, tmpfun)
Assuming every row has only one non-NA entry.
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 11/21/16, 1:26 PM, "R-hel
Hi Olu,
If you always have only one non-NA value in the first three columns:
veg_df<-data.frame(col1=c(NA,"cassava","yam",NA,NA,NA,"maize"),
col2=c("pumpkin",NA,NA,"cherry",NA,NA,NA),
col3=c(NA,NA,NA,NA,"pepper","mango",NA))
veg_df$col4<-apply(as.matrix(veg_df),1,function(x) x[!is.na(x)])
Jim
Hello,
Try the following.
dat <- read.table(text = "
| colA | colB | colC | colD |
| NA | pumpkin | NA | Pumpkin |
| Cassava | NA | NA | Cassava |
| yam | NA | NA | yam |
| NA | Cherry | NA | Cherry |
| NA | NA | Pepper | Pepper |
| NA | NA | Mango | Mango |
| maize | NA | NA | maize |
", header
Hello,I have the following data
| colA | colB | colC | colD |
| NA | pumpkin | NA | Pumpkin |
| Cassava | NA | NA | Cassava |
| yam | NA | NA | yam |
| NA | Cherry | NA | Cherry |
| NA | NA | Pepper | Pepper |
| NA | NA | Mango | Mango |
| maize | NA | NA | maize |
All I want to do is to combine
Thanks Thierry, you made my day :)
On 21 July 2015 at 17:00, Thierry Onkelinx wrote:
> Please always keep the mailing list in cc.
>
> If mat is a data.frame, then you can use do.call. Then the number of
> columns doesn't matter.
>
> do.call(paste, mtcars[, c("mpg", "cyl")])
> do.call(paste, mtc
Please always keep the mailing list in cc.
If mat is a data.frame, then you can use do.call. Then the number of
columns doesn't matter.
do.call(paste, mtcars[, c("mpg", "cyl")])
do.call(paste, mtcars[, c("mpg", "cyl", "disp")])
do.call(paste, mtcars)
ir. Thierry Onkelinx
Instituut voor natuur-
Yes. paste0() can work on vectors. So paste0(mat[, col1], mat[, col2])
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
To call in t
Hi,
The answer to this is probably straightforward, I have a dataframe and I'd
like to build an index of column combinations, e.g.
col1 col2 --> col3 (the index I need)
A 1 1
A 1 1
A 2 2
B 1 3
B 2 4
B 2 4
At th
Dear Andrew,
Try this:
data.frame(z=c(a$a,b$c))
HTH,
Jorge
On Tue, Mar 17, 2009 at 5:55 PM, Andrew McFadden <
andrew.mcfad...@maf.govt.nz> wrote:
> I all
>
> I am trying to combine columns from two dataframes to make a completely
> new dataframe consisting of one column of dates (ie a combinat
age-
From: r-help-boun...@r-project.org on behalf of Andrew McFadden
Sent: Tue 3/17/2009 2:55 PM
To: r-help@r-project.org
Subject: [R] Combining columns from two dataframes
I all
I am trying to combine columns from two dataframes to make a
completely
new dataframe consisting of one colum
5 PM
To: r-help@r-project.org
Subject: [R] Combining columns from two dataframes
I all
I am trying to combine columns from two dataframes to make a completely
new dataframe consisting of one column of dates (ie a combination of
dates from the two dataframes).
>From the following dataframes
I all
I am trying to combine columns from two dataframes to make a completely
new dataframe consisting of one column of dates (ie a combination of
dates from the two dataframes).
>From the following dataframes
a b
1 2008-07-27 1
2 2008-10-01 2
3 2008-08-15 3
4 2008-08-14 4
5 2008-08-14 5
6
13 matches
Mail list logo