similar to: Help on efficiency/vectorization

Displaying 20 results from an estimated 20000 matches similar to: "Help on efficiency/vectorization"

2008 Dec 09
2
Need help optimizing/vectorizing nested loops
Hi, I'm analyzing a large number of large simulation datasets, and I've isolated one of the bottlenecks. Any help in speeding it up would be appreciated. `dat` is a dataframe of samples from a regular grid. The first two columns are the spatial coordinates of the samples, the remaining 20 columns are the abundances of species in each cell. I need to calculate the species richness in
2010 Aug 06
1
apply family functions
Hi all, I would like to flag each record in the data according to certain conditions as specified below. For example, If "Close_date" in *dat* is between ("Open" & "Close") or ("Open1" & "Close1") or ("Open2" & "Close2") in *oc, *flag the records as "Valid", otherwise "Invalid" I would like to
2006 Jun 23
1
looping through a data frame
Hi- I am having trouble with the syntax of looping through the rows and columns of a data frame. I have a table with 17 observations for 84 lines at n=5-10 per line. So the table is ~700x17. I want to pull out the median and stdev for each line and put it in a dataframe with rowname = linename. So I have tried the following.... #read in the table input.table <- read.table(file =
2010 Oct 04
3
How To Extract Row from A Data Frame
I have a data frame that looks like this: > print(df) V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 1 FN 8.637 28.890 31.430 31.052 29.878 33.215 32.728 32.187 29.305 31.462 2 FP 19.936 30.284 33.001 35.100 30.238 34.452 35.849 34.185 31.242 35.635 3 TN 0.000 17.190 16.460 21.100 17.960 15.120 17.200 17.190 15.270 15.310 4 TP 22.831 31.246 33.600 35.439 32.073
2013 Feb 15
3
datos climáticos cambio de formato
Hola!! tengo un data.frame donde cada fila corresponde a un año y cada columna a un mes (De enero a diciembre) > head(valT) V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 1941 18.0 16.3 15.2 10.1 8.1 8.3 8.8 9.2 7.9 12.2 11.9 14.6 1942 17.2 15.9 13.6 11.6 8.7 6.2 6.4 7.2 9.7 12.0 14.1 16.7 1943 17.6 17.3 13.5 12.5 10.5 7.0 8.2 7.9 -999.9 -999.9
2012 Jan 08
1
creating vectors from data-frames
I am having a problem with creating a vector from a rows or columns, I searched around and found as.vector(x), but it does not seem to do what it says it does I have included an example below, of doing what would seem to be the method required to create a vector, but instead it creates a one row data frame. What is required to actually create a vector. Many thanks Philip > data
2014 Jul 02
2
error al leer una linea desde un archivo de texto
A mi también me funciona para los dos casos: > dat <- read.csv("d11-16.csv", header=FALSE, sep=",", dec=".", skip=11, nrows=1) > dat V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 1 masa total en µg 30.04633 ug PEAKS MUY PEQUENOS NA NA NA NA NA NA NA > dat18 <- read.csv("d11-18.csv", header=FALSE,
2013 Feb 28
1
help for an R automated procedures
Dear, I would like to post the following question to the r-help on Nabble (thanks in advance for the attention, Gustavo Vieira): Hi there. I have a data set on hands with 5,220 cases and I'd like to automate some procedures (but I have almost no programming knowledge). The data has some continuous variables that are grouped by 2 others: the name of species and the locality where they were
2013 Apr 10
3
how to calculate average of each column
Hey All, I have a large dataset and I want to calculate the average of each column then return a new dataset. Here is my question: I dont know if there is a function that can allow me to calculate the average every 60 records of data in the whole dataset, and return a new data frame. Not sure if I have to divide the dataset first for every 60, then do the mean or can i directly do that. thanks
2005 Oct 13
1
expand.grid problem
Hi all, I want to make all possible combination from dataset below: V1 <- c(0,1,2) V2 <- c(0,1) V3 <- c(0,1) V4 <- c(0,1) V5 <- c(0,1) V6 <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) V7 <- c(0,1,2,3,4,5,6) V8 <- c(0,1) V9 <- c(0,1) V10 <- c(0,1) V11 <- c(0,1) V12 <- c(0,1) V13 <- c(0,1) V14
2009 Jun 12
3
Replacing 0s with NA
Hello I have a dataset in which I would like to replace 0s with NAs. There is a lot of information on how to replace NAs with 0, but I have struggled to find anything with regards to doing the reverse. Any recommendations would be great. Cheers Christine
2004 Aug 03
4
How to select a whole column? Thanks!
Dear all, I hope to remove a whole column from a data frame or matrix (> 2000 columns). All value in the column are same. The first thing is to select those columns. For instance, I hope to remove the V3~6 column, for all the value in those colume is zero. V3 V4 V5 V6 V7 V8 V9 V10 1 0 0 0 0 0.000 0.000 0.000 0.000 2 0 0 0 0 0.000 0.000 0.000 0.000 3 0 0 0
2009 Sep 11
2
Accumulating results from "for" loop in a list/array
Dear R users, I would like to accumulate objects generated from 'for' loop to a list or array. To illustrate the problem, arbitrary data set and script is shown below, x <- data.frame(a = c(rep("n",3),rep("y",2),rep("n",3),rep("y",2)), b = c(rep("y",2),rep("n",4),rep("y",3),"n"), c =
2012 Jun 15
8
Apply() on columns
Hi, I have some trouble with the following: I have a table of 7 rows and 6columns. The columns 1,2,3 have information about the number of employees. The columns 4,5,6 have information about the number of working hours. Each row, is corresponding with a week. My goal is to make a boxplot, histogram etc. of the columns 4, 5 and 6 (thus, the data of the number of working hours). How can I select by
2011 Sep 01
2
how to plot a series of data in a dataframe?
hi i have a dataframe with the name "obsdata" V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 1 1001 3 24 12 24.7 44.4 70.1 49.3 33.7 3.0 6.8 2.7 NA 2 1001 3 25 0 70.1 49.3 33.7 138.2 152.5 NA 4.2 6.9 17.5 3 1001 3 25 12 33.7 187.7 286.5 386.7 NA 16.2 46.0 48.8 43.1 4 1001 3 26 0 88.6 129.4 NA NA
2012 Aug 15
2
to remove columns and rows
Dear, I am using R I'm trying to identify and remove columns and rows in a data frame that are has elements equals. For example in dataframe below. The columns 1, 2,3,4,5 ,6 and 10 (file1) has elements equal then should be removed. How can I ask R to remove those columns with same elements in new dataframe (file2) to result a matrix as follows: file1 1 0 2 2 1 1 5 1 1 1 1 0
2005 Oct 28
3
replacing a factor value in a data frame
Hi All, I have the following problem, that's driving me mad. I have a dataframe of factors, from a genetic scan of SNPs. I DO have NAs in the dataframe, which would look like: V4 V5 V6 V7 V8 V9 V10 1 TT GG TT AC AG AG TT 2 AT CC TT AA AA AA TT 3 AT CC TT AC AA <NA> TT 4 TT CC TT AA AA AA TT 5 AT CG TT CC AA AA TT 6 TT CC TT AA AA AA TT 7 AT CC
2015 Aug 22
3
sprintf error: "only 100 arguments allowed"
I'm trying to apply a function defined in the VW R docs, that attemps to convert a data.table object to Vowpal Wabbit format. In the process i'm getting the error in printf mentioned in the subject. The original function is here: https://github.com/JohnLangford/vowpal_wabbit/blob/master/R/dt2vw.R Below there is a small example that reproduces the error. The function works great with
2005 Oct 20
5
search a value in variables dataset
Dear R-list, I have a dataset, say (the real dataset is 20 columns,110200 rows). > my.reducedID V1 V2 V3 V4 V5 V6 V7 V8 V9 [1,] 1 0 0 1 14 3 1 0 2 [2,] 2 0 0 1 14 3 1 0 2 [3,] 0 1 0 1 14 2 1 0 2 [4,] 0 0 1 1 14 3 1 0 2 [5,] 0 1 1 0 14 2 1 0 2 [6,] 0 0 0 1 14 3 1 0 2 [7,] 0 0 0 1 0 3 1 0 2 [8,] 0
2005 Jan 06
2
patterns of missing data: determining monotonicity
Here is a problem that perhaps someone out here has an idea about. It vaguely reminds me of something I've seen before, but can't place. Can anyone help? For multiple imputation, there are simpler methods available if the patterns of missing data are 'monotone' --- if Vj is missing then all variables Vk, k>j are also missing, vs. more complex methods required when the