Displaying 20 results from an estimated 5000 matches similar to: "Newbie: Data reading problem"
2023 Apr 04
1
Simple Stacking of Two Columns
Just to repeat:
you have
NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
and you want
NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
There must be something I am missing, because
NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2))
appears to
2023 Apr 03
4
Simple Stacking of Two Columns
Hi R-Helpers,
Sorry to bother you, but I have a simple task that I can't figure out how to do.
For example, I have some names in two columns
NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly"))
and I simply want to get a single column
2023 Apr 04
1
Simple Stacking of Two Columns
I may be missing something but using the plain old c() combine function
seems to work fine:
df <- data.frame(left = 1:5, right = 6:10)
df.combined <- data.frame(comb = c(df$left, df$right))
df
left right
1 1 6
2 2 7
3 3 8
4 4 9
5 5 10
df.combined
comb
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
-----Original
2023 Apr 03
1
Simple Stacking of Two Columns
Hi,
You were on the right track using stack(), but you just pass the entire data frame as a single object, not the separate columns:
> stack(NamesWide)
? values ? ind
1 ? ?Tom Name1
2 ? Dick Name1
3 ?Larry Name2
4 ?Curly Name2
Note that stack also returns the index (second column of 'ind' values), which tells you which column in the source data frame the stacked values originated
2020 Jul 23
5
Off Topic bash question
I have a simple script:
#!/bin/bash
#
index=0
total=0
names=()
ip=()
while read -r LINE
do
NODENAME=` echo $LINE | cut -f 1 -d ','`
IP=` echo $LINE | cut -f 2 -d ','`
names[index]="$NODENAME"
ip[index]="$IP"
index=`expr index+1`
total=`expr total+1`
done <<< $(cat list.txt)
simple file:
more list.txt
name1,ip1
name2,ip2
name3,ip3
output when
2001 May 23
1
Passing a string variable to Surv
Hi,
I am trying to write a function to automate multiple graph
generation. My data looks like:
Table of numeric values with the following headers:
timeM1 statusM1 xM1 timeM2 statusM2 xM2 timeM3 statusM3 xM3
1
2
3
4
5
6
Where M1,M2, M3 hve no similarity except they have a max string length
of 7. Examples are mcw0045, adl0003, lei0101.
Now, what I want to do is
Function(M1, M2,
2009 Jul 31
1
function problem
I have a series of columns that need to be evaluated in various tables. I
need to apply a function in the following manner somers2(name1,name2). name1
is a vector of x inputs for the function which correspond to a vector of y
inputs in name2.
y<-rep(c(3,4,5,8),6)
z<-rep(c(23,24,25,26,27,28),4)
name1<-sprintf("Pred_pres_%s_indpdt[,%s,,]",x,y)
2017 Jul 16
0
Arranging column data to create plots
On Sat, 15 Jul 2017, Michael Reed via R-help wrote:
> Dear All,
>
> I need some help arranging data that was imported.
It would be helpful if you were to use dput to give us the sample data
since you say you have already imported it.
> The imported data frame looks something like this (the actual file is
> huge, so this is example data)
>
> DF:
> IDKey X1 Y1 X2 Y2
2006 Jan 20
3
Selecting data frame components by name - do you know a shorter way?
Hi! I suspect there must be an easy way to access components of a data frame by name, i.e. the input should look like "name1 name2 name3 ..." and the output be a data frame of those components with the corresponding names. I ´ve been trying for hours, but only found the long way to do it (which is not feasible, since I have lots of components to select):
2009 Sep 04
2
transforming a badly organized data base into a list of data frames
Dear R-ers!
I have a badly organized data base in Excel. Once I read it into R it
looks like this (all variables become factors because of many spaces
and other characters in Excel):
2017 Jul 16
3
Arranging column data to create plots
Dear All,
I need some help arranging data that was imported.
The imported data frame looks something like this (the actual file is huge, so this is example data)
DF:
IDKey X1 Y1 X2 Y2 X3 Y3 X4 Y4
Name1 21 15 25 10
Name2 15 18 35 24 27 45
Name3 17 21 30 22 15 40 32 55
I would like to create a new data frame with the following
NewDF:
IDKey X Y
Name1 21 15
Name1
2000 Oct 16
2
renaming an object
Say I have a file called exp.batch which contains 2 cols
The first col contains names of R objects the user would like to use.
The second col contains the file names which will be read in using
read.table
i.e. exp.batch may look like this.....
name1 complex/filename/path1.txt
name2 complex/filename/path2.txt
name3 complex/filename/path3.txt
name4 complex/filename/path4.txt
I want to have a
2006 Dec 13
2
(no subject)
Hi,
Let us suppose I have a list
x = list ()
x $ name1 = 1
x $ name2 = 'a'
in the work environment.
Let us suppose that in the body of a function I want to acces to a component of x by
using its name as argument of that function. How can this by done? For instance, I was
expecting
f = function ( name ) x $ name
to output
1 ( that is, x $ name1 )
when I command f ( name1 ) or f (
2008 May 25
3
naming components of a list
Hi
I have a character vector with thousands of names which looks like this:
> V=c("Fred", "Mary", "SAM")
> V
[1] "Fred" "Mary" "SAM"
> class(V)
[1] "character"
I would like to change it to a list:
> L=as.list(V)
> L
[[1]]
[1] "Fred"
[[2]]
[1] "Mary"
[[3]]
[1] "SAM"
but I need to
2010 May 26
1
Xen guest does not autostart
I have a virtual machine stack which was purely Centos 5.4 the last time
I rebooted and experienced this problem: one of the guests does not
start automatically after reboot.
[root at farm1 xen]# pwd
/etc/xen
[root at farm1 xen]# ls -l auto
total 0
lrwxrwxrwx 1 root root 8 Dec 11 17:25 name1 -> ../name1
lrwxrwxrwx 1 root root 8 May 5 21:10 name2 -> ../name2
lrwxrwxrwx 1 root root 8 Nov
2005 Feb 23
1
to print dataframe
Dear all,
Is it possible to print a dataframe without the row numbers?
For example if I have a dataframe like that:
>df <- data.frame(name1=sample(LETTERS,10),name2=sample(c(0,1),10,replace=TRUE))
after printing
name1 name2
1 O 1
2 H 0
3 R 0
4 T 0
5 V 1
6 E 0
7 W 0
8 P 1
9 G 0
10 J 1
2009 Jul 23
2
Constructing lists (yet, again)
This is an attempt to rescue an old R-help question that apparently
received
no response from the oblivion of collective silence, and besides I'm
also
curious about the answer
> From: Griffith Feeney (gfeeney at hawaii.edu)
> Date: Fri 28 Jan 2000 - 07:48:45 EST wrote (to R-help)
> Constructing lists with
>
> list(name1=name1, name2=name2, ...)
>
> is tedious when
2010 Feb 10
4
Readjusting the OUTPUT csv file
Dear R helpers
I have some variables say ABC, DEF, PQR, LMN and XYZ. I am choosing any three varaibles at random at a time for my analysis and name these files as input1.csv, input2.csv and input3.csv. So if I choose variables say ABC, DEF and PQR, I am passing the specifications of these variables to input1.csv, input2.csv and input3.csv respectively.
This means in another case even if I
2006 Nov 29
1
Extract some character from a character vector of length 1
the content of th character vector (of length 1) is as follows:
a <- "something2 ....pat1 name1 pat2 something2....pat1 name2
pat2....pat1 name3 pat2 "
I would like to extract the character bewteen pat1 and pat2. That's to
say, I would like to get a vecter of c("name1", "name2","name3").
What I did is use strsplit() twise. But I wonder if there
2012 Mar 03
3
Shape manipulation
Hi all, let say I have following matrix:
> Dat <- matrix(1:30, 5, 6); colnames(Dat) <- rep(c("Name1", "Names2"), 3)
> Dat
Name1 Names2 Name1 Names2 Name1 Names2
[1,] 1 6 11 16 21 26
[2,] 2 7 12 17 22 27
[3,] 3 8 13 18 23 28
[4,] 4 9 14 19 24 29
[5,] 5