This question already has answers here:
Concatenate a vector of strings/character
(8 answers)
Closed 5 years ago.
I have a data frame like this:
I want to convert those objects to a long string like this, without the column's name salary:
23400;26800;9878;6754;7654;28907;6679
What should I do?
Assuming your data.frame is called x:
paste0(x$salary,collapse=';')
Related
This question already has answers here:
How to reshape data from long to wide format
(14 answers)
Closed 2 years ago.
Suppose I have the following dataframe in R
I would like the dataframe to become
How do I do this?
Yeah, pivotwider was what I needed.
This question already has answers here:
How to drop columns by name pattern in R?
(6 answers)
Remove columns that contain a specific word
(5 answers)
Closed 3 years ago.
My data set has about 100 columns and some of them (about 25) are called similar but not them same. I'd like to delete all columns that start with "reads_per_million" because write this is so impractical:
data_tumor <- data_tumor[,-c(3,5,7,13,15,22,33,54,65,34,**etc,etc**)]
Thank you so much
This question already has answers here:
How do I paste string columns in data.frame [duplicate]
(2 answers)
Closed 5 years ago.
For example, if I have a data set
data.frame(x = c("a","b","a","b","c"))
how can I get a output =
a,b,a,b,c in a list or text.
paste(data_frame,collapse=",") will collapse the column into a single string.
This question already has answers here:
How do I make a matrix from a list of vectors in R?
(6 answers)
Combine a list of data frames into one data frame by row
(10 answers)
Closed 5 years ago.
I have a dat frame called crimeLARaw_tbl_final.
One of the columns called location_1.coordinates, is a ‘list’ data type column which contains a list of values:
location_1.coordinates
c(-118.3157, 34.0454)
c(-118.2717, 34.001)
c(-118.2671, 34.0294)
c(-118.4517, 33.967)
How could I bring each value in the list to its own column?
long lat
-118.3157 34.0454
-118.2717 34.001
-118.2671 34.0294
-118.4517 33.967
I have tried with dplyr and stringr but not getting anywhere.
Thank you
This question already has answers here:
Most efficient list to data.frame method?
(2 answers)
Closed 9 years ago.
I have a list of 3000 vectors in R. How can I create a data frame from the first 1000 elements of this list?
Cheers
You can do:
data.frame(myList[1:1000])
This makes the assumption that the vectors are all the same length. If they are not, values will be recycled.