Displaying 10 results from an estimated 10 matches for "names2".
Did you mean:
names
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 10 15 20 25 30
>...
2004 Jun 25
3
String manipulation
...quot;one","two","three")
Now I want to concatenate the items to one string, seperateted by space or
something else,
>str
>"one, two, three"
If possible without a loop.
My actual goal ist to create string like
>str.names
>"female = names1, male = names2"
and pass it as argument to list(), intending to create a list
>names.list<-list( female = names1, male = names2)
Thanks a lot,
Robin
2012 Jun 03
2
merging single column from different dataframe
Hi all,
probably really simple to solve, but having no background in programming I
haven't been able to figure this out: I have two dataframes like
df1 <- data.frame(names1=c('aa','ab', 'ac', 'ad'), var1=c(1,5,7,12))
df2 <- data.frame(names2=c('aa', 'ab', 'ac', 'ad', 'ae'),
var2=c(3,6,9,12,15))
Now I want merge var1 to df2 by matching the dataframes by the 'names'
columns, i.e. something like
df3 <- merge (df2, df1, by.x='names2', by.y='names1', all.x=T)
However, the...
2023 Apr 03
4
Simple Stacking of Two Columns
...","Curly"))
and I simply want to get a single column
NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
> NamesLong
Names
1 Tom
2 Dick
3 Larry
4 Curly
Stack produces an error
NamesLong<-stack(NamesWide$Name1,NamesWide$Names2)
Error in if (drop) { : argument is of length zero
So does bind_rows
> NamesLong<-dplyr::bind_rows(NamesWide$Name1,NamesWide$Name2)
Error in `dplyr::bind_rows()`:
! Argument 1 must be a data frame or a named atomic vector.
Run `rlang::last_error()` to see where the error occurred.
I tried m...
2013 Feb 17
6
histogram
HI Elisa,
You could use ?cut()
vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45)
label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i) paste(i[1],"<x<=",i[2],sep="")))
2023 Apr 04
1
Simple Stacking of Two Columns
...because
NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2))
appears to do the job in the simplest possible manner. There are all sorts
of alternatives, such as
data.frame(Name = as.vector(as.matrix(NamesWide[, 1:2])))
As for stack(), the main problem there was a typo (Names2 for Name2).
> stack(NamesWide)
values ind
1 Tom Name1
2 Dick Name1
3 Larry Name2
4 Curly Name2
If there were multiple columns, you might do
> stack(NamesWide[,c("Name1","Name2")])$values
[1] "Tom" "Dick" "Larry" "Curly&qu...
2009 Dec 02
2
Help: barchart() {Lattice}
...),
border=NA
)
I need help with:
1. How can I remove the (y-axis) tick marks on the right side of the plot.
2. While reading in the data, I'm using "row.names=Names". Can I generalize
this? What I mean is if for some other data set, the row names column
has some other name (say Names2) or may be just blank. Can I still produce a
similar graph plotting row labels (in this case they are Row1, Row2, ...) on
x-axis.
Any help would be appreciated,
Thanks,
Peng
-------------- next part --------------
Names Col1 Col2 Col3
Row1 -20 40 -10
Row2 30 -20 40
Row3 30 10 -20
Row4 20 20 -10
2023 Apr 03
1
Simple Stacking of Two Columns
...get a single column
> NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly"))
> > NamesLong
> Names
> 1 Tom
> 2 Dick
> 3 Larry
> 4 Curly
>
>
> Stack produces an error
> NamesLong<-stack(NamesWide$Name1,NamesWide$Names2)
> Error in if (drop) { : argument is of length zero
>
> So does bind_rows
> > NamesLong<-dplyr::bind_rows(NamesWide$Name1,NamesWide$Name2)
> Error in `dplyr::bind_rows()`:
> ! Argument 1 must be a data frame or a named atomic vector.
> Run `rlang::last_error()` to see wh...
2023 Apr 04
1
Simple Stacking of Two Columns
...a.frame(Names=c("Tom","Dick","Larry","Curly"))
>>> NamesLong
>> Names
>> 1 Tom
>> 2 Dick
>> 3 Larry
>> 4 Curly
>>
>>
>> Stack produces an error
>> NamesLong<-stack(NamesWide$Name1,NamesWide$Names2)
>> Error in if (drop) { : argument is of length zero
>>
>> So does bind_rows
>>> NamesLong<-dplyr::bind_rows(NamesWide$Name1,NamesWide$Name2)
>> Error in `dplyr::bind_rows()`:
>> ! Argument 1 must be a data frame or a named atomic vector.
>> Run `rla...
2009 Dec 02
1
Fw: Re: Help: barchart() {Lattice}
...free"
> >>
> >>
> >> > 2. While reading in the data, I'm using "row.names=Names". Can I
> >> > generalize
> >> > this? What I mean is if for some other data set, the row names column
> >> > has some other name (say Names2) or may be just blank. Can I still
> >> > produce a
> >> > similar graph plotting row labels (in this case they are Row1, Row2,
> >> > ...) on
> >> > x-axis.
> >>
> >> row.names can be a column number (1)
> >> See ?read.tabl...