Displaying 20 results from an estimated 48 matches for "col5".
Did you mean:
col
2009 Oct 02
3
help with regexp mass substitution
...me a lot of variables, and, given that they have regular name constructs, I would like to use regexps.
Here's a dump of my head(names(df))
varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
"col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
"col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3",
"col4.3.3", "col5.3.3", "txt.4.3", &qu...
2005 Mar 23
2
replace values in a matrix subject to boolean condition
Hi everybody!
I am sorry to bother you with a question so simple but
I think there might be a
better solution:
I have a matrix of size 360x501 where I want to check
the value of each 5th
column of each row and replace it (and the 6th, 7th,
8th column) by zero if the
value is less than 1000. I have written a double loop
to do that but that
requires a lot of time.
Is there a faster way to
2012 Oct 18
4
speeding read.table
...,
I am reading a 1 GB file into R using read.table. The file consists of 100 tables, each of which is headed by two lines of characters.
The first of these lines is:
TABLE NO. 1
The second is a list of column headers.
For example:
TABLE NO. 1
COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12
1.0010E+05 0.0000E+00 1.0000E+00 1.0000E+03 -1.0000E+00 1.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
1.0010E+05 1.0001E+01 1.0000E+00 1.0000E+03 -1.0000E+00 1.0000E...
2010 Mar 22
1
help needed with boxplot
I am new to R, can anyone help with boxplot for a dataset like:
file1 col1 col2 col3 col4 col5
050350005 101 56.625 48.318 RED
051010002 106 50.625 46.990 GREEN
051190007 25 65.875 74.545 BLUE
051191002 246 52.875 57.070 RED
220050004 55 70 80.274 BLUE
220150008 75 67.750 62.749 RED
220170001 77 65.750 54.307 GREEN
file2
col1 col2 col3 col4 col5
050350005 101 56.625 57 RED
051010002 106 50.6...
2008 Mar 16
2
How to loop through all the columns in dataframe
...036084
covAB<- (-0.0000013046)
varB<- 0.00000052628
After transposing my dataframe I need something like
the following:
varA + col1*covAB + col2*covAB + col1*col2*varB
varA + col1*covAB + col3*covAB + col1*col3*varB
varA + col1*covAB + col4*covAB + col1*col4*varB
varA + col1*covAB + col5*covAB + col1*col5*varB
and so on..
then do it all over again but starting with col2
varA + col2*covAB + col3*covAB + col2*col3*varB
varA + col2*covAB + col4*covAB + col2*col4*varB
varA + col2*covAB + col5*covAB + col2*col5*varB
then col3
then col4 to col7
This is easy to do...
2006 Dec 14
5
Better way to change the name of a column in a dataframe?
Hello R users --
If I have a dataframe such as the following, named "frame" with the
columns intended to be named col1 through col6,
> frame
col1 col2 cmlo3 col4 col5 col6
[1,] 3 10 2 6 5 7
[2,] 6 8 4 10 7 1
[3,] 7 5 1 3 1 8
[4,] 10 6 5 4 9 2
and I want to correct or otherwise change the name of one of the
columns, I can do so with
> dimnames(frame)[[2]][which(dimnames(frame...
2013 Jan 03
5
splitting matrices
Dear useRs,
i want to split a matrix having 1116rows and 12 columns. i want to split that matrix into 36 small matrices each having 12 columns and 31 rows. The big matrix should be splitted row wise. which means that the first small matrix should copy values which are in first 31 rows and 12 columns of the big matrix. similarly 2nd small matrix should contain values from 32nd to 63rd row of the
2008 Apr 09
1
Replace values according to conditions
Greetings R-users,
I have the following data called mydata in a data.frame
Col1 Col2 Col3 Col4 Col5
1 2 4 6 7
8 8 7 3 5
4 4 5 6 7
I want to replace the data according to the following conditions
Condition 1 if data <= 3, replace with -1
Condition 2 if data >=6, replace with 1
Condition 3 if data = 4 or data =5, replace with 0
S...
2007 Apr 25
1
Sum of specific column
I have a data set that I have imported (not sure if that makes a
difference) and I would like to calculate the sum of only specific
columns. I have tried
>colSums(dataset, by=list(dataset$col5), dims=1) and I get an error of
unused arguments
I have also tried
>aggregate(dataset, by=list(dataset$col5), sum) and I get the error that
sum is not meaningful for factors.
I want to only calculate the sum for specific columns because some of
the columns have words in them and I have not been...
2010 Oct 21
2
Adding rows to column
...ting column 7 where rows match "ID"
col1<- table2[grep("ID", table2[,1]),7]
#similarly extracting column 9,11,13,15
col2<- table2[grep("ID", table2[,1]),9]
col3<- table2[grep("ID", table2[,1]),11]
col4<- table2[grep("ID", table2[,1]),13]
col5<- table2[grep("ID", table2[,1]),15]
there are also some other single columns I extracted from other file. Now I
want to combine all these single columns into a single table with
corresponding headers. Any hint on how that can be done? Thanks.
i.e file3.txt
col1 col2 col3 col4 col5
R...
2011 Jan 24
2
how to slice a zoo object
...ot;COL2" "COL3" "COL4" ...
?- attr(*, "index")= POSIXct[1:632], format: "2009-05-01 01:00:00"
"2009-05-02 01:00:00" ...
and I would just like to take only arbitrary columns, i.e. another zoo
object with only the columns "COL2", "COL5", etc..
I've tried various syntactical combinations such as those for
data.frames and also tried manipulating the coredata(). What would be
nice would be the ability to do this by column names and not their
indexes.
Any help appreciated and thanks in advance,
Blair
2011 Aug 25
2
replicate lines of data frame
...h
line 6 times and then later change values in the first 2 columns.
I am trying to figure out how to accomplish this. I think that I need
to use rep(my.df, each=6) but it does not quite work.
This is the sample data frame
"col1" "col2" "col3" "col4" "col5" "col6" "col7"
foo bar 1 blah blah blah blah
foo bar 2 blah blah blah blah
foo bar 3 blah blah blah blah
......
......
I need to change it into this:
"col1" "col2" "col3" "c...
2012 Oct 20
2
Help with programming a tricky algorithm
Hi All,
I'm a little stumped by the following problem. I've got a dataset with
the following structure:
idxy ix iy country (other variables)
1 1 1 c1 x1
2 1 2 c1 x2
3 1 3 c1 x3
. . . . .
3739 55 67 c7 x3739
3740 55 68 c7 x3740
where ix and
2013 Jan 02
4
list of matrices
dear useRs,
i have a list containing 16 matrices. i want to calculate the column mean of each of them.
i tried
>sr <- lapply(s,function(x) colMeans(x, na.rm=TRUE))
but i am getting the following error
>Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
can it be done in any other way? and why i am getting this error??
thanks in advance..
elisa
[[alternative
2018 May 08
2
Dinamic variables in loop
Hello,
I am a newbie in R and I have a problem.
I want this line:
newMyData <-MyData[!(is.na(col1)) | !(is.na(col2)) | !(is.na(col3)) | !(
is.na(col4)) | !(is.na(col5)),]
write in for loop. The number of col[number] may be different from 3 to 8
Is there any ideas?
Thank you
Laura
[[alternative HTML version deleted]]
2016 Dec 20
2
colnames for data.frame could be greatly improved
...ric e.g. 23.5749
)
cat("GB =", round(sum(gc()[,2])/1024, 3), "\n")
#GB = 0.397
colnames(DF) = NULL
system.time(nm1<-colnames(DF, FALSE))
# user system elapsed
# 22.158 0.299 22.498
print(nm1)
#[1] "col1" "col2" "col3" "col4" "col5" "col6" "col7" "col8" "col9"
### restart R
colnames <- function (x, do.NULL = TRUE, prefix = "col")
{
if (is.data.frame(x)) {
nm <- names(x)
if (do.NULL || !is.null(nm))
return(nm)
else...
2006 May 15
1
what's wrong with my "gls"? it does not allocate memory... even for the simplest AR1 model...
> myfit1 <- gls(col1 ~ col2+col3+col4+col5+col6-1, data=data2, corr=corAR1(
0.3202), method='ML')
Error: cannot allocate vector of size 199712 Kb
if I get rid of the "corr=corAR1(0.3202)" option, it works okay...
can anybody help me?
thanks a lot!
[[alternative HTML version deleted]]
2005 May 02
4
"apply" question
...w want to calculate
(1) the number of values in each row of columns 6-10 that were NA??s
(2) the sum of all values on columns 1-5 for which there were no missing
values in the corresponding cells of columns 6-10.
Example: (let??s call the data frame "data")
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8 Col9 Col10
1 2 5 2 3 NA 5 NA 1 4
3 1 4 5 2 6 NA 4 NA 1
The result would then be (for the first row)
(1) "There were 2 NA??s in columns 6-10."
(2) The mean of Columns 1-5 was 2+2...
2012 Nov 23
6
Summary statistics for matrix columns
Hi,
is there a way I can calculate a summary statistics for a columns matrix
let say we have this matrix
x <- matrix(sample(1:8000),nrow=100)
colnames(x)<- paste("Col",1:ncol(x),sep="")
if I used summary
summary(x)
i get the output for each column but I need the output to be in matrix with
rownames and all the columns beside it
this how I want it
2007 Feb 22
2
Is there better alternative to this loop?
Dear List,
Thanks to those who helped with my enquiry a few days ago.
I have a another question on loops, in this case I am trying to print out
the row of a data frame if the previous 3 values (daily values) in col5 are
in descending order. I have this loop which works, but ask whether this can
be done differently (without conventional loop) in R:
flag="T"
d= 3 # d represents previous down days
for(i in (d+1): 100)
{
for( j in (i-d):(i-1))
{
if(x[j,5]<x[i,5]){flag="F"}
}
if( flag == &...