search for: newcolumn

Displaying 11 results from an estimated 11 matches for "newcolumn".

2012 Jul 24
5
First value in a row
...is likely a trivial problem but have not found a solution. Imagine the following dataframe: Lat Lon x1 x2 x3 01 10 NA NA .1 01 11 NA .2 .3 01 12 .4 .5 .6 I want to generate another column that consist of the first value in each row from columns x1 to x3. That is NewColumn .1 .2 .4 Any input greatly appreciated, Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii
2012 Jun 10
3
Data.frames can not hold objects...What can be done in the following scenario?
R-Help community, I understand that data.frames can hold elements of type double, string etc but NOT objects (such as a matrix etc). This is not convenient for me in the following situation. I have a function that takes 2 inputs and returns a vector: testfun <- function (x,y) seq(x,y,1) I have a data.frame defined as follows: testframe<-data.frame(xvalues=c(2,3),yvalues=c(4,5)) I would
2018 May 10
3
Fill down a new column in data frame with a number
Hi, I am a begginer in R programming. I am traying to create a a column in my data frame filled down with a number. > df$newcolumn <- number How can I do it? I am considering use rep() but in this case it is necessary know the number of rows in each data base that I have and I would like to do it in a faster ( and more elegant) way. TKs [[alternative HTML version deleted]]
2013 Jan 08
1
incrementation within ifelse
Dear R-helper, I am working on a very large data frame and I am trying to add a new column and write in it with certain conditions. I have try to use this code with the data frame p : ID = 0 p[,"newColumn"]<- ifelse (p$flagFoehn3_durr == 1, ifelse(p$Guetsch == 0, ID <<- ID ++ , ID ) , 0 ) What I am trying to do is to increment the ID when p$Guetsch == 0 and to put this result in the column. The problem is that ID does not...
2007 Dec 06
0
alternatives to latex() or xtable()
...others.selector=rep(TRUE,length(indices)) others.selector[length(indices):indexnum]=FALSE numcombinations.others = prod(unlist(subset(lapply(bynames,length), others.selector))) # Replicate each level of this index the number of existing combinations of other indices newcolumn=rep(bynames[[indexnum]],each=numcombinations.others) if(indexnum==length(indices)) { # first run by.df=data.frame(newcolumn) } if(indexnum!=length(indices)) { # newcolumn is too short by some multiple so we have to fix that newcolumn=rep(...
2011 Aug 01
1
Inserting column in between -- "better" way?
...via an R package. I leave it to you to define "essentially better." Thanks. Cheers, Bert On Mon, Aug 1, 2011 at 10:17 AM, Bert Gunter <bgunter at gene.com> wrote: > Doesn't work -- you lose column names. > > Try this instead: > > yourframe[,30:51] <- cbind( newcolumn,yourframe[,30:50]) > > Adjust column names after via: > > names(yourframe) [30:51] <- c(newcolname,names(yourframe[30:50]) > > Cheers, > Bert > > On Mon, Aug 1, 2011 at 10:10 AM, Sarah Goslee <sarah.goslee at gmail.com> wrote: >> x <- cbind(x[,1:29], new...
2017 Dec 14
1
match and new columns
Hi Bill, I put stringsAsFactors = FALSE still did not work. tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE ,stringsAsFactors = FALSE) tdat$D <- 0 tdat$E <- 0 tdat$D <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)) tdat$E <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0))
2010 Apr 24
1
Adding new column variable to a existing spreadsheet
Hi, I've got a csv format of file. There are seven columns of variables all together, and I've used the diff() function to take the differences between the variables in one column. Now I want to add the differences as the 8th column variable to the csv file. Is there any way that I can do this? Thanks in advance. Carol Gao [[alternative HTML version deleted]]
2003 May 31
5
parse on left hand side of R assignment
I keep finding myself in a situation where I want to calculate a variable name and then use it on the left hand side of an assignment. For example iteration <- 1 varName <- paste("run",iteration,sep="") myList$parse(text=varName) <- aColumn I want to take some existing variable "aColumn" and use the name "varName" name for it and put it into a
2012 May 25
4
Hash Table - Select and Change Data iniside Matrix
Hi, Here i have been a matrix like this, *NAME AGE PALCE TRUE/FALSE* ABC 20 INDIA XYZ 30 FRANCE PQR 40 USA MNO 30 KENIYA DEF 25 AUSTRALIA Here,* TRUE/FALSE* Column containing empty values. So my requirement what is , need to change all the *TRUE/FALSE *column value into "*TRUE*" where *AGE =
2012 Sep 28
4
Merging multiple columns into one column
Good Evening- I have a dataframe that has 10 columns that has a header and 7306 rows in each column, I want to combine these columns into one. I utilized the stack function but it only returned 3/4 of the data...my code is: where nfcuy_bw is the dataframe with 7305 obs. and 10 variables Once I apply this code I only receive a data frame with 58440 obs. of 2 variables, of which there should be