Referencing offset cells with INDIRECT() function - formula

Suppose that I have a cell, lets say Sheet2.A1, with the value: Sheet1.A10.
It contains the information from where to fetch the data.
Now I would like to fetch this data, which I do with INDIRECT(Sheet2.A1). However, I would further like to extract the data from some cells below in the same column. So suppose I would like to extract data from Sheet1.A11 and Sheet1.A12.
How can I calculate this offset to extract the data?
Is there any extension to the INDIRECT function where I can add this offset of one or two columns below?

I resolved it using =OFFSET(INDIRECT(Sheet2.A1),1,0) and =OFFSET(INDIRECT(Sheet2.A1),2,0)

Related

How to convert categorical string variables in Excel to numeric variables?

I am trying to analyze road collision data. I need to convert the categorical data into numeric data in Excel before I import it to RStudio, but I am not able to do it.
Excel file containing the sample data to be used:
Have a look at this, as I don't know which value you want to search with and which you want as the result, I have shown it taking the weather and returning the leftmost column.
You can change that as you need as I have used Index() with match().
So, based on the comment, all you need is left() to get the number, I have used find() to get the space just in case you have 2 or 3 digit numbers...
=LEFT(C3,FIND(" ",C3,1)-1)
C3 is the target cell, drag down as far as...

How can I dynamically refer to an attribute in an R data frame?

I have a SpatialLinesDataFrame named df with a number of attributes. These attributes represent the permutations of three dimensions:
dim1
dim2
dim3
The attributes thus are:
df$dim1a.dim2a.dim3a
df$dim1a.dim2a.dim3b
df$dim1a.dim2b.dim3a
...
df$dim1b.dim2a.dim3a
df$dim1b.dim2a.dim3b
...
df$dim1n.dim2n.dim3n
I am now trying to make my data accessible in Shiny, where I offer a widget item for each dimensions that allows the user select one value for that dimension. If the user selects
dim1a
dim2c
dim3b
I want to display data for df$dim1a.dim2c.dim3b.
How can I dynamically access the part of the data frame that the user is asking to have displayed?
I can construct the name of the attribute by constructing it via
display_data <- paste0(input$radioButton_dim1,'.',input$radioButton_dim2,'.',input$radioButton_dim3)
But how can I refer to it when trying to select it from the df or subset the data frame to select the data?
+++ Update:
When I try subsetting the data frame by using df[,display_data], the objects of class "Lines" are being returned. If I just use df$dim1a.dim2c.dim3b, I get a list of the actual attribute values for those objects, which is what I am looking for.
+++
If this is not easily feasible or not recommended for some reason, can something like melting/casting also be performed on a SpatialLinesDataFrame?

How to get index of certain value in tableView?

in Qt u can get data from index like this 'Index.data().toString()', i need opposite. I have data and i want index.
Is there in Qt some native function? Or i have to map those data in some array for example
In order to obtain the index by data, you have to traverse your table to find corresponding row and column numbers. You can do it manually, or using QAbstractItemModel::match() function. For example:
QModelIndexList foundIndexes = tableView->model()->match(QModelIndex(),
Qt::DisplayRole,
"My String");
You can change the function arguments to get search result that better fits your need.

Dataset Tables Merging in single dataset with result set

I have three result sets and that will be in the Dataset. So each result set has only one Row. No I want to make it into one Table with three rows.
Example ::
Result Set ::
ds.Tables[0].Rows[0]["A"],
ds.Tables[1].Rows[0]["B"],
ds.Tables[2].Rows[0]["C"]
My desired Output ::
ds.Tables[0].Rows[0]["A"],
ds.Tables[0].Rows[0]["B"],
ds.Tables[0].Rows[0]["C"]
How can I achieve this?
Could you not use the DataTable.Merge method? Start with a clone of the first table and then merge in the data from the other tables?
The Merge method has an option, MissingSchemaAction, that lets you specify that new columns should be added to the resulting table so it should do what you are after.

Loop in R to create and save series of ggplot2 plots with specified names

I have a data frame in R with POSIXct variable sessionstarttime. Each row is identified by integer ID variable of a specified location . Number of rows is different for each location. I plot overall graph simply by:
myplot <- ggplot(bigMAC, aes(x = sessionstarttime)) + geom_freqpoly()
Is it possible to create a loop that will create and save such plot for each location separately?
Preferably with a file name the same as value of ID variable?
And preferably with the same time scale for each plot?
Not entirely sure what you're asking but you can do one of two things.
a) You can save each individual plot in a loop with a unique name based on ID like so:
ggsave(myplot,filename=paste("myplot",ID,".png",sep="")) # ID will be the unique identifier. and change the extension from .png to whatever you like (eps, pdf etc).
b) Just assign each plot to an element of a list. Then write that list to disk using save
That would make it very easy to load and access any individual plot at a later time.
I am not sure if I get what you want to do. From what I guess, i suggest to write a simple function that saves the plot. and then use lapply(yourdata,yourfunction,...) . Since lapply can be used for lists, it´s not necessary that the number of rows is equal.
HTH
use something like this in your function:
ggsave(filename,scale=1.5)

Resources