Displaying 20 results from an estimated 30000 matches similar to: "Order by the columns"
2007 Jul 28
1
data order by different level of variables
Dear useR,
I have a data matrix, it has n columns, each column is a two-level variable
with entires -1 and +1. They are randomly generated, now I want to order
them like (for example, 5 columns case)
- - - - -
- - - - -
.................
(first several rows are the samples with all variables in low level)
+ - - - -
+ - - - -
.............................
2009 Sep 21
5
More elegant way of excluding rows with equal values in any 2 columns?
Hello, dear R-ers!
I built a data frame "grid" (below) with 4 columns. I want to exclude
all rows that have equal values in ANY 2 columns. Here is how I am
doing it:
index<-expand.grid(1:4,1:4,1:4,1:4)
dim(index)
# Deleting rows that have identical values in any two columns (1 line of code):
2010 Jul 09
2
split with list
Dear List I would like to ask you something concenting a better print of the R output:
I have a bit data frame which has the following structure:
CFISCALE RAGSOCB ANNO VAR1 VAR2.........
9853312 astra 2005 6 45
9853312 astra 2006 78 45
2011 Jul 21
2
Latex Table Help on R
Hello everyone,
Peter (see my earlier post) recommended the following script for finding the
means and standard deviations and putting them in table form.
However, I would like the standard deviations under the means in brackets.
Can anyone check this code to see how this can be adjusted?
library(xtable)
dataset1 = matrix( c(1,2,3,4, 5, 6 ), 2 , 3)
dataset2 = matrix( c(4,3,5,10, 1, 0), 2, 3)
2011 Jun 06
1
Merge two columns of a data frame
I have the following data:
prefix <- c("cheap", "budget")
roots <- c("car insurance", "auto insurance")
suffix <- c("quote", "quotes")
prefix2 <- c("cheap", "budget")
roots2 <- c("car insurance", "auto insurance")
roots3 <- c("car insurance", "auto
2007 Apr 02
3
Create a new var reflecting the order of subjects in existing var
Dear R helpers
I have a data set sth like this:
set.seed(123);dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4),
rep(5,5)),
var1 =rnorm(17, 35,2),
var2=runif(17,0,1))
dat
ID var1 var2
1 1 33.87905 0.02461368
2 1 34.53965 0.47779597
3 2 38.11742 0.75845954
4 2 35.14102 0.21640794
5 2 35.25858 0.31818101
6 3 38.43013
2008 Jan 24
3
Reshaping a dataframe with conditional summary of columns - apply or reshape?
I need to do a somewhat complex rearrangement of an existing dataframe that
involves an "on-the-fly" conditional summary as well. I've tried to make
the example as simple as possible. Code to produce the object being acted
on is at the end of the message. I hope this isn't too much for a single
posting. Any guidance will be much appreciated.
The input example looks like
2011 Nov 29
2
aggregate syntax for grouped column means
I am calculating the mean of each column grouped by the variable 'id'.
I do this using aggregate, data.table, and plyr. My aggregate results
do not match the other two, and I am trying to figure out what is
incorrect with my syntax. Any suggestions? Thanks.
Here is the data.
myData <- structure(list(var1 = c(31.59, 32.21, 31.78, 31.34, 31.61, 31.61,
30.59, 30.84, 30.98, 30.79, 30.79,
2008 Jul 16
2
Group level frequencies
Dear List,
I have Multi-level Data
i= Indivitual Level
g= Group Level
var1= First Variable of interest
var2= Second Variable of interest
and I want to count the frequency of "var1" and "var2" on the group
level.
I found a way, but there must be a much simpler way.
data.ml <-
data.frame(i=c(1:8),g=as.factor(c(1,1,1,2,2,3,3,3)),var1=c(3,3,3,4,4,4,4
,4),
2011 Aug 31
1
Recoding observations in all columns of a data frame.
Dear all,
Suppose I have a data frame like this:
[code]
var1 <- c(1,999,2)
var2 <- c(999,1,2)
var3 <- c(1,2,999)
example <- data.frame(var1,var2,var3)
[/code]
I want to replace all 999 to NA in all observations in all columns. I
know how to do it in each individual column.
[code]
example$var1[example$var1==999] <- NA
[/code]
I think it can be done with a for loop.
[code]
for
2010 Dec 03
2
Add columns of dataset
Dear all,
I have a dataset that looks like
id var1 var2 var4 var7 var8
1 0.0 0.1 0.3 0.9 0.0
2 0.4 0.6 0.0 0.0 0.2
3 0.0 0.0 0.0 0.8 0.7
Some columns are missed, for example, here the fourth (var3), sixth(var5)
and seventh (var6) columns. I want to first determine which columns are
missed in a huge dataset and then add the missed
1999 Jan 04
1
Names of data frame columns in an apply
Hi,
[some background]
I have a dataset which describes a number of subjects doing a "scientific
discovery". That is, they have to discover the rules underlying a
particular domain. To do so, they have to set the levels of 5 variables
which leads to a certain outcome. To identify what kind of "experiments"
the subjects did, I want to combine these levels into one variable
2004 Aug 17
5
Bug in colnames of data.frames?
Hi,
I am using R 1.9.1 on on i686 PC with SuSE Linux 9.0.
I have a data.frame, e.g.:
> myData <- data.frame( var1 = c( 1:4 ), var2 = c (5:8 ) )
If I add a new column by
> myData$var3 <- myData[ , "var1" ] + myData[ , "var2" ]
everything is fine, but if I omit the commas:
> myData$var4 <- myData[ "var1" ] + myData[ "var2" ]
the name
2009 Sep 22
3
converting a character vector to a function's input
Hi all, I have been trying to solve this problem and have had no luck so far.
I have numeric vectors VAR1, VAR2, and VAR3 which I am trying to cbind. I also have a character vector "VAR1,VAR2,VAR3". How do I manipulate this character vector such that I can input a transformed version of the character vector into cbind and have it recognize that I'm trying to refer to my numeric
2014 Aug 21
2
pregunta
Buenas noches Javier y José,
Estoy en contra de usar attach(), asi que propongo la siguiente alternativa
con with():
# paquete
require(epicalc)
# los argumentos en ... pasan de epicalc:::cc
# ver ?cc para mas informacion
foo <- function(var1, var2, var3, ...){
or1 <- cc(var1, var2, ...)
or2 <- cc(var1, var3, ...)
list(or1 = or1, or2 = or2)
}
# datos
x <-
2010 Dec 20
2
Turning a Variable into String
I would like to know how to turn a variable into a string. I have tried
as.symbol and as.name but it doesnt work for what I'd like to do
Essentially, I'd like to feed the function below with two variables. This
works fine in the bit working out number of elements in each variable.
In the print(sprintf("OK with %s and %s\n", var1, var2)) line I would like
var1 and var2 to be
2006 Mar 02
1
CCF and Lag questions
I am new to R and new to time series modeling.
I have a set of variables (var1, var2, var3, var4, var5) for which I have
historical yearly data.
I am trying to use this data to produce a prediction of var1, 3 years into
the future.
I have a few basic questions:
1) I am able to read in my data, and convert it to a time series format
using 'ts.'
data_ts <- ts(data, start = 1988, end =
2010 May 05
3
concatenate values of two columns
Dear list,
I'm trying to concatenate the values of two columns but im not able to do it:
i have a dataframe with the following two columns:
X VAR1 VAR2
1 2
2 1
3 2
4 3
5 4
6 4
what i would like to
2012 Jul 01
2
list to dataframe conversion-testing for identical
HI R help,
I was trying to get identical data frame from a list using two methods.
#Suppose my list is:
listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2))
#Creating dataframe using cbind
dat1<-data.frame(do.call("cbind",listdat1))
colnames(dat1)<-c("Var1","Var2","Var3")
#Second dataframe conversion
2006 Jan 13
2
find mean of a list of timeseries
Can someone please give me a clue how to 're'write this so I dont need
to use loops.
a<-ts(matrix(c(1,1,1,10,10,10,20,20,20),nrow=3),names=c('var1','var2','var3'))
b<-ts(matrix(c(2,2,2,11,11,11,21,21,21),nrow=3),names=c('var1','var2','var3'))