search for: dataframes

Displaying 20 results from an estimated 4801 matches for "dataframes".

2010 Apr 28
7
operator problem within function
Dear all, i have a problem with processing dataframes within a function using the "$". HereĀ“s my code: recode_items = function(dataframe,number,medium=2){ # this works q<-paste("columna",number,sep="") # this does not work, particularly because "dataframe" is not processed # dataframe should be: give...
2006 Nov 08
2
combining dataframes with different numbers of columns
Dear list members, I have to combine dataframes together. However they contain different numbers of variables. It is possible that all the variables in the dataframe with fewer variables are contained in the dataframe with more variables, though it is not always the case. There are key variables identifying observations. These could be us...
2006 Feb 25
2
Adding header lines to a dataframe that is exported using write.csv
I would like to export a dataframe to a .csv using: >write.csv(dataframe,"dataframe.csv") but I need to add four "header" lines to the csv that are not part of the dataframe (which itself has a line of column headers). The difficulty (for me, at least!) lies in the requirement that certain elements of the header (X, Y and the number of "Q"s - please see example
2009 Mar 23
1
Confusion regarding environments invoked by "source" command
Colleagues, R version 2.8.1 in OS X Within a function (which is already within a function), I am sourcing a file. The syntax of the command is something like (this is just an example; the actual code is much more complicated): BIGFUNCTION <- function() { DATAFRAME <- [some commands to create a dataframe] MYFUNCTION(DATAFRAME) } MYFUNCTION <- function(DATAFRAME) { print(ls())
2008 Oct 26
3
Process dataframes from list
Hi all, I have roughly fifty dataframes and a dataframe with the names of the fifty dataframes. I want to perform the same set of manipulations on all fifty dataframes, but can't find a way to batch process from a list with the dataframe names using a loop. Is there a way to read the file names from the dataframe with the names and...
2011 Jun 30
1
Match strings across two differently sized dataframes and copy corresponding row to dataframe
Hello- Sorry, this is a bit of a noob question, but I can't seem to progress it any further. I have two dataframes which contain a series of strings which exactly match. The problem is one has more rows than the other (more cases have been added) and they have been sorted so that they are not in the same order. The smaller dataframe, though, contains in another column which has codes classifying the strings. S...
2011 Apr 01
3
programming: telling a function where to look for the entered variables
...here, Could someone help me with the following programming problem..? I have written a function that works for my intended purpose, but it is quite closely tied to a particular dataframe and the names of the variables in this dataframe. However, I'd like to use the same function for different dataframes and variables. My problem is that I'm not quite sure how to tell my function in which dataframe the entered variables are located. Here's some reproducible data and the function: # create reproducible data set.seed(124) xvar <- sample(0:3, 1000, replace = T) yvar <- sample(0:1, 1000...
2012 Dec 11
5
Renaming column names according to another dataframe
...and lots of rows), the first containing the code and the second some Text (real name). Now I'd like to use the information (pairs of code and name) of the second dataframe to rename all the columnnames in the first dataframe. How is it possible to achieve that? Here a small example of the two dataframes: df <- data.frame(A=(1:10),B=(1:10),C=(1:10)) df_names <- data.frame(code=c("A","B","C","D","E"),name=c("Col A","Col B","Col C","Col D","Col E")) /j
2011 Oct 07
2
Merge dataframes
...1.8 2.4 3) Next, I add a new variable from this dataframe: height width color 1 1.1 2.3 red 3 1.8 1.9 red 5 1.8 2.4 blue 4) So, I want to merge those dataframes, so that the new variable, color, is binded to the first dataframe. Of course some cases won't have value for it, since I generated this variable in a smaller dataframe. In those cases I want the value to be NA. The result dataframe should be: height width color 1...
2018 Apr 21
2
Check if row of dataframe is superset of any row in another dataframe.
Hi, I am looking for a way in which I can check if rows in 1 dataframe are present in another data frame in a unique way. A row in dataframe should be super set of any row in another dataframe. I can write a for loop for it, however, that will be inefficient. So, I am looking for an efficient way to do this in R. I have explained it with an example below: I want to check if a row in dataframe
2007 May 14
2
creating a "list of 3 dataframes" from a "list of 2 dataframes" and a dataframe?
#I wish to create a "list of three dataframes" ("results2") from a "list of two dataframes" (temp) and a dataframe ("c")? #Please advise. a <- data.frame(x=c(1,2,3),y=c(5,7,9)) b <- data.frame(x=c(2,4,7,9),y=c(2,3,5,4)) c <- data.frame(x=c(22,34,7,9),y=c(52,63,5,4)) results1 <- list(a,b,c) #wha...
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 <...
2003 May 18
1
How to split a dataframe into smaller constituent dataframes
I have read a large dataset into a dataframe using RODBC, the rows of data in the dataframe are (integer) timestamped and I would like to divide the original dataframe into n smaller dataframes where dataframe 1 contains all rows that had timestamps falling in the period 0-x1 minutes, dataframe 2 contains all rows that had timestamps falling between x1+1 and x2, etc.. Does anyone know how to do this? Thanks _________________________________________________________________ Overloaded...
2009 Oct 13
2
splitting dataframe, assign to new dataframe, add new rows to new dataframe
..."df", j, sep=""), picked) #assign(paste("df",j, sep=""), paste("df", j, sep="")) } } The problem is that the assign function overwrites the previous value of df and therefore the I have not been able to insert rows in the three df dataframes and always end up with only 1 (final) row in df1, df2 and df3. I have tried using rbind but was not able to assign values back to the "on-the-fly" variable names. I really need your advice and assistance since I have stuck with this for some time now. Thank you.
2009 May 10
1
Select the rows in a dataframe that matches a criteria in another dataframe
Hi everyone! Thank you for the help you have been given to me, and here I'm with another problem with my dataframes: I have two dataframes (with much more observations), like these: Dataframe1 Firm Year cash 500400200 2007 100 500400200 2006 200 500400200 2005 400 500400300 2007 300 500400300 2006 240 500400300 2005 120 500400400 2007 340 50040040...
2003 Apr 07
5
How to sort a dataframe?
Dear R-helpers, for the purpose of plotting a dataframe, i am trying to sort a dataframe by one column, for example tester <- data.frame(one=c(3,2,1), two=c(2,3,1)) #> tester # one two #1 3 2 #2 2 3 #3 1 1 # I want to sort "tester" by column "one", so that i get a dataframe # that looks like: #one two #1 1 #2 3 #3 2 I know of 'sort' but
2005 May 26
2
Q: changing the class of an object
Dear All, I have a list of dataframes, each cell in every dataframe (after I have cleaned up the dataframes) is either real or NA but have class character (I think). I would like to know how to change the class of every cell without using a for-loop. I currently have this dataframes <- sapply(1: no.of.subs, function(k) apply(dataf...
2010 Mar 25
4
Creating dataframe of all possible variable combinations
Hello, I need to create a dataframe containing all possible combinations of three variables: SITE (101,102,103,104), WDAY (MON,TUE,WED,THR,FRI), and TOD (MORN, AFTN). There should be a total of 40 unique combinations in my dataframe. I used expand.grid() successfully(?) to create my dataframe, but then when I went to order it by SITE, the resultant dataframe only contained four rows, one for each
2011 Feb 09
3
Need help merging two dataframes
...female subadult LP 03 male subadult MR ... Hopefully this all makes sense and someone knows a solution. Thanks in advance for taking a look at my problem and helping out (I hope!). Nathaniel -- View this message in context: http://r.789695.n4.nabble.com/Need-help-merging-two-dataframes-tp3297313p3297313.html Sent from the R help mailing list archive at Nabble.com.
2012 Feb 08
2
Split dataframe into new dataframes
Hi, I want to split a dataframe based on a grouping variable (in one column). The resulting new dataframes should be stored in a new variable. I tried to split the dataframe using split() and to store it using a FOR loop, but thats not working so far: df <- data.frame(A=c("A1","A1","A2","A2"),B=seq(1:4)) Fsplit <- function(x,y){ ls <- split(x,f=x$y) f...