similar to: Combining logical operators to extract columns from a dataframe

Displaying 20 results from an estimated 10000 matches similar to: "Combining logical operators to extract columns from a dataframe"

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
2013 Mar 12
5
extract values
Hello all! I have a problem to extract values greater that for example 1820. I try this code: x[x[,1]>1820,]->x1 Please help me! Thank you! The data structure is: structure(c(2.576, 1.728, 3.434, 2.187, 1.928, 1.886, 1.2425, 1.23, 1.075, 1.1785, 1.186, 1.165, 1.732, 1.517, 1.4095, 1.074, 1.618, 1.677, 1.845, 1.594, 1.6655, 1.1605, 1.425, 1.099, 1.007, 1.1795, 1.3855, 1.4065, 1.138, 1.514,
2010 Nov 24
5
Performance tuning tips when working with wide datasets
Does anyone have any performance tuning tips when working with datasets that are extremely wide (e.g. 20,000 columns)? In particular, I am trying to perform a merge like below: merged_data <- merge(data1, data2, by.x="date",by.y="date",all=TRUE,sort=TRUE); This statement takes about 8 hours to execute on a pretty fast machine. The dataset data1 contains daily data going
2008 Nov 04
1
perform Kruskal-Wallis test without using the built-in command in R
Hi, again i am stuck in my presentation, and i have never learn R before in my life but need this to be done, so please help me out for a favour: http://www.nabble.com/file/p20333155/kew.dat kew.dat run this in R and these comes up: Month Year Rain 1 Jan 1900 74.400000 2 Feb 1900 80.500000 3 Mar 1900 23.600000 4 Apr 1900 23.600000 5 May 1900 25.100000 6
2009 Jan 23
2
Dates in Common
I have two collections of dates and I want to figure out what dates they have in common. This is not giving me what I want (I don't know what it is giving me). What is the best way to do this? Tom > data1 [1] "1948-02-24 EST" "1949-04-12 EST" "1950-05-29 EDT" "1951-05-21 EDT" [5] "1951-12-20 EST" "1953-01-22 EST"
2007 Jul 19
3
help with heatmap - how to remove annoying "X" before numeric values?
Hello All, I have a simple question based on how things are labeled on my heat map; particularly, there is this annoying "X" that appears before the numeric value of all the labels of my columns. Let's say I have the following silly data, stored in "temp.txt" 1905 1910 1950 1992 2011 2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake
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
2004 May 27
4
extract columns using their names
Hello, Is there a way to extract multiple columns from a dataframe using their names instead of their numbers? Currently I use: data2 <- data1[, c(1,3,9)] And I am looking for something like data2 <- data1[, c("XX","YY","ZZ")] I use the same dataframe for many purposes, and I run codes that change the order of the columns every time. Many thanks, Adrian
2019 May 04
2
read.table() fails with https in R 3.6 but not in R 3.5
In versions of R prior to 3.6.0 the following invocation succeeds, returning the data frame shown: > read.table("https://www.dwds.de/r/stat?corpus=kern&cnt=tokens&date=decade&format=text", header=TRUE) Dekade Anzahl 1 1900 11467254 2 1910 13023370 3 1920 13434601 4 1930 13296355 5 1940 12121250 6 1950 13191131 7 1960 10587420 8 1970 10944129 9
2010 Sep 06
1
combining collumns for data.frames
Hi This question is far less simple than the title suggests, please read carefully, thanks. I have 2 sets of data, both read into R >data1<-read.table ("1.txt", header=T, sep="\t") >data2<-read.table ("2.txt", header=T, sep="\t") >data1 Taxon stage1 stage2 stage3 stage4 T1 0 0 1 1 T2 0
2009 Jul 23
3
How to perform a calculation in each element of my list?
Hi R-helpers, I have a list containing 10 elements, each of which is a dataframe. I wish to add a new column to each list element (dataframe) containing the product of the last two columns of each dataframe. I'd appreciate any pointers, thanks! Mark Na [[alternative HTML version deleted]]
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
2009 Jul 09
2
How to combine two rows (in a dataframe) into a third row?
Dear R-helpers, I have two rows in my dataframe: ID VALUE 1A 10 1B 15 and I would like to combine these two rows into a single (new) row in my dataframe: ID VALUE 1 25 ...simply by specifying a new value for ID and summing the two VALUES. I have been trying to do this with with rbind, but it's not working. I'd appreciate any pointers. Thanks, Mark Na [[alternative
2009 Jun 16
3
How to extract all rows that contain the value of X in any column?
Hi R-helpers, I'm trying to use this code > pvh_dnv<-pvh[sapply(pvh=="dnv"),] to make a new dataframe containing the rows from pvh that contain the value of "dnv" in ANY column. But, it's not working. I get this error Error in match.fun(FUN) : element 1 is empty; the part of the args list of 'is.function' being evaluated was: (FUN) which, to
2013 Mar 13
2
merge datas
Hello all! I have a problem with R. I try to merge data like this: structure(c(2.1785, 1.868, 2.1855, 2.5175, 2.025, 2.435, 1.809, 1.628, 1.327, 1.3485, 1.4335, 2.052, 2.2465, 2.151, 1.7945, 1.79, 1.6055, 1.616, 1.633, 1.665, 2.002, 2.152, 1.736, 1.7985, 1.9155, 1.7135, 1.548, 1.568, 1.713, 2.079, 1.875, 2.12, 2.072, 1.906, 1.4645, 1.3025, 1.407, 1.5445, 1.437, 1.463, 1.5235, 1.609, 1.738, 1.478,
2009 Jul 23
2
Antw: How to extract the upper xlim and ylim of my plot?
You may want to use the function corner.label from the plotrix-package. Frank >>> Mark Na <mtb954@gmail.com> 21.07.2009 23:03 >>> Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e. > plot(log(all$SR,10)~log(all$AREA,10)) > text(.1*max(xlim),.9*max(ylim),"text to be placed") (I know
2012 Dec 17
1
subset handling
Dear Rui and UseRs,[a text file has also been attached, in case the format of my email is difficult to get]I am extremely sorry that I am bothering you once again, but I?ll have to get to the bottom of it. The following command sp <- lapply(split(agg, agg$st), function(x) x[order(x$year, x$month), ]) gave me an output with monthly mean of population(as under). i am not able to apply
2013 Apr 07
2
group data in classes
Hello all! I have a problem to group my data (years) in 10 years classes. For example for year year decade 1598 1590-1600 1599 1590-1600 1600 1590-1600 1601 1600-1610 --- my is like this> [1] 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 [16] 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 [31] 1628 1629 1630 1631 1632 1633
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]]
2003 Nov 19
5
ISOdate returns incorrect date?
Dear all, I have found the following (for me) incomprehensible behaviour of ISOdate (POSIXct): > ISOdate(1900,6,16) [1] "1900-06-15 14:00:00 Westeurop?ische Sommerzeit" > ISOdate(1950,6,16) [1] "1950-06-16 14:00:00 Westeurop?ische Sommerzeit" Note that in the first case I get the 15th of June back, not the 16th as I would have expected! This happened under R-1.7.1 on