This question already has answers here:
How do I split a data frame among columns, say at every nth column?
(1 answer)
What is the algorithm behind R core's `split` function?
(1 answer)
Closed 4 years ago.
I have a data frame that is 640 rows by 50,002 columns. I need to split the data columns 2:50001 into 5 equal groups. I have tried the split and sample commands but it gave an error.
Related
This question already has answers here:
how to remove multiple columns in r dataframe?
(8 answers)
Select column 2 to last column in R
(4 answers)
Closed 2 years ago.
I have a data frame that I import from excel each week with 40+ columns. Each week the data frame has a different number of columns, I am only interested in the first 40. I take the data frame, drop the columns after 40 and rbind to another data frame (that has 40 columns).
The code I use to drop the columns is"
df = df[ -c(40:45) ] #assume df has 45 columns this week.
I would like to find a step to automate the lendth of columns to drop, similar to length(df$x) type of idea. I try width(df) but doesn't seem to work?
Any ideas please?
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:
Extracting specific columns from a data frame
(10 answers)
Closed 4 years ago.
in R programming, how do I subset a matrix so that I can skip columns in between? I only know how to do it continuously such as 1:4, but what if I want the first, second, and fourth colum
You can select specific columns as follows:
new_df <- x[,c(1,2,4)]# Select column 1,2 and 4
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.