search for: newcols

Displaying 20 results from an estimated 39 matches for "newcols".

Did you mean: newcol
2010 May 17
1
suggestions/improvements for recoding strategy
I am recoding some data. Many values that should be 1.5 are recorded as 1-2. Some example data and my solution is below. I am curious about better approaches or any other suggestions. Thanks! # example input data myData <- read.table(textConnection("id, v1, v2, v3 a,1,2,3 b,1-2,,3-4 c,,3,4"),header=TRUE,sep=",") closeAllConnections() # the first column is IDs so remove
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
Full_Name: Steven McKinney Version: 2.9.0 OS: Mac OS X 10.5.6 Submission from: (NULL) (142.103.207.10) A corrupt data frame can be constructed as follows: foo <- matrix(1:12, nrow = 3) bar <- data.frame(foo) bar$NewCol <- foo[foo[, 1] == 4, 4] bar lapply(bar, length) > foo <- matrix(1:12, nrow = 3) > bar <- data.frame(foo) > bar$NewCol <- foo[foo[, 1] == 4, 4]
2006 Sep 13
7
inserting columns in the middle of a dataframe
Dear R users: Is there a built-in and simple way to insert new columns after other columns in a dataframe? I.e. currently I have: V1 V2 V3 V4 [1,] [2,] Etc. But I want V1 V5 V2 V3 V4 [1,] [2,] Etc. Can this be done in one line? Jon Minton [[alternative HTML version deleted]]
2018 Apr 15
4
Adding a new conditional column to a list of dataframes
Hi all .., I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes. When I extract one dataframe and apply my code it works very well as follows :- First suppose this is my first dataframe in the list > OneDF <- Mylist[[1]] > OneDF ID Pdate
2009 Apr 29
1
Corrupt data frame construction - bug?
Hi useRs, A recent coding infelicity along these lines yielded a corrupt data frame. foo <- matrix(1:12, nrow = 3) bar <- data.frame(foo) bar$NewCol <- foo[foo[, 1] == 4, 4] bar lapply(bar, length) > foo <- matrix(1:12, nrow = 3) > bar <- data.frame(foo) > bar$NewCol <- foo[foo[, 1] == 4, 4] > bar X1 X2 X3 X4 NewCol 1 1 4 7 10 <NA> 2 2 5 8 11
2010 Aug 09
1
creating pdf of wireframe
...details I have specified are not reproduced. For example, the line width I have specified is not reproduced, and neither are the font sizes for the axis labels. I'm an R novice, so I could really use some guidance. Here is the code I am using (post1, post2, post3 are 3-dimensional matrices): newcols <- colorRampPalette(c("grey90", "grey10")) #generates palette frome light to dark grey for better visibility trellis.device(pdf,file="PostAll.pdf", width = 5, height = 5) trellis.par.set("plot.line", list(lwd=0.15)); top.left <- wireframe(post1, xlab=...
2011 Aug 01
1
Inserting column in between -- "better" way?
Folks: I consider my reply below rather clumsy: One has to keep track of index numbers other than that which is inserted and must separately change column names. Is there as "essentially better" way to do this, either via base R or 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
2013 Jan 08
2
Applying a user-defined function
...above cut ()/quantile function to apply on different columns of the data frame > > CutQuintiles <- function(x) { + cut (test1$x,quantile (test1$x, (0:5/5)),include.lowest=TRUE) + } > > #apply the CutQuintile () on every odd-numbered columns of the "test1" data frame > newcols <- sapply(test1 [, seq (1,6,2)], CutQuintiles) Error in cut.default(test1$x, quantile(test1$x, (0:5/5)), include.lowest = TRUE) : 'x' must be numeric I would appreciate receiving your advice. Thanks, Pradip ###### The reproducible example begins here test1 <- read.table (text=...
2018 Apr 15
0
Adding a new conditional column to a list of dataframes
> On Apr 15, 2018, at 4:08 AM, Allaisone 1 <Allaisone1 at hotmail.com> wrote: > > > Hi all .., > > > I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes. > > > When I extract one dataframe and apply my code it works very well as
2009 Feb 02
2
concatenating 2 text columns in a data.frame
Hi, I'm trying to concatenate values from two columns in a data frame. For example, I have the following data.frame: C1 C2 C3 C4 C5 A B *F C* Q G H *I J* T K D *R S* E P L *M N* O I'd like to concatenate text from columns C3 and C4, to yield either a list or vector, like so: NewCol FC IJ RS MN Is this feasible in R? Thanks!
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All I have a datafram which looks like this : CustomerID DietType 1 a 1 c 1 b 2 f 2 a 3 j 4 c 4 c 4 f And I would like to reshape this so I can
2007 Mar 12
1
How to modify a column of a matrix
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070312/5b30b712/attachment.pl
2008 Aug 20
3
vector operation using regexpr?
Hi, Here's my problem... I have a data frame with three columns containing strings. The first columns is a simple character. I want to get the index of that character in the second column and use it to extract the item from the third column. I can do this using a scalar method. But I'm not finding a vector method. An example is below. col1 col2 col3 'L'
2002 Feb 09
1
How to access objects outside an R function
Dear R-Users, I have a dataframe (''forexdata'') of daily returns from the foreign exchange market for three currencies - British Pound (bp), Canadian Dollar(cd), Deustche Mark (dm) vis-a-vis the US Dollar and the Date Of Trade(yymmdd). For some dates the returns are missing (recorded as zero) as there were no trades in that currency for that date. My task is to substitute the
2010 Jul 06
2
grayscale wireframe??
I need grayscale formatting for a wireframe. The only col.regions that I can find are color palettes are all colored: rainbow(n, s = 1, v = 1, start = 0, end = max(1,n - 1)/n, gamma = 1, alpha = 1) heat.colors(n, alpha = 1) terrain.colors(n, alpha = 1) topo.colors(n, alpha = 1) cm.colors(n, alpha = 1) The code follows: X11() library(lattice) par(family="serif", cex=1.2)
2018 Feb 25
0
reshaping column items into rows per unique ID
Hi Allaisone, If you want a data frame as the output you will have to put up with a few NA values unless each Customer has the same number of diet types: a1df<-read.table(text="CustomerID DietType 1 a 1 c 1 b 2 f 2 a 3 j 4
2015 May 13
2
[LLVMdev] Modifying debug information through llvm pass
Hi All, I want to change debug information of an llvm instruction so that the modified debug info is subsequently passed to executable binary. So if I use "addr2line" utility on the binary, it will return my modified debug information. I've tried to change by using the following code snippet: MDNode *N = Inst->getMetadata("dbg"); DebugLoc Loc =
2011 Oct 24
1
Creating data frame with residuals of a data frame
Dear experts, I am trying to create a data frame from the residuals I get after having applied a linear regression to each column of a data frame, but I don't know how to create this data frame from the resulting list since the list has differing numbers of rows. So for example: age<- c(5,6,10,14,16,NA,18) value1<- c(30,70,40,50,NA,NA,NA) value2<- c(2,4,1,4,4,4,4) df<-
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame (presumably the "table" data structure you describe) can *not* contain "blanks" -- all columns must be the same length, which means NA's are filled in as needed. Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any local version of R (maybe it would in some server version --
2008 Aug 27
1
How to create additional columns?
I do have some data of dim 100*3 (i.e 100 rows and 3 columns ) stored in a txt file. I want to read the data into R, Perform the same operation in each row and store the result in a forth column( that I should create). I do not know how I can create a forth column to store the result of the operation for each row? -- View this message in context: