Displaying 20 results from an estimated 5000 matches similar to: "First value in a row"
2013 Mar 27
9
conditional Dataframe filling
Hi everyone:
This may be trivial but I just have not been able to figure it out.
Imagine the following dataframe:
a b c d
TRUE TRUE TRUE TRUE
FALSE FALSE FALSE TRUE
FALSE TRUE FALSE FALSE
I would like to create a new dataframe, in which TRUE gets 0 but if
false then add 1 to the cell to the left. So the results for the
example above should be something like:
a b c
2013 Mar 13
3
loop in a data.table
Hi everyone,
I have a data.table called "data" with many columns which I want to
group by column1 using data.table, given how fast it is.
The problem with looping a data.table is that data.table does not like
quotations to define the column names (e.g. "col2" instead of col2).
I found a way around which is to use get("col2"), which works fine but
the
2013 Mar 02
3
replace zeros for NA in a column based on values of another column
Hi everyone,
Imagine that I have a data frame with four columns:
data<-
a b c d
0 1 1 0
1 1 1 1
1 0 0 1
I want to replace the zeros in columns a:b for NA only for the rows in
which column d are zero. So
a b c d
NA 1 1 0
1 1 1 1
1 0 0 1
I am trying
2012 Sep 01
5
R_closest date
Hi,
I have encountered an issue about finding a date closest to another date
So this is how the data frame looks like:
PT_ID IDX_DT OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY
13 4549 2002-08-21 2002-08-20 -1 183 2
14 4549 2002-08-21 2002-11-14 85 91 1
15 4549 2002-08-21 2003-02-18 181 89 1
16 4549 2002-08-21 2003-05-15
2012 Oct 14
6
transforming a .csv file column names as per a particular column rows using R code
Hello all,
I have a .csv file like below.
Tool,Step_Number,Data1,Data2... etc up to 100 columns.
A,1,0,1
A,2,3,1
A,3,2,1
.
.
B,1,3,2
B,2,1,2
B,3,3,2
.
.
...... so on upto 50 rows
where the column "*Tool*" has distinct steps in second column
"*Step_Number*",but both have same entries in Step_Number column.
I want the output like below.
2012 Mar 10
3
function input as variable name (deparse/quote/paste) ??
Hi all
Say I have a function:
myname=function(dat,x=5,y=6){
res<<-x+y-dat
}
for various input such as
myname(dat1)
myname(dat2)
myname(dat3)
myname(dat4)
myname(dat5)
how should I modify the 'res' line, to have new informative variable name
correspondingly, such as
dat1.res
dat2.res
dat3.res
dat4.res
dat5.res
stored in the workspace.
This is only an example of a complex
2012 Oct 12
3
Columns and rows
Hi,
Could you please advice some easy way to do the following for a dataframe
(header=F) having unequal column- & row- length.
1. Combine/stack/join contents from -
a) multiple rows into one column.
b) multiple columns into one row.
2. Stack contents from multiple columns (or, rows) into one column (or,
row).
Thank you.
Cheers,
Santana
[[alternative HTML
2013 Apr 08
3
Reshaping a table
Hello all,
I have data in the form of a table:
X Y1 Y2
0.1 3 2
0.2 2 1
And I would like to transform in the form:
X Y
0.1 Y1
0.1 Y1
0.1 Y1
0.1 Y2
0.1 Y2
0.2 Y1
0.2 Y1
0.2 Y2
Any ideas how?
Thanks in advance,
IOanna
[[alternative HTML version deleted]]
2011 Jul 02
5
How many times occurs
Hi all,
I have a data matrix likein "input.txt"
8 9 2 5 4 5 8 5 6 6
8 9 2 8 9 2 8 9 2 1
8 9 2 5 4 5 8 5 6 4
8 9 2 5 4 5 8 5 6 6
8 9 2 8 9 2 8 9 2 1
8 9 2 5 4 5 8 9 2 2
In this example will be an 6x10 matrix (or data frame)
I want to detect how many times in a row appears this combination 8 follewd
by 9 followed by 2, and create a new matrix with only this number of occurs
then
2012 Jul 14
2
Arrange two columns into a five variable dataframe
Hi,
I hope that folks can give me some simple approaches to taking the data set
below, which is accumulated in two columns called "long" and "group", then
arrange the data is the "long" column into a data frame containing five
variables: "Group 1", "Group 2", "Group 3", "Group 4", and "Group 5". I am
hoping for a few
2012 Oct 26
3
regression analysis in R
Dear useRs,
i have vectors of about 27 descriptors, each having 703 elements. what i want to do is the following 1. i want to do regression analysis of these 27 vectors individually, against a dependent vector, say B, having same number of elements.2. i would like to know best 10 regression results, if i do regression analysis of dependent vector against the random combination of any 4
2012 Jul 29
1
readRDS, In as.double.xts(fishReport$count) : NAs introduced by coercion
Hello,
I looked in the R-help but could not find an archive addressing the
following. I would like to convert a character to numeric after reading a
file with RDS extension. After using as.numeric, I checked if it is
numeric. It was not converted. Please help.
Here is my code
>Report <- readRDS(file="RDS/Report.RDS")
> Report[1:2,]
dive_id date
2012 Oct 26
3
Delete row if two values in a matrix are equal
Hi all and thank you for your time.
I would like to delete rows from this matrix I call "var" if the character
in Ref_Allele is equal to the character in Var_Allele. I have attached a
before and after, to help my poor explanation. If someone could provide me
with some code, or some guidance I would really appreciate it.
Thank you again.
"Before"
> var
Ref_Pos Ref_Allele
2012 Dec 17
3
Merge more than 2 dataframe
Hello.
I have for example 4 or more dataframe which like such this example:
date value
2006-11 0.4577647
2006-12 NaN
2006-10 0.1577647
2006-11 0.3577647
2006-12 NaN
2007-01 NaN
2007-02 NaN
2007-03 0.2956429
2007-01 0.3677647
2007-02 NaN
They have the same length. I need merge by date undefined number of
dataframes. End result output will look like
2012 Sep 24
3
List creation based on matrix
Hi guys,
It would be great if you could help me with this one...
I'm looking to create a script to convert a matrix of species abundance e.g:
<http://r.789695.n4.nabble.com/file/n4643978/species_matrix.jpg>
into two vectors e.g:
<http://r.789695.n4.nabble.com/file/n4643978/communitylist.jpg>
----------------
If you feel there is no easy answer to this and that it would be
2012 Oct 19
4
Creating a new by variable in a dataframe
Hello,
I have a dataframe w/ 3 variables of interest: transaction,date(tdate) &
time(event_tim).
How could I create a 4th variable (last_trans) that would flag the last
transaction of the day for each day?
In SAS I use:
proc sort data=all6;
by tdate event_tim;
run;
/*Create last transaction flag per day*/
data all6;
set all6;
by tdate event_tim;
last_trans=last.tdate;
Thanks
2012 Oct 04
3
R combining vectors into a data frame but without a continuous common variable
Hello,
I have two different files which I'd like to combine to make one data frame
but I've no idea how to do it! The first file has two columns; one is the
date, the following is a binary code for debris flow events. Then my other
file has also two columns; the date and then precipitation data.
The thing is, is that the two date columns don't all contain the same dates.
The binary
2012 Sep 02
1
why variations in accuracy between R to ARCGIS for the same point reprojection?
Hi everyone,
I wonder if anyone knows the reason why the outputs of the same
reprojection in r and arcgis are different?. The magnitude of the
change can be up to 40 km in the poles.
Basically, I have a database of points equally separated by one degree
over the globe.
In ARCGIS, I am projecting the data in GCS-WGS-1984 and then
reprojected it to Berhmann to ensure equal area
2012 Jul 22
2
R Beginner : Loop and adding row to dataframe
Hi everybody,
I am currently quite inexperienced with R.
I try to create a function that simply take a value in a dataframe, look for
this value in another dataframe and copy all the row that have this value
This example is a simplified version of what I am doing but it's enough to
help me
listA
Name NACE
a 1
b 2
c 3
ListB
NACE aaa bbb ccc
1 a a c
1 a a c
1 a a c
2 a a c
2 a a c
3 a a c
4 a
Error with custom function in apply: Error in FUN(newX[, i], ...) : unused argument(s) (newX[, i])
2013 Mar 23
1
Error with custom function in apply: Error in FUN(newX[, i], ...) : unused argument(s) (newX[, i])
Hi everyone,
I wonder if I can get your help using a custom function in apply.
Imagine the following dataframe called "data":
LowLim HighLim A1 A2 A3 A4
4 6 3 4 5 6
4 6 4 5 5 6
2 3 1 4 2 3
2 3 NA NA NA NA
We have created a custom function (see below) that takes the values in
a given row between columns A1 to A4 to see if they are outside the
limits in the same