Displaying 20 results from an estimated 11000 matches similar to: "Re-arrange Columns in data frame"
2009 Nov 13
4
processing log file
Dear all, I'm trying to process a log file which logs the date, the username and the computer number accessed. The table looks like this:
>table.users
Date UserName Machine
1 2008-11-25 John 641
2 2008-11-25 Clive 611
3 2008-11-25 Jeremy 641
4 2008-11-25 Walt 722
5 2008-11-25 Tony 645
6 2008-11-26 Tony 645
7 2008-11-26
2007 Aug 10
3
having problems with factor()
Dear R Help,
I have a set of data of heights of trees described by area that they are in. The areas are numerical (0 to 7).
ht area
1 320 3
2 410 4
3 230 2
4 360 3
5 126 1
6 280 2
7 260 2
8 280 2
9 280 2
10 260 2
.......
180 450 4
181 90 1
182 120 1
183 440 4
184 210 2
185 330 3
186 210 2
187 100 1
188 0 0
I want to convert the
2011 Dec 01
1
Fw: calculate mean of multiple rows in a data frame
NAME
ID
a
b
c
d
1
Control_1
probe~B01R01C01
381
213
345
653
2
Control_2
probe~B01R01C02
574
629
563
783
3
Control_1
probe~B01R09C01
673
511
521
967
4
Control_3
probe~B01R09C02
53
809
999
50
5
MM0289~RFU:11810.15
probe~B29R13C06
681
34
115
587
6
MM0289~RFU:9238.41
probe~B29R13C05
784
443
20
784
7
MM16597~RFU:36765.38
probe~B44R15C20
719
251
790
445
8
MM16597~RFU:41258.94
probe~B44R15C19
677
2011 Nov 24
2
how to add "waiting for page change" to my script
I'd like to "step" through 24 histograms by using the return or click button option, as shown in the demo(graphics) demonstration. I've searched for "interactive graphics", and "waiting for page change" in R documentation but with no result. I'm sure that this is a relatively straightforward procedure. Can anyone point me to the correct solution?
Jabez
2007 Aug 13
2
question regarding is.factor()
Dear all, please help with what must be a straightforward question which I can't answer.
I add a column of my dataframe as factor of an existing column e.g.
df[,5] <- factor(df[,2])
and can test that it is by is.factor()
but if I did not know in advance what "types" the columns were, is there a function to tell me what they are.
i.e. instead of
2005 Apr 05
1
accessing header information in a table
Dear list, I have read an excel table into R using read.table() and headers=T. The table is 7 columns of figures. Is there any way to gain access to the header information? Say the table headers are Mon, Tue etc I can get to the data with myTable$Tue, but how do I get the headers themselves.
TIA
Jab
[[alternative HTML version deleted]]
2008 Mar 06
3
1-pnorm values in a table
Hi,
I've read in a csv file (test.csv) which gives me the following table:
Hin1 Hin2 Hin3 Hin4 Hin5 Hin6
HAI1 9534.83 4001.74 157.16 3736.93 484.60 59.25
HAI2 13272.48 1519.88 36.35 33.64 46.68 82.11
HAI3 12587.71 5686.94 656.62 572.29 351.60 136.91
HAI4 15240.81 10031.57 426.73 275.29 561.30 302.38
HAI5 15878.32 10517.14 18.93 22.00 16.91
2011 Jul 27
2
Elegant way to subtract matrix from array
there are really two related problems here
I have a 2D matrix
A <- matrix(1:100,nrow=20,ncol =5)
S <- matrix(1:10,nrow=2,ncol =5)
#I want to subtract S from A. so that S would be subtracted from the
first 2 rows of
#A, then the next two rows and so on.
#I have a the same problem with a 3D array
# where I want to subtract Q for every layer (1-10) in Z
# I thought I solved this one
2006 Nov 08
0
Fw: data frames re-ordering and naming columns
Thank you for help with the first part. The second part I do not understand. All I get is "3" "3". Presumably this is the factor that you refer to. Is there no simple way of extracting the text alone
----- Forwarded Message ----
From: Peter Alspach <PAlspach@hortresearch.co.nz>
To: Jabez Wilson <jabezwuk@yahoo.co.uk>
Sent: Tuesday, 7 November, 2006 7:46:02 PM
2009 Feb 18
1
rbind: number of columns of result is not a multiple of vector length (arg 1)
i have the following constructed and running very well,, thanks to Gabor
Grothendieck for his help.
>data.info <- c("station.id", "year", "date", "max.discharge")
>
> for(i in 1:num.files) {
+ station.id <- substring(data[i], 1,8)
+ DF <- read.table(data[i], sep=",", blank.lines.skip = TRUE)
+ z <- zoo(DF[,4],
2010 Dec 02
1
Arrange elements on a matrix according to rowSums + short 'apply' Q
Greetings,
My goal is to create a Markov transition matrix (probability of moving from
one state to another) with the 'highest traffic' portion of the matrix
occupying the top-left section. Consider the following sample:
inputData <- c(
c(5, 3, 1, 6, 7),
c(9, 7, 3, 10, 11),
c(1, 2, 3, 4, 5),
c(2, 4, 6, 8, 10),
c(9, 5, 2, 1, 1)
)
MAT <- matrix(inputData,
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2012 May 20
5
removeing only rows/columns with "na" value from square ( symmetrical ) matrix.
I have some square matrices with na values in corresponding rows and
columns.
M<-matrix(1:2,10,10)
M[6,1:2]<-NA
M[10,9]<-NA
M<-as.matrix(as.dist(M))
print (M)
1 2 3 4 5 6 7 8 9 10
1 0 2 1 2 1 NA 1 2 1 2
2 2 0 1 2 1 NA 1 2 1 2
3 1 1 0 2 1 2 1 2 1 2
4 2 2 2 0 1 2 1 2 1 2
5 1 1 1 1 0 2 1 2 1 2
6 NA NA 2 2 2 0 1 2 1 2
7 1 1 1 1 1 1 0 2 1 2
8
2012 Jun 01
1
Redefine multiple columns (using grep) as factor variables
Hi,
I have a dataframe with around 100 columns. Now I want
to redefine some of the columns as factors (using as.factor).
Luckily all the names of the columns I want to redefine start with
"crast". Thus I thought I can use grep() for that purpose...
...I found an example for redefining a single column as factor
but that is not working with multiple columns I get from grep()...
what I
2011 Dec 28
2
Gale-Shapley Algorithm for R
Dear R-helpers,
I'm not a speciallist in writing complex functions, and the function still
very rusty (any kind of suggestions are very welcome). I want to implement
Gale-Shapley algorithm for R Language. It is based on
http://www.jstor.org/stable/10.2307/2312726 Gale and Shapley (1962) , and it
has evolved to
2011 Mar 28
2
Import variable labels to data frame columns
Hi, I'm new to R and I'm stuck trying to import some data from a .dat file
I've been given. The tricky bit for me is that the data has both variable
values and labels?
The data looks like this,
Id=1 time=2011-03-27 19:23:40 start=1.4018 end=1.4017
Id=2 time=2011-03-27 19:23:40 start=1.8046 end=1.8047
Id=1 time=2011-03-27 19:23:50 start=1.4017 end=1.4018
Id=2
2012 Mar 06
2
Help in matrix
Hi
I have a matrix
a = 1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
b = 5 6 7
8 9 10
I want output as
c = 5 2 3
8 2 3
1 6 3
1 9 3
1 2 7
1 2 10
Please any on help to avoid reduncy of my code
-----
Thanks in Advance
Arun
--
View this message in context:
2012 Mar 07
1
date columns chooser
i have a data frame with 2 columns of dates.
with str(dataframe) i have ensured myself that they were indeed formatted
as dates.
one column has NA's in it.
the aim is now to make a third column that chooses date1 if it is a date,
and choose date2 if it is a NA.
i am trying
df$date3=ifelse(is.na(df$date1), df$date2, df$date1).
this leads to unexpected behaviour: the resulting column is
2008 Jan 16
3
replace numbers in a column conditional on their value
Dear R help,
I have a data frame column in which I would like to replace some of the numbers dependent on their value.
data frame = zz
AveExpr t P.Value FC
7.481964 7.323950 1.778503e-04 2.218760
7.585783 12.233056 6.679776e-06 2.155867
6.953215 6.996525 2.353705e-04 1.685733
7.647513 8.099859 9.512639e-05 1.674742
7.285446 7.558675 1.463732e-04 1.584071
2011 Mar 01
2
Entering table with multiple columns & rows
Hi,
I'm having difficulty with getting a table to show with
multiple rows and columns. Below is the commands that I've typed in and
errors that I am getting. Thank you.
Laura
Table trying to enter:
Diet: Binger-yes: Binger-No: Total:
None 24 134 158
Healthy 9 52 61
Unhealthy 23 72 95
Dangerous 12 15 27
>