similar to: I() in data.frames

Displaying 20 results from an estimated 90000 matches similar to: "I() in data.frames"

2013 Feb 08
1
Merging and Updating Data Frames with Unequal Size
Dear All, I am trying to merge 2 dataframes of with different sizes. Let's say that one dataframe R contains some raw data and another data frame F contains the information to fix R. For instance F <- data.frame(cbind(x=-seq(10), y=1:10, z=3:12, w=8:17, p=18 )) R <-
2023 Oct 26
1
Bug in print for data frames?
On 25/10/2023 2:18 a.m., Christian Asseburg wrote: > Hi! I came across this unexpected behaviour in R. First I thought it was a bug in the assignment operator <- but now I think it's maybe a bug in the way data frames are being printed. What do you think? > > Using R 4.3.1: > >> x <- data.frame(A = 1, B = 2, C = 3) >> y <- data.frame(A = 1) >> x >
1999 Feb 02
0
Re: glm and data.frames (PR#108)
jlindsey at alpha.luc.ac.be writes: > The following is a bug or feature in recent versions. Try the > following with a clean workspace: > > y <- cbind(rpois(20,4),rpois(20,4)) > df <- data.frame(y=y,x=rnorm(20)) > colnames(df) > colnames(model.frame(y~x,data=df)) > > Now start over with a clean workspace and try > > df <-
2009 Aug 09
3
howto get the number of columns and column names of multiply data frames
Hi, I' ve read in several files with measurements into R data frames(works flawlessly). Each dataframe is named by the location of measurement and contains hundreds of rows and about 50 columns like this dataframe1. date measurment_1 .... mesurement_n 1 2 3 .. .. .. n For further processing I need to check whether or not ncol and colnames are the same for all dataframes. Also I need to
2012 Nov 17
2
Using cbind to combine data frames and preserve header/names
I have a dataframe that has a header like so: class value1 value2 value3 class is a factor the actual values in the columns value1, value2 and value3 are 0-255, I wish to binarize these using biclust. I can do this like so: binarize(dataframe[,-1]) this will return a dataframe, but then I lose my first column class, so I thought I could combine it like so: dataframe <-
2007 Jan 24
1
how to properly extend s3 data.frames with s4 classes?
Dear R Programmers! After some time of using R I decided to work through John Chambers book "Programming with Data" to learn what these S4 classes are all about and how they work in R. (I regret not having picked up this rather fine book earlier!) I know from the documentation and the mailing archives that S4 in R is not 100% the book and that there are issues especially with
2010 Mar 05
1
Error in inherits(x, "data.frame") : subscript out of bounds
Hi, I have a list p with different size dataframes and length of over 8000. I'm trying to calculate correlations between the rows of dataframes of this list and columns of another dataset (type data.frame also) so that first column is correlated with all the rows in the list dataframe. Some information from another dataset is also included to the final output (all.corrs). This worked a
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, The obvious way would be to preallocate the resulting data.frame, to expand an empty one on each iteration being a time expensive operation. n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D4 <- data.frame(distance=integer(n),difference=integer(n)) k <- 0 for (i in 1:nrow(D1)){ for (j in 1:nrow(D2)) { k <- k + 1 D4[k, ] <-
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
You appear to be trying to write C code in R. Don't do this. If you can trade off space for efficiency, the calculation can be easily vectorized (assuming I correctly understand what you want to do, of course). set.seed(135) ## for reproducibility D1<-data.frame(x=1:5,y=6:10,z=rnorm(5)) D2<-data.frame(x=19:30,y=41:52,z=rnorm(12)) D.all <-merge(D1,D2, by.x=NULL,by.y=NULL) ##
2013 May 02
3
R issue with unequal large data frames with multiple columns
I'm a bit of an amateur R programmer. I can do simple R scenarios but my handle on complex grammatical issues isn't steady. I have 12 CSV files that I've read into dataframes. Each has 8 columns and over 2000000 rows. Each dataframe has data associated by time component and a date component in the format of: X.DATE and then X.TIME X.DATE is in the format of MMDDYYYY and X.TIME is
2012 Jan 06
1
(Edited) cbind alternate for data frames
> > I have two dataframes and want to perform cbind and then write into a > file. The number of entries are more than a million in both frames. R is > taking a lot of time performing this operation. > > Is there any alternate way to perform cbind? > > x = table1[1:1000000,1:4] > y = table2[1:1000000,3:6] > > z = cbind(x,y) //hanging the machine > >
2010 Dec 29
0
Simulating data and imputation
Hi, I wrote a script in order to simulate data, which I will use for evaluating missing data and imputation. However, I'm having trouble with the last part of my script, in which a dataframe is constructed without missing values. This is my script: y1 <- rnorm(10,0,3) y2 <- rnorm(10,3,3) y3 <- rnorm(10,3,3) y4 <- rnorm(10,6,3) y <- c(y1,y2,y3,y4) a1 <-rep(1,20) a2
2010 Apr 22
2
Compare two data frames
I wonder if there is a more efficient way to do this task. Suppose I have two data frames, such as d1 <- data.frame(x = c(1,2,3), y = c(4,5,6), z = c(7,8,9)) d2 <- d1[, c('y', 'x')] The first dataframe d1 has more variables than d2 and the variable columns are in a different order. So, what I want to do is compare the two frames on the variables that are common between
2017 Jun 23
1
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, Another way would be n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D5 <- data.frame(distance=integer(n),difference=integer(n)) D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) t(sapply(seq_len(nrow(D2)), function(j){ c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2) } )))) identical(D3, D5) In my first answer I forgot to say that
2008 Jan 13
1
Trying to write Merge for more data.frames - Error in match.names(clabs, names(xi))
Dear list members, I would like to merge multiple dataframes and seems that this task is going to be required quite often, so I decided to write a simple (pseudo)recursive merge. I started with the case when dataframes are merged by rows (0). But there is a problem when a dataframe to be merged in the step n has some items that are not in previous ones. Then I get "Error in match.names(clabs,
2010 Nov 24
3
apply over list of data.frames
R users, This probably involves a simple incantation of one of the flavors of apply... that I can't yet figure out. Consider a list of data frames. I'd like to apply a function (mean) across the list and return a dataframe of the same dimensions where each cell represents the mean of that cell across all dataframes. # set up the list x <- vector("list",2) names(x) <-
2017 Jun 23
4
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
For certain reason, the content was not visible in the last mail, so posting it again. Dear Members, I have two different dataframes with a different number of rows. I need to apply a set of functions to each possible combination of rows with one row coming from 1st dataframe and other from 2nd dataframe. Though I am able to perform this task using for loops, I feel that there must be a more
2010 Nov 16
0
renaming a list of data frames y calculating with lapply
Hello everyone I'm a new R user and have some questions about lists indexing, names and the lapply function. first have a look to my data (names changed) it's a rainfall record for 67 stations, str(data) List of 67 $ e9999.somename.xx.txt :'data.frame': 456 obs. of 5 variables: ..$ Y : int [1:456] 1960 1960 1960 1960 1960 1960 1960 1960 1960 1960 ... ..$
2008 Dec 28
2
Conditional operation on multiple columns from two data frames
Hi- I have two data frames for which I wish to conditionally subtract the values of one dataframe from the other. I want to subtract df1$x from df2$x when their id is equal and the absolute value of difference between the dates is 12 hours or less. If there is no match of equal id's and dates less than 12 hours apart I want it to return "NA". Note that df1 has missing values in x
2012 Jan 30
1
mgcv bam() with grouped binomial data
Hello, I'm trying to use the bam() function in the R mgcv package for a large set of grouped binary data. However, I have found that this function does not take data in the format of cbind(numerator, denominator) on the left hand side of the formula. As an example, consider the following dat1 <- data.frame(id=rep(1:6, each=3), num=rbinom(18, size=10, prob=0.8), den=rbinom(18, size=5,