similar to: Retain only those records from a dataframe that exist in another dataframe

Displaying 20 results from an estimated 40000 matches similar to: "Retain only those records from a dataframe that exist in another dataframe"

2007 Mar 26
2
How to drop variables using a wildcard and logic...
Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter "t" I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]]
2011 Oct 08
1
How to write a list object's name to a new dataframe in that list object
Hello R-helpers, I have a list that only contains dataframes. Each element of the list (i.e., each dataframe) has a unique name ("one" through "ten"). I wish to add a new column (called "NAME") to each list element (i.e each datarame) and I want that column to contain the name of it's list element. e.g. the list element (i.e., dataframe) called "one"
2009 Dec 07
2
How to apply five lines of code to ten dataframes?
Hello R-helpers, I have 10 dataframes (named data1, data2, ... data10) and I would like to add 5 new columns to each dataframe using the following code: data1$LogDepth<-log10(data1[,2]/data1[,4]) data1$LogArea<-log10(data1[,3]/data1[,5]) data1$p<-2*data1[,6]/data1[,7] data1$Exp<-data1[,2]^(2/data1[,8]) data1$s<-data1[,3]/data1[,9] ...but I would prefer not to repeat this chunk of
2009 Jul 15
1
Averaging dataframes that are stored in a list
Dear R-helpers, I have a list containing 5000 elements, each element is a dataframe containing one ID column (identical over the 5000 dataframes) and 9 numeric variables, e.g. ID VAR1 VAR2 VAR3 ... VAR9 I would like to create a new dataframe containing the ID column and the mean values of the 9 numeric variables. So, the structure of this new dataframe would be identical to the structure of the
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
2009 Jun 17
2
How to translate a dataframe into the R code that makes that dataframe?
Hi, I am helping another R user (off list) and I would like to email her an R script containing the data she needs and the code to solve her problem. I have made a small dummy dataset, but instead of sending her a CSV I would prefer to send the data embedded in the script, so there would be a like in the script like: my.df<-c( etc, etc, etc I have made the dataframe (in a spreadsheet) and
2018 Mar 25
1
Get Specific Records from Another DataFrame
Hello I have been struggling with this simple looking problem. I have two dataframes. The first one contains ID, date, and revenue information for specific suppliers. id lastdate depvar A 5/10/2017 10 B 8/16/2017 20 C 2/14/2017 30 D 9/5/2017 40 E 8/1/2017 50 F 11/4/2017 60 G 6/22/2017 70 The second dataframe contains timeseries data of each supplier in different columns. For example Column A are
2006 Feb 24
2
Sorting a dataframe by one column?
Given the following dataframe: A=1:10 B=(a-5)^2 DATAFRAME=data.frame(A,B) How can I sort DATAFRAME increasing (or decreasing, for that matter) by B without making reference to A, or any other column? I've read ?order and ?sort but cannot seem to figure this out. Thank you. Mark
2009 Aug 06
1
problem with recording numeric output into another dataframe
dear all, I have two dataframes dataframe1 ID a b c dataframe2 ID value a;W 100 X;c 200 Y;Z 300 I wanted to match the IDs from the two dataframes and record the values into a new column of dataframe1 at the corresponding rows. This is what I expect: dataframe1 ID value a 100 b c 200 I tried doing it like this: for (i in seq(1:nrow(dataframe1))) {
2010 Dec 16
2
Compare two dataframes
Hello, I have two dataframes DF1 and DF2 that should be identical but are not (DF1 has some rows that aren't in DF2, and vice versa). I would like to produce a new dataframe DF3 containing rows in DF1 that aren't in DF2 (and similarly DF4 would contain rows in DF2 that aren't in DF1). I have a solution for this problem (see self contained example below) but it's awkward and
2008 Mar 25
2
Combining logical operators to extract columns from a dataframe
Hi R-helpers, I have a dataframe (called data) with 100 columns, the columns of which are named with integers ranging from 1900 to 1999. I wish to extract those columns which names are >=1950 and <=1970. I tried: data2<-subset(data,select=(names(data)>=1950 & names(data)<=1970)) but that doesn't work. Any ideas? Thanks! Mark [[alternative HTML version deleted]]
2008 Jan 08
1
retaining "POSIXct" formatting when using apply(muff, FUN=MAX) on POSIXct dataframe?
How do I retain "POSIXct" formatting when using apply, with FUN=max? #example: mydata <- rep(Sys.time(), 10) mydf <- data.frame(matrix(data=mydata, nrow=2, ncol=length(mydata) ) ) for(i in seq(mydf))class(mydf[[i]]) <- class(mydata) str(mydf) maxdates <- apply(mydf,2,max,na.rm=T) str(maxdates) #Why is the formattign now "chr", and not
2012 Dec 11
5
Renaming column names according to another dataframe
Hi, I've got a dataframe having a code as column name. Addtionally I have another dataframe with a two columns (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
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
2005 Feb 03
1
Efficient selection and alteration of dataframe records
Hi All, I am writing a simulation that examines the effects of species extinctions on ecological communties by sequentially removing individuals of a given species (sometimes using weighted probabilities) and replacing the lost individuals with species identities randomly sampled from the remaining individuals. Thus I use two dataframes. One contains all the individuals and their species
2012 Jun 01
1
Drop values of one dataframe based on the value of another
Hello all, Let me first say that this isn't a question about outliers. I am using the outlier function from the outliers package but I am using it only because it is a convenient wrapper to determine values that have the largest difference between itself and the sample mean. Where I am running into problems is that I am several groups where I want to calculate the "outlier" within
2009 Nov 24
2
How to identify the rows in my dataframe with a negative value in any column?
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091124/27851110/attachment-0001.pl>
2010 Dec 31
2
dataframe, simulating data
Dear all, I'm having trouble with my dataframe, and I hope someone can help me out... I have data from 40 subjects, displayed in a dataframe. I have randomly assigned subjects to group 1 or 0 (mar.y==0 or mar.y==1, with probabilities used). In the end, I want 34 cases assigned to group 0, with the rest of the subjects assigned to group 1. However, if there are more than 34 cases assigned to
2013 Jan 17
2
Naming an object after another object...can it be done?
Hello R-helpers, I have run the following line of code: x<-dat$col and now I would like to assign names(x) to be "dat$col" (e.g., a character string equal to the column name that I assigned to x). What I am trying to do is to assign columns in my dataframe to new objects called x and y. Then I will use x and y within a new function to make plots with informative axis labels (e.g.,
2007 Jan 31
1
FreePBX/Debian Aborts Call While Connecting
I used the "FreePBX on Debian" HowTo at http://powerontech.com/freepbx-on-debian.htm to install. I use callfiles to initiate calls to my SIP carrier. They get my registration, but they see that my call is interrupted before they can complete the connection. My Asterisk log shows that the call times out after the time (45s) specified in my dialplan Dial() command. What is wrong? [from