Displaying rows and columns vertically - qt

I'm working on a qt application using the model / view architecture, and I'm having trouble displaying the columns from my SQLite table. I have tried to use a qlistview and a qtableview in many different ways, but have failed so far.
I want to lay everything out vertically like this:
ItemView
Data of row 1, column 1
Data of row 1, column 2
Data of row 2, column 1
Data of row 2, column 2
Data of row 3, column 1
Data of row 3, column 2
How can I achieve this?

Related

Subsetting a dataframe with columns of interest in an unusual pattern

I currently have a dataframe which is 500 rows x 39042 columns in size. Essentially I would like to subset a specific sequence of columns in this data frame which are in the following pattern:
1, 4, 7, 8, 11, 14, 15, 18, 21 ....
The file is too large for R so I have attached a picture of what the data looks like in Excel. The columns in red are the ones I would like to extract
I have thought about stacking the dataframe every 9 columns (so the data will follow a consistent pattern), subsetting only the three columns of interest and re-formatting to a wide format, but I don't know how to do this. There was a similar question posted previously about stacking columns, (Automatically stack every nth column of a dataframe) but that was for a small dataframe and I am having issues using the answers posted there on my data.
If you need any more info please let me know.
Thanks!

Why is my csv export from R to Excel showing all the conent from one row in a single cell?

I'm trying to transform my data frame from R to Excel so I used the most obvious way:
write.csv(dataframe, "path")
This is working so far but if I'm opening it on Excel it's just terrible. I'm having 600 rows with 18 columns but Excel shows all the content from one row (so all the columns with different numbers, but also longer string text) in the very first cell, so A1, A2, A3 etc. Why isn't it showing the content from row 1, column 1 in A1 and then row 1, column 2 in A2 and so on?
I'm almost breaking down over this problem since this is the very last step of a quite long work and I don't know what to do. If anyone can help I'd be so grateful!

Matching multiple letters across rows

I want to analyze my dataset in a certain way, but unfortunately, despite spending a lot of time on R, I could not figure out how to accomplish the task. Below is what I want to do:
Dataset name: Proteome (this dataset has thousands of rows and 14 columns: below I am showing only four entries in column 5)
Row 1, column 5: GHFCLKPGCNFHAESTRGYR
Row 2, column 5: FCLKPGCNFHAESTRGYR
Row 3, column 5: GHFCLKPGCNFHAESTR
Row 4: column 5: GCNFHAESTR
In row 2, first two letters of row 1 are missing;
in row 3, last three letters of row 1 are missing;
in row 4, first seven and last three letters of row 1 are missing.
Rows 2, 3, and 4 reflect the artifacts of the scientific method I have been using to generate the data, and therefore I want to remove these entries.
Ideally, I want R to return me the top entry, but it would be OK if R could only collapse such rows into a single row. My idea is to collapse multiple rows into one if five consecutive letters in those rows match with each other. In the above example, GCNFHAESTR match in all four rows, so I want R to return me only one row, ideally the top one.

insert one data frame into another data frame by columns

Sorry I did not find similar answer, if there were, from past posts here.
Suppose I have two simple n-by-m data frames, df1 and df2. Now I want to combine them to get a n-by-2m data frame called df. By doing this, I want column 1 in df2 to be column 2 in df, column 2 in df2 to be column 4 in df, column 3 in df2 to be column 6 in df....Meanwhile, column 1 in df1 is column 1 in df, column 2 in df1 is column 3 in df...
It means in the new df, column 1, 3, 5, 7...come from df1 and column 2, 4, 6, 8...come from df2.
In general, it looks like to INSERT df2 into df1 by every other column, to put each column of df2 behind its corresponding column in df1.
Can anybody help me on this?
why does it need to be that way, they are variables after all, but if you want to do it
m<-ncol(df1)
df<-merge(df1,df2)
df<-df[,c(seq(1,2*m, by=2),seq(2,2*m, by=2))

Remove Data in a data frame based on an index column

Looking at a Data Frame like so:
set.seed(3)
Data1<-rnorm(20, mean=20)
Dir_1<-rnorm(20,mean=2)
Data2<-rnorm(20, mean=21)
Dir_2<-rnorm(20,mean=2)
Data3<-rnorm(20, mean=22)
Dir_3<-rnorm(20,mean=2)
Data4<-rnorm(20, mean=19)
Dir_4<-rnorm(20,mean=2)
Data5<-rnorm(20, mean=20)
Dir_5<-rnorm(20,mean=2)
Data6<-rnorm(20, mean=23)
Dir_6<-rnorm(20,mean=2)
Data7<-rnorm(20, mean=21)
Dir_7<-rnorm(20,mean=2)
Data8<-rnorm(20, mean=25)
Dir_8<-rnorm(20,mean=2)
Index<-rnorm(20,mean=5)
DF<-data.frame(Data1,Dir_1,Data2,Dir_2,Data3,Dir_3,Data4,Dir_4,Data5,Dir_5,Data6,Dir_6,Data7,Dir_7,Data8,Dir_8,Index)
I end up with a data frame with two columns of data per observation (based on observation 1-8) and an index. Based on this index I would like to remove (or make NA) certain data observations.
As an example:
If the index is greater than 5, drop observation 8 (both Data and Dir) in that row
If the index is greater than 4, drop observations 7 and 8 in that row
If the index is greater than 3 and less then 3.5, drop 6,7,8 in that row
I was hoping to come up with a series of "if" statements that would let me drop columns for each row based on an index value.
Assuming what you want is not to "drop columns for a row" but put NAs into the proper columns for the rpecific row, you need to use a few index vectors and not a series of if statements:
DF[DF$Index>3 & DF$Index<3.5, (6*2-1):(8*2)] <- NA
DF[DF$Index>4, (7*2-1):(8*2)] <- NA
DF[DF$Index>5, (8*2-1):(8*2)] <- NA

Resources